Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dynamic-type-mismatch UBSAN error in t_json_generator.cc
Summary: Exposed by UBSAN: ```lang=bash thrift/compiler/generate/t_json_generator.cc:278:25: runtime error: downcast of address 0x610000000a40 which does not point to an object of type 't_set' 0x610000000a40: note: object is of type '6t_list' 03 00 80 34 28 b9 74 8a 5f 7f 00 00 58 0a 00 00 00 61 00 00 00 00 00 00 00 00 00 00 00 be be be ^~~~~~~~~~~~~~~~~~~~~~~ vptr for '6t_list' #0 0x7f5f8b1ec21d in t_json_generator::type_to_spec_args[abi:cxx11](t_type*) thrift/compiler/generate/t_json_generator.cc:278 #1 0x7f5f8b1ece84 in t_json_generator::print_type(t_type*) thrift/compiler/generate/t_json_generator.cc:293 #2 0x7f5f8b1f3de0 in t_json_generator::generate_struct(t_struct*) thrift/compiler/generate/t_json_generator.cc:484 #3 0x7f5f8b1e66aa in t_json_generator::generate_program() thrift/compiler/generate/t_json_generator.cc:161 #4 0x42ee58 in generate(t_program*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<cha r, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11:: basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) thrift/compiler/main.cc:305 #5 0x42b88e in main thrift/compiler/main.cc:681 #6 0x7f5f8734b857 in __libc_start_main /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../csu/libc-start.c:289 #7 0x425a28 in _start /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../sysdeps/x86_64/start.S:118 UndefinedBehaviorSanitizer: dynamic-type-mismatch thrift/compiler/generate/t_json_generator.cc:278:25 ``` The fix is inspired by https://github.com/apache/thrift/pull/1222/files Reviewed By: yfeldblum Differential Revision: D8154131 fbshipit-source-id: 0ff7d993b87c0fe20652865a89a2bb205dde10e3
- Loading branch information