What happens if you follow Dmitry's suggestion? sizeof(sigaction) is most likely not what you need.
On Thu, Jan 16, 2014 at 8:36 AM, laser <[email protected]> wrote: > -g was added, The Compile info and gdb is below. thanks! > > <gcc4.8 path>/i686-linux5.0-gcc -fsanitize=address -g -Wl,-rpath=<libasan > path>/lib -o segerror1 ./segerror1.c > > > (gdb) run > Starting program: /tmp/./segerror1 > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". > > Program received signal SIGSEGV, Segmentation fault. > 0x0804868b in main () at ./segerror1.c:11 > 11 memset(&sa, 0, sizeof(sigaction)); > (gdb) bt > #0 0x0804868b in main () at ./segerror1.c:11 > (gdb) bt full > #0 0x0804868b in main () at ./segerror1.c:11 > sa = {__sigaction_handler = {sa_handler = 0xbffff588, sa_sigaction = > 0xbffff588}, sa_mask = {__val = {3087006324, 0, 3062103960, 1, 0, 1, > 3087005976, 3061966280, 3061966288, > 3221222824, 3064042993, 3063833572, 3061050508, 3221222824, > 3061014528, 3061094460, 3062313366, 0, 3064042993, 3221222916, 3061966280, > 3064000985, 134518996, 134514512, > 0, 3221222776, 134514484, 3064105672, 3064104756, 3221222792, > 134514653, 134514512}}, sa_flags = 134519256, sa_restorer = 0xbffff598} > > > > > On Thursday, January 16, 2014 11:30:33 AM UTC+8, kcc wrote: >> >> This does not happen for me: >> >> % cat z.c >> #include <signal.h> >> #include <stdio.h> >> #include <stdlib.h> >> #include <string.h> >> >> >> int main(void) >> { >> struct sigaction sa; >> >> memset(&sa, 0, sizeof(sigaction)); >> sigemptyset(&sa.sa_mask); >> // sa.sa_flags = SA_SIGINFO; >> >> // sigaction(SIGSEGV, &sa, NULL); >> >> return 0; >> } >> % clang z.c -fsanitize=address && ./a.out >> % >> >> >> Please provide more info. How do you compile? (make sure to add -g) >> run this under gdb and show what 'bt' says. >> >> --kcc >> >> >> On Thu, Jan 16, 2014 at 7:14 AM, laser <[email protected]> wrote: >> > Hi experts, >> > >> > asan report segment fault error for memset line in the simple code >> > below, >> > valgrind doesn't report it, could you explain the reason? >> > >> > >> > 1 #include <signal.h> >> > 2 #include <stdio.h> >> > 3 #include <stdlib.h> >> > 4 #include <string.h> >> > 5 >> > 6 >> > 7 int main(void) >> > 8 { >> > 9 struct sigaction sa; >> > 10 >> > 11 memset(&sa, 0, sizeof(sigaction)); >> > 12 sigemptyset(&sa.sa_mask); >> > 13 // sa.sa_flags = SA_SIGINFO; >> > 14 >> > 15 // sigaction(SIGSEGV, &sa, NULL); >> > 16 >> > 17 return 0; >> > 18 } >> > >> > >> > >> > >> > >> > root@terry-lx:/tmp# ./segerror1 >> > >> > ASAN:SIGSEGV >> > >> > ================================================================= >> > >> > ==26565== ERROR: AddressSanitizer: SEGV on unknown address 0x17f91a12 >> > (pc >> > 0x0804868b sp 0xbfc8d060 bp 0xbfc8d158 T0) >> > >> > AddressSanitizer can not provide additional info. >> > >> > #0 0x804868a (/tmp/segerror1+0x804868a) >> > >> > #1 0xb5fda4d2 (/lib/i386-linux-gnu/libc-2.15.so+0x194d2) >> > >> > #2 0x8048510 (/tmp/segerror1+0x8048510) >> > >> > ==26565== ABORTING >> > >> > root@test-lx:/tmp# ./segerror1 2>&1 | ./asan_symbolize.py | c++filt >> > >> > /tmp/llvm-3.4/llvm/Release+Asserts/bin/llvm-symbolizer >> > --use-symbol-table=true --demangle=False --functions=true >> > --inlining=true >> > >> > ASAN:SIGSEGV >> > >> > ================================================================= >> > >> > ==26566== ERROR: AddressSanitizer: SEGV on unknown address 0x17ff0c3a >> > (pc >> > 0x0804868b sp 0xbff861a0 bp 0xbff86298 T0) >> > >> > AddressSanitizer can not provide additional info. >> > >> > #0 0x804868a (/tmp/segerror1+0x804868a) >> > >> > >> > /tmp/segerror1 0x804868a >> > >> > #0 0x804868a in main /tmp/./segerror1.c:11:0 >> > >> > #1 0xb60184d2 (/lib/i386-linux-gnu/libc-2.15.so+0x194d2) >> > >> > >> > /lib/i386-linux-gnu/libc-2.15.so 0x194d2 >> > >> > addr2line -f -e /lib/i386-linux-gnu/libc-2.15.so >> > >> > /lib/i386-linux-gnu/libc-2.15.so 0x194d2 >> > >> > #1 0xb60184d2 in __libc_start_main >> > /build/buildd/eglibc-2.15/csu/libc-start.c:226 >> > >> > #2 0x8048510 (/tmp/segerror1+0x8048510) >> > >> > >> > /tmp/segerror1 0x8048510 >> > >> > addr2line -f -e /tmp/segerror1 >> > >> > /tmp/segerror1 0x8048510 >> > >> > #2 0x8048510 in _start ??:0 >> > >> > ==26566== ABORTING >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "address-sanitizer" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "address-sanitizer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "address-sanitizer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
