slachiewicz opened a new pull request, #3924: URL: https://github.com/apache/thrift/pull/3924
`print_const_value` cast the declared type of a constant to `t_map`, `t_list` or `t_set` by the shape of the value without checking the type. A struct literal is a map value over a `t_struct` and a typedef of a container is a `t_typedef`, so the cast read out of bounds; an enum identifier or a nested container under the wrong type then dereferenced the garbage and the compiler crashed. `--gen gv` on `test/DebugProtoTest.thrift` and `test/EnumTest.thrift` crashes today; https://issues.apache.org/jira/browse/THRIFT-6332 has the three-line reproducer and the AddressSanitizer trace. The value's shape now follows the resolved type, and a struct literal is walked field by field with each field's own type. Keys keep the quoted rendering the surviving cases had. The new test in `compiler/cpp/tests/gv/` writes the affected shapes and checks the rendered constants; it turns the gv generator on in the tests' CMake, as `tests/README.md` describes. With the fix reverted the test binary segfaults. Verified: AddressSanitizer build over every `.thrift` file in the repository → no reports; output byte-identical for the 154 files that did not crash before; the 5 that crashed generate. `git clang-format --diff` on the generator → empty. - [x] JIRA ticket: THRIFT-6332 - [x] Title follows `THRIFT-NNNN:` pattern - [x] Single commit - [x] No breaking change -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
