crashappsec / libcon4m

Base Compiler and Runtime Support for con4m
Apache License 2.0
0 stars 0 forks source link

SIGSEGV: when using `~` #58

Open ee7 opened 3 months ago

ee7 commented 3 months ago

With:

The .c4m file:

x = 1
~x

produces the ASan output:

ERROR: AddressSanitizer: SEGV on unknown address 0x000000000004 (pc 0x5c3742234b28 bp 0x7ffd55a63d10 sp 0x7ffd55a63c70 T0)
The signal is caused by a READ memory access.
Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x5c3742234b28 in gen_one_kid libcon4m/debug/../src/con4m/compiler/codegen.c:478:16
    #1 0x5c374222ff70 in gen_lock libcon4m/debug/../src/con4m/compiler/codegen.c:1783:5
    #2 0x5c374221fba4 in gen_one_node libcon4m/debug/../src/con4m/compiler/codegen.c:1901:9
    #3 0x5c37422241aa in gen_kids libcon4m/debug/../src/con4m/compiler/codegen.c:466:9
    #4 0x5c3742223c66 in gen_module libcon4m/debug/../src/con4m/compiler/codegen.c:787:5
    #5 0x5c374221f710 in gen_one_node libcon4m/debug/../src/con4m/compiler/codegen.c:1805:9
    #6 0x5c374221df59 in gen_module_code libcon4m/debug/../src/con4m/compiler/codegen.c:2110:5
    #7 0x5c374221b383 in c4m_internal_codegen libcon4m/debug/../src/con4m/compiler/codegen.c:2188:9
    #8 0x5c3742174cb6 in c4m_generate_code libcon4m/debug/../src/con4m/compiler/compile.c:1079:5
    #9 0x5c374200e63f in test_compiler libcon4m/debug/../src/tests/test.c:441:20

and e.g.:

~foo.bar = 1

produces:

ERROR: AddressSanitizer: SEGV on unknown address (pc 0x5cf9ab39cedb bp 0x7ffc0e587510 sp 0x7ffc0e587180 T0)
The signal is caused by a READ memory access.
Hint: this fault was caused by a dereference of a high value address.
SCARINESS: 20 (wild-addr-read)
    #0 0x5cf9ab39cedb in hatrack_dict_get_hash_value libcon4m/debug/../src/hatrack/hash/dict.c:682:14
    #1 0x5cf9ab39bb8c in hatrack_dict_get_mmm libcon4m/debug/../src/hatrack/hash/dict.c:205:10
    #2 0x5cf9ab39dadc in hatrack_dict_get libcon4m/debug/../src/hatrack/hash/dict.c:237:12
    #3 0x5cf9ab40a7d5 in c4m_vm_attr_lock libcon4m/debug/../src/con4m/attrstore.c:130:37
    #4 0x5cf9ab25f9f9 in c4m_vm_runloop libcon4m/debug/../src/con4m/vm.c:1127:21
    #5 0x5cf9ab24c4f9 in c4m_vmthread_run libcon4m/debug/../src/con4m/vm.c:1664:18
    #6 0x5cf9ab161919 in test_compiler libcon4m/debug/../src/tests/test.c:453:5
viega commented 3 months ago

I have not done all the work on attributes yet, including this. The two examples will, when I hook them up, give two different errors because the first is a variable not an attr, unless specified in a confspec.

Confspecs are not done yet either.