You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnvoid!AstProject.load(&self) {
if (self.proj_path) {
path::Pathp=path::temp_new(self.proj_path)!;
if (!path::is_dir(p)) {
returnIoError.FILE_NOT_DIR?;
}
path::PathWalkerfnwalk=fnbool!(Pathp, boolis_dir, void*ctx) {
AstProject*self= (AstProject*)ctx;
if (is_dir) returnfalse;
returnfalse;
};
p.walk(fnwalk, self)!!;
}
}
With sanitizer, it fails at:
==3625966==ERROR: AddressSanitizer: container-overflow on address 0x7ffc2d7b2f18 at pc 0x7f0b91cb6c25 bp 0x7ffc2d7b2cd0 sp 0x7ffc2d7b2480
WRITE of size 16 at 0x7ffc2d7b2f18 thread T0
#0 0x7f0b91cb6c24 in __asan_memcpy ../../../../src/libsanitizer/asan/asan_interceptors_memintrinsics.cpp:22
#1 0x557436aa1729 in std.io.path.PathImp.new_append /home/ubertrader/code/c3c/lib/std/io/path.c3
#2 0x557436aa4b20 in std.io.path.PathImp.walk /home/ubertrader/code/c3c/lib/std/io/path.c3:561
#3 0x557436aa4e8c in std.io.path.PathImp.walk /home/ubertrader/code/c3c/lib/std/io/path.c3:564
#4 0x557436ae3f23 in c3tools.ast.AstProject.load /home/ubertrader/code/c3test/lib/c3tools/ast.c3:323
#5 0x557436ae4406 in c3symbols.process_dir /home/ubertrader/code/c3test/src/c3symbols.c3:10
#6 0x557436ae4d9e in c3symbols.main /home/ubertrader/code/c3test/src/c3symbols.c3:94
#7 0x557436ae5746 in @main_to_int_main_args /home/ubertrader/code/c3c/lib/std/core/private/main_stub.c3:47
#8 0x557436ae5746 in main /home/ubertrader/code/c3test/src/c3symbols.c3:69
#9 0x7f0b91967249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#10 0x7f0b91967304 in __libc_start_main_impl ../csu/libc-start.c:360
#11 0x557436a2e490 in _start (/home/ubertrader/code/c3test/build/c3symbols+0x1d490)
Since you're passing self using &self it's already a AstProject* so when you take the address of that, you're passing an AstProject** which you then cast to AstProject* which isn't great.
Also, because it is void*, this is sufficient: AstProject* self = ctx;
Consider this sample example:
With sanitizer, it fails at:
I think it caused by this line: https://github.com/c3lang/c3c/blob/master/lib/std/io/path.c3#L554, maybe stack overflow?
Another proposal: can we replace
void*
byany
? I segfaulted when passedp.walk(fnwalk, &self)!!;
instead ofp.walk(fnwalk, self)!!;
The text was updated successfully, but these errors were encountered: