[ccan] [PATCH] altstack: New module
Rusty Russell
rusty at rustcorp.com.au
Wed Jan 27 15:51:14 AEDT 2016
Dan Good <dan at dancancode.com> writes:
> altstack - run a function with a dedicated stack, and then release the memory
>
> Signed-off-by: Dan Good <dan at dancancode.com>
Hmm, fails here:
Linux rusty-Lemur 4.2.0-23-generic #28-Ubuntu SMP Sun Dec 27 17:47:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
rusty at rusty-Lemur:~/devel/cvs/ccan/ccan/altstack (master)$ ccanlint -v
Module's run and api tests pass (tests_pass): FAIL
/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:1..16
ok 1 - (fail = getrlimit_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(getrlimit_))) && call1 == (0) && call2 == (0)
ok 2 - (fail = setrlimit_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(setrlimit_))) && call1 == (getrlimit_) && call2 == (0)
ok 3 - (fail = mmap_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(mmap_))) && call1 == (getrlimit_|setrlimit_) && call2 == (setrlimit_)
ok 4 - (fail = sigaltstack_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(sigaltstack_))) && call1 == (getrlimit_|setrlimit_|mmap_) && call2 == (setrlimit_|munmap_)
ok 5 - (fail = sigaction_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(sigaction_))) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_) && call2 == (setrlimit_|munmap_|sigaltstack_)
ok 6 - (fail = munmap_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == 1) && errno == ((900+(munmap_))) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|sigaltstack_|sigaction_)
not ok 7 - (altstack(1*((1024UL)*(1024UL)), wrap, (void *) 1000000, 0) == -1) && errno == (75) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|munmap_|sigaltstack_|sigaction_)
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 94)
not ok 8 - (altstack(1*((1024UL)*(1024UL)), wrap, (void *) 1000000, 0) == -1) && errno == (75) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|munmap_|sigaltstack_|sigaction_)
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 99)
not ok 9 - (fail = munmap_) && (altstack(1*((1024UL)*(1024UL)), wrap, (void *) 1000000, 0) == -1) && errno == (75) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|sigaltstack_|sigaction_)
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 104)
not ok 10 - used > 1*MiB-1*KiB && used < 1*MiB
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 108)
not ok 11 - strcmp(altstack_geterr(), estr) == 0
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 116)
not ok 12 - strcmp(buf, estr "\n") == 0
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 124)
not ok 13 - (altstack(8*((1024UL)*(1024UL)), wrap, (void *) 1000000, 0) == -1) && errno == (75) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|munmap_|sigaltstack_|sigaction_)
# Failed test (/home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:main() at line 129)
ok 14 - used > 8*MiB-8*KiB && used < 8*MiB
ok 15 - (altstack(8*((1024UL)*(1024UL)), wrap, (void *) 100000, 0) == 0) && errno == (0) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_|munmap_) && call2 == (setrlimit_|munmap_|sigaltstack_|sigaction_)
ok 16 - used == 32
# Looks like you failed 7 tests of 16.
Should I run the first failing test under the debugger? y
GNU gdb (Ubuntu 7.10-1ubuntu2) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/ccanlint-12859.1804289383/run...done.
Breakpoint 1 at 0x403148: file /home/rusty/devel/cvs/ccan/ccan/tap/tap.c, line 139.
Starting program: /tmp/ccanlint-12859.1804289383/run
1..16
ok 1 - (fail = getrlimit_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(getrlimit_))) && call1 == (0) && call2 == (0)
ok 2 - (fail = setrlimit_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(setrlimit_))) && call1 == (getrlimit_) && call2 == (0)
ok 3 - (fail = mmap_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(mmap_))) && call1 == (getrlimit_|setrlimit_) && call2 == (setrlimit_)
ok 4 - (fail = sigaltstack_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(sigaltstack_))) && call1 == (getrlimit_|setrlimit_|mmap_) && call2 == (setrlimit_|munmap_)
ok 5 - (fail = sigaction_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == -1) && errno == ((900+(sigaction_))) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_) && call2 == (setrlimit_|munmap_|sigaltstack_)
ok 6 - (fail = munmap_) && (altstack(8*((1024UL)*(1024UL)), wrap, 0, 0) == 1) && errno == ((900+(munmap_))) && call1 == (getrlimit_|setrlimit_|mmap_|sigaltstack_|sigaction_) && call2 == (setrlimit_|sigaltstack_|sigaction_)
Program received signal SIGSEGV, Segmentation fault.
0x00000000004020b8 in dn (i=967233)
at /home/rusty/devel/cvs/ccan/ccan/altstack/test/run.c:51
51 if (i) dn(--i);
(gdb) p dn
$1 = {void (unsigned long)} 0x402081 <dn>
(gdb) p i
$2 = 967233
More information about the ccan
mailing list