Fixed bug with parents_stack being static #88
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.