-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Incorrect values added by CreateVectorOfStructs() when the vector parameter has an odd size [C++, clang 15, OS X, 22.9.24 and later] #8117
Comments
I also encountered this same bug and came to the same conclusion. To reproduce it, I riffed off the unit test added to the commit referenced above:
The unit test (also riffing off the original unit test):
yields a failure:
This is a pretty significant regression. |
This issue is stale because it has been open 6 months with no activity. Please comment or label |
I repeat: this is a pretty significant regression. Generated code leads to corrupted data. |
So my test repo above passes if I point to commit fb9afba, which I think is the last that passed tests? I'm trying to get tests to run locally to try @mikemccarty-vertex 's unit test. |
I'm fairly confident this is fixed now. I added another field to the JustSmallStruct test in the latest master I'll wait for @mikemccarty-vertex to comment before closing. |
Thanks @nolen777 for working through this. I admit I didn't do my due diligence on this since the last time I checked into it. It looks like you've been very thorough. My only remaining question: Is there now a unit test in the repo that exercises this scenario? This is subtle enough that it's not hard imagining this sort of problem someday cropping up again. |
I don't believe there is a test that catches it. I'll try back-porting the existing test to the failing commit to verify that, and then I could probably adjust my patch to add to the existing unit tests instead of replacing one. I won't be able to get to it for a few days, and it's not clear this repo is accepting outside contributions, but I'll give it a shot. |
I think #8363 should do it |
* add an odd sized test * formatting --------- Co-authored-by: Derek Bailey <[email protected]>
…#8363) * add an odd sized test * formatting --------- Co-authored-by: Derek Bailey <[email protected]>
…#8363) * add an odd sized test * formatting --------- Co-authored-by: Derek Bailey <[email protected]>
When I call FlatBufferBuilder::CreateVectorOfStructs() passing in a vector with an odd number of entries, the created vector always has zero values in the first entry.
I believe this is a regression in 72aa85a
I've created a small repro case at https://github.com/nolen777/flatbuffers-test
To reproduce:
The test is just checking that the entries in the FB are the same as the entries in the original vector.
If you change the argument vector to have an even number of entries (comment out line 22 and un-comment line 19 in src/main/cpp/test.cpp), the test passes. If you change the WORKSPACE file to the previous commit, the test passes. But on commit 72aa85a or later with an odd number of entries, the test fails.
The text was updated successfully, but these errors were encountered: