Correcting an UBSan error in builder#344
Merged
Merged
Conversation
If a table with optional fields is created before the ds-stack is allocated we get an UBSan error.
The ds stack would normally be allocated when a field is added to the table.
/xxxx/flatcc/src/runtime/builder.c:613:16: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:61:62: note: nonnull attribute specified here
#0 0x600c6b6e in exit_frame /xxxx/flatcc/src/runtime/builder.c:613:9
dvidelabs#1 0x600d4520 in flatcc_builder_end_table /xxxx/flatcc/src/runtime/builder.c:1380:5
dvidelabs#2 0x600a0be8 in optional_scalars_NestedTable_end /xxxx/flatcc/build/Debug/test/optional_scalars_test/generated/optional_scalars_test_builder.h:35:1
dvidelabs#3 0x600a08a7 in create_scalar_stuff /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:27:20
dvidelabs#4 0x600ab4f5 in test /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:176:5
dvidelabs#5 0x600abd1f in main /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:272:9
dvidelabs#6 0xe9186518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 6f8a2d2f90a25e7865aa6fdfd9a7825d62d53f51)
dvidelabs#7 0xe91865f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 6f8a2d2f90a25e7865aa6fdfd9a7825d62d53f51)
dvidelabs#8 0x6007053a in _start (/xxxx/flatcc/build/Debug/test/optional_scalars_test/optional_scalars_test_d+0x2653a) (BuildId: d47f8a02ee936bc1bc53a0efd6ad360faa6428d7)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /xxxx/flatcc/src/runtime/builder.c:613:16
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If a table with optional fields is created before the ds stack is allocated we get an UBSan error.
The ds stack is normally allocated when the first field is added to the table.
Reproduced by adding some steps in test
optional_scalars_test.See #343 for additional fixes.
This probably need an extra pair of eyes from an expert..