Fix sanitizer attribute infrastructure to use standard TREE_LIST format [PR113264]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · hanwei (K)
Ping...
Can you submit a full new patch rather than just a patch on top of Kees patch? Please use Co-authored-by: too.
Thanks,
Andrew
Quoted 168 lines
Quoted 168 lines · On Wed, Feb 25, 2026 at 12:28 AM hstk30 <[email protected]> wrote:
Quoted 97 lines · Andrew Pinski
Quoted 53 lines · Kees Cook
Quoted 35 lines
The __attribute__((__copy__)) functionality was crashing when
copying sanitizer-related attributes because these attributes
violated the standard GCC attribute infrastructure by storing
INTEGER_CSTvalues directly instead of wrapping them inTREE_LISTlike all other attributes.Wrap sanitizer attributes
INTEGER_CSTvalues inTREE_LISTstructuresto follow the same pattern as other attributes. This eliminates the
copy_list()crashes when copying sanitizer attributes:test.c:4:1: internal compiler error: tree check: expected tree that contains ‘common’ structure, have ‘integer_cst’ in
copy_list, at tree.cc:14274 | __attribute__((__copy__(__tanh))); | ^~~~~~~~~~~~~
0x859d06tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*)../../gcc/gcc/tree.cc:9126
0x860f78contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)../../gcc/gcc/tree.h:3748Quoted 7 lines
0x860f78copy_list(tree_node*)../../gcc/gcc/tree.cc:1427
0xa755a5handle_copy_attribute../../gcc/gcc/c-family/c-attribs.cc:3077I am not a fan of the wrapping because it increases the memory usage
Quoted 7 lines
slightly but it is required since the rest of the attributes code
requires
TREE_LISThere.So Ok. I will do final testing either Monday or Tuesday and push it after that.
So this causes some ICEs in the testsuite:
FAIL:
c-c++-common/asan/inline-kernel.c-O0 (internal compilererror: in
tree_to_sanitize_code_type, at tree.cc:6704)
0xa4376bfancy_abort(char const*, int, char const*)
/home/apinski/src/upstream-gcc-new/gcc/gcc/diagnostics/context.cc:1812
0x92f581tree_to_sanitize_code_type(tree_node const*)/home/apinski/src/upstream-gcc-new/gcc/gcc/tree.cc:6704
0x92f581tree_to_sanitize_code_type(tree_node const*)/home/apinski/src/upstream-gcc-new/gcc/gcc/tree.cc:6702
0x128bea2print_no_sanitize_attr_value/home/apinski/src/upstream-gcc-new/gcc/gcc/tree-cfg.cc:8223
0x128bea2dump_function_to_file(tree_node*, _IO_FILE*, dump_flag)/home/apinski/src/upstream-gcc-new/gcc/gcc/tree-cfg.cc:8276Quoted 3 lines
Looks like you forgot to update
dump_function_to_filetoo.Can you double check all of the locations that use
tree_to_sanitize_code_typeto make sure they all have been fixed?Fix this fail by below patch:
gcc/tree-cfg.cc +0
-0index
66ea54f8b85..808b8000603100644--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
gcc/tree-cfg.cc +4
-1@@ -8220,7 +8220,10 @@ dump_default_def (FILE *file, tree def, int spc, dump_flags_t flags) static void print_no_sanitize_attr_value (FILE *file, tree value) { - sanitize_code_type flags = tree_to_sanitize_code_type (value); + /* Extract the INTEGER_CST from the TREE_LIST wrapper. */ + gcc_assert (TREE_CODE (value) == TREE_LIST); + sanitize_code_type flags = tree_to_sanitize_code_type (TREE_VALUE (value)); + bool first = true; for (int i = 0; sanitizer_opts[i].name != NULL; ++i) {I have checked the patch which first introduces the
tree_to_sanitize_code_type(https://inbox.sourceware.org/gcc-patches/[email protected]/)
Quoted 13 lines
Thanks,
Andrew
Quoted 5 lines
Thanks,
Andrew