On Tue, Jun 9, 2020 at 3:38 AM Shuai Wang via Gcc <gcc@gcc.gnu.org> wrote: > > Hello! > > I am writing to report a potential bug I encountered when playing with the > GIMPLE IR. I enabled the ASan and would like to print out all ASAN_MARK > statements for the following simple code: > > int main(int argc ,char **argv) > { > int stack_array[100]; > stack_array[1] = 100; > stack_array[argc + 12]; // an ASan check, namely, ASAN_MARK, will > be inserted at this point > } > > And I am using the following code snippet (basically derived from this > post > <https://stackoverflow.com/questions/29346772/print-called-function-name-using-gcc-plugin>) > to print out all function calls, including ASAN_MARK: > > if (is_gimple_call(stmt)){ > tree current_fn_decl = gimple_call_fndecl(stmt); > const char* name = get_name(current_fn_decl); > cerr << " Function : " << name << " is called \n"; > } > > However, I note that some internal exceptions are encountered, when I > use gcc version 7.4, 8.3, and also 9.3: > > test.c: In function ‘main’: > test.c:9:5: internal compiler error: Segmentation fault > 9 | int main(int argc ,char **argv) > | ^~~~ > 0xab88bf crash_signal > ../../gcc-9.3.0/gcc/toplev.c:326 > 0xcfc836 location_wrapper_p(tree_node const*) > ../../gcc-9.3.0/gcc/tree.h:3812 > 0xcfc836 tree_nop_conversion > ../../gcc-9.3.0/gcc/tree.c:12850 > 0xcfc836 tree_strip_nop_conversions(tree_node*) > ../../gcc-9.3.0/gcc/tree.c:12888 > 0xcfc836 get_name(tree_node*) > ../../gcc-9.3.0/gcc/tree.c:12559 > 0x7f9466d86bb7 execute > > /home/shuaiw/work/sanitizer_reduction_gcc/demo/walk_gimple/walk_gimple.cc:61 > Please submit a full bug report, > with preprocessed source if appropriate. > Please include the complete backtrace with any bug report. > See <https://gcc.gnu.org/bugs/> for instructions. > Makefile:10: recipe for target 'test' failed > make: *** [test] Error 1 > > > I think the issue is due to ASAN_MARK, because when I comment out that > particular array access which induces the ASAN_MARK, all other function > calls, including ASan related functions, __builtin___asan_init > and __builtin___asan_version_mismatch_check_v8, and be smoothly printed out > with no issue. > > Can I interpret it as a bug or somewhat? Any suggestions are welcomed. > Thank you very much.
ASAN_MARK is likely an internal function which does not have a function declaration so you feed get_name a NULL pointer. > > Best, > Shuai