Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with parents_stack being static #88

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

AjayBrahmakshatriya
Copy link
Collaborator

BuildIt had a major bug with the implementation of custom structs. BuildIt uses a parents_stack to keep track of dyn_var objects being constructed so nested objects can find existence (and pointers) of their parents.

There was a bug where the parents_stack was declared static in the header. This would generally be okay because the stack is pushed/popped from member_begin and member_end calls to which should be in the same translation unit. However since member_begin is templated there are many instances of it (potentially in different translation units) but just one member_end. This means these two could point to different instances of the stack. This leads to a problem with more pops on a vector than pushes which is undefined behavior.

To solve this, parents_stack has been made a single global.

Unfortunately, with the current infra, we cannot test this since it requires atleast two translation units. We can test it with a more rigorous test framework later.

@AjayBrahmakshatriya AjayBrahmakshatriya merged commit ceefecf into BuildIt-lang:master Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant