paul-j-lucas / cdecl

Composing and deciphering C (or C++) declarations or casts, aka ‘‘gibberish.’’
GNU General Public License v3.0
90 stars 11 forks source link

Function returning function parameter crash #20

Closed jengelh closed 2 years ago

jengelh commented 2 years ago

Version: f7124b1ad8773cc5e687b0d773f854ab2827195e

Reading symbols from c++decl...
(gdb) r 'explain void f(void ()())'
Starting program: /dev/shm/cdecl/src/c++decl 'explain void f(void ()())'
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.35-1.1.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000411df7 in yyparse () at /dev/shm/cdecl/src/parser.y:4702
4702          $$.ast->loc = @$;
Missing separate debuginfos, use: zypper install libncurses6-debuginfo-6.3.20220129-9.1.x86_64 libreadline8-debuginfo-8.1-3.1.x86_64
(gdb) bt
#0  0x0000000000411df7 in yyparse () at /dev/shm/cdecl/src/parser.y:4702
#1  0x0000000000427e73 in cdecl_parse_string (s=0x4e3e30 "explain void f(void ()())", s_len=25) at cdecl.c:399
#2  0x00000000004278e8 in cdecl_parse_command_line (command=0x0, argc=1, argv=0x7fffffffdba0) at cdecl.c:221
#3  0x00000000004277cc in cdecl_parse_argv (argc=1, argv=0x7fffffffdba0) at cdecl.c:187
#4  0x0000000000427730 in main (argc=1, argv=0x7fffffffdba0) at cdecl.c:148
(gdb) up
#1  0x0000000000427e73 in cdecl_parse_string (s=0x4e3e30 "explain void f(void ()())", s_len=25) at cdecl.c:399
399       int const status = yyparse() == 0 ? EX_OK : EX_DATAERR;
(gdb) 
#2  0x00000000004278e8 in cdecl_parse_command_line (command=0x0, argc=1, argv=0x7fffffffdba0) at cdecl.c:221
221       int const status = cdecl_parse_string( sbuf.str, sbuf.len );
(gdb) 
#3  0x00000000004277cc in cdecl_parse_argv (argc=1, argv=0x7fffffffdba0) at cdecl.c:187
187         return cdecl_parse_command_line( /*command=*/NULL, argc, argv );
(gdb) 
#4  0x0000000000427730 in main (argc=1, argv=0x7fffffffdba0) at cdecl.c:148
148       exit( cdecl_parse_argv( argc, argv ) );
paul-j-lucas commented 2 years ago

ACK. Working on it. It's tricky since it's at odds with implicit function-to-pointer-to-function conversion per 6.3.2.1(4) of the C11 standard.

paul-j-lucas commented 2 years ago

Fixed in this commit.