M
m.labanowicz
Hello,
Is there any restriction releated to the
usage of stack in branches after longjmp ?
Following example makes mudflap violation.
--------------------------------------------------
$ gawk '{printf("/*%02u:*/ %s\n", NR, $0);}' main.c
/*01:*/ #include <setjmp.h>
/*02:*/ #include <string.h>
/*03:*/ #include <stdlib.h>
/*04:*/ int main(void) {
/*05:*/ volatile int var = 56;
/*06:*/ jmp_buf jmp;
/*07:*/ if (0 == setjmp(jmp)) {
/*08:*/ char bar [15];
/*09:*/ memset(bar, 0, sizeof(bar));
/*10:*/ var = 45;
/*11:*/ longjmp(jmp, 1);
/*12:*/ }
/*13:*/ else {
/*14:*/ char foo [11];
/*15:*/ memset(foo, var, sizeof(foo));
/*16:*/ }
/*17:*/ return EXIT_SUCCESS;
/*18:*/ }
$ gcc --version | head -n1
gcc (Ubuntu/Linaro 4.7.2-11precise2) 4.7.2
$ gcc -ansi -pedantic -W -Wall -Werror -fmudflap main.c -lmudflap -o a.out
$ export MUDFLAP_OPTIONS=
$ ./a.out
*******
mudflap violation 1 (register): time=1360844131.327763 ptr=0x7fff06e922d0 size=11
pc=0x7f6a2945f5f1
/usr/lib/x86_64-linux-gnu/libmudflap.so.0(__mf_register+0x41) [0x7f6a2945f5f1]
./a.out(main+0xc0) [0x400a9c]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f6a290b876d]
Nearby object 1: checked region begins 0B into and ends 10B into
mudflap object 0x7c1d20: name=`main.c:8:10 (main) bar'
bounds=[0x7fff06e922d0,0x7fff06e922de] size=15 area=stack check=0r/1w liveness=1
alloc time=1360844131.327758 pc=0x7f6a2945f5f1
number of nearby objects: 1
*******
mudflap violation 2 (unregister): time=1360844131.328163 ptr=0x7fff06e922d0 size=11
pc=0x7f6a2945f196
/usr/lib/x86_64-linux-gnu/libmudflap.so.0(__mf_unregister+0x36) [0x7f6a2945f196]
./a.out(main+0xef) [0x400acb]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f6a290b876d]
Nearby object 1: checked region begins 0B into and ends 10B into
mudflap object 0x7c1d20: name=`main.c:8:10 (main) bar'
number of nearby objects: 1
--------------------------------------------------
If size of 'foo' array is set to 3 then everything is correct.
Or maybe there is a BUG in MUDFLAP...
Regards
Is there any restriction releated to the
usage of stack in branches after longjmp ?
Following example makes mudflap violation.
--------------------------------------------------
$ gawk '{printf("/*%02u:*/ %s\n", NR, $0);}' main.c
/*01:*/ #include <setjmp.h>
/*02:*/ #include <string.h>
/*03:*/ #include <stdlib.h>
/*04:*/ int main(void) {
/*05:*/ volatile int var = 56;
/*06:*/ jmp_buf jmp;
/*07:*/ if (0 == setjmp(jmp)) {
/*08:*/ char bar [15];
/*09:*/ memset(bar, 0, sizeof(bar));
/*10:*/ var = 45;
/*11:*/ longjmp(jmp, 1);
/*12:*/ }
/*13:*/ else {
/*14:*/ char foo [11];
/*15:*/ memset(foo, var, sizeof(foo));
/*16:*/ }
/*17:*/ return EXIT_SUCCESS;
/*18:*/ }
$ gcc --version | head -n1
gcc (Ubuntu/Linaro 4.7.2-11precise2) 4.7.2
$ gcc -ansi -pedantic -W -Wall -Werror -fmudflap main.c -lmudflap -o a.out
$ export MUDFLAP_OPTIONS=
$ ./a.out
*******
mudflap violation 1 (register): time=1360844131.327763 ptr=0x7fff06e922d0 size=11
pc=0x7f6a2945f5f1
/usr/lib/x86_64-linux-gnu/libmudflap.so.0(__mf_register+0x41) [0x7f6a2945f5f1]
./a.out(main+0xc0) [0x400a9c]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f6a290b876d]
Nearby object 1: checked region begins 0B into and ends 10B into
mudflap object 0x7c1d20: name=`main.c:8:10 (main) bar'
bounds=[0x7fff06e922d0,0x7fff06e922de] size=15 area=stack check=0r/1w liveness=1
alloc time=1360844131.327758 pc=0x7f6a2945f5f1
number of nearby objects: 1
*******
mudflap violation 2 (unregister): time=1360844131.328163 ptr=0x7fff06e922d0 size=11
pc=0x7f6a2945f196
/usr/lib/x86_64-linux-gnu/libmudflap.so.0(__mf_unregister+0x36) [0x7f6a2945f196]
./a.out(main+0xef) [0x400acb]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f6a290b876d]
Nearby object 1: checked region begins 0B into and ends 10B into
mudflap object 0x7c1d20: name=`main.c:8:10 (main) bar'
number of nearby objects: 1
--------------------------------------------------
If size of 'foo' array is set to 3 then everything is correct.
Or maybe there is a BUG in MUDFLAP...
Regards