thradams / cake

Cake a C23 front end and transpiler written in C
http://thradams.com/cake/index.html
GNU General Public License v3.0
533 stars 21 forks source link

Segmentation fault on unfinished struct decl #155

Closed iphydf closed 6 months ago

iphydf commented 6 months ago
struct

Just the 1 keyword will result in:

#22 1.049 Program received signal SIGSEGV, Segmentation fault.
#22 1.049 0x00000000004323c1 in struct_or_union_specifier (ctx=0x7ffda435ab10) at parser.c:3080
#22 1.049 3080      if (ctx->current->type == TK_IDENTIFIER)
#22 1.049 #0  0x00000000004323c1 in struct_or_union_specifier (ctx=0x7ffda435ab10)
#22 1.049     at parser.c:3080
#22 1.049 #1  0x0000000000432132 in type_specifier (ctx=0x7ffda435ab10) at parser.c:2979
#22 1.049 #2  0x000000000043019e in type_specifier_qualifier (ctx=0x7ffda435ab10)
#22 1.049     at parser.c:3582
#22 1.049 #3  0x000000000042f07c in declaration_specifier (ctx=0x7ffda435ab10)
#22 1.049     at parser.c:2242
#22 1.049 #4  0x000000000042ed26 in declaration_specifiers (ctx=0x7ffda435ab10, 
#22 1.049     default_storage_flag=STORAGE_SPECIFIER_EXTERN) at parser.c:1887
#22 1.050 #5  0x000000000042f1dd in declaration_core (ctx=0x7ffda435ab10, 
#22 1.050     p_attribute_specifier_sequence_opt=0x0, can_be_function_definition=true, 
#22 1.050     is_function_definition=0x7ffda435a597, 
#22 1.050     default_storage_class_specifier_flags=STORAGE_SPECIFIER_EXTERN)
#22 1.050     at parser.c:2017
#22 1.050 #6  0x000000000042f763 in function_definition_or_declaration (
#22 1.050     ctx=0x7ffda435ab10) at parser.c:2083
#22 1.050 #7  0x00000000004391e5 in external_declaration (ctx=0x7ffda435ab10)
#22 1.050     at parser.c:6467
#22 1.050 #8  0x000000000043914f in translation_unit (ctx=0x7ffda435ab10, 
#22 1.050     berror=0x7ffda435a65f) at parser.c:6448
#22 1.050 #9  0x00000000004392a6 in parse (ctx=0x7ffda435ab10, list=0x7ffda435a800, 
#22 1.050     berror=0x7ffda435a76f) at parser.c:6547
#22 1.051 #10 0x0000000000439f32 in compile_one_file (
#22 1.051     file_name=0x7ffda435aff0 "/src/workspace/c-toxcore/crash.c", 
#22 1.051     options=0x7ffda435b9e8, 
#22 1.051     out_file_name=0x7ffda435b5f0 "/src/workspace/c-toxcore/out/crash.c", 
#22 1.051     argc=3, argv=0x7ffda435bc68, report=0x7ffda435bbf8) at parser.c:6834
#22 1.051 #11 0x000000000043a575 in compile (argc=3, argv=0x7ffda435bc68, 
#22 1.051     report=0x7ffda435bbf8) at parser.c:7067
#22 1.051 #12 0x000000000044910f in main (argc=3, argv=0x7ffda435bc68) at main.c:59
thradams commented 6 months ago

same as. (at least the fix will fix both I guess. crash on error #131

thradams commented 6 months ago

fixed.. may function that return list must be checked with a extra parameter bool berror. for the ones that return null on error try catch blocks are missing in many places.