Open
Description
It is possible to return from a match what was passed to it:
(defn main []
(let [a (Maybe.Just @"aa")]
(ignore (match a
_ a))))
This should be a borrow checker error as match should have taken ownership of a
here.
This causes a double free as there is now two owners of a
.
Output of addresses sanitizer:
=================================================================
==22651==ERROR: AddressSanitizer: attempting double-free on 0x6020000000f0 in thread T0:
#0 0x10fd28549 in wrap_free+0xa9 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46549)
#1 0x10fc35684 in String_delete carp_string.h:17
#2 0x10fc896c2 in Maybe_delete__String main.c:7223
#3 0x10fc9376f in main main.c:9245
#4 0x7fff20340630 in start+0x0 (libdyld.dylib:x86_64+0x15630)
0x6020000000f0 is located 0 bytes inside of 3-byte region [0x6020000000f0,0x6020000000f3)
freed by thread T0 here:
#0 0x10fd28549 in wrap_free+0xa9 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46549)
#1 0x10fc35684 in String_delete carp_string.h:17
#2 0x10fc896c2 in Maybe_delete__String main.c:7223
#3 0x10fc93694 in main main.c:9236
#4 0x7fff20340630 in start+0x0 (libdyld.dylib:x86_64+0x15630)
previously allocated by thread T0 here:
#0 0x10fd28400 in wrap_malloc+0xa0 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46400)
#1 0x10fc35a3a in String_copy carp_string.h:64
#2 0x10fc932a8 in main main.c:9218
#3 0x7fff20340630 in start+0x0 (libdyld.dylib:x86_64+0x15630)
SUMMARY: AddressSanitizer: double-free (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46549) in wrap_free+0xa9
==22651==ABORTING