Steven Chamberlain wrote:
> Unfortunately gdb on kfreebsd doesn't handle threads very well, [...]
I changed the test runner to send a SIGABRT instead of SIGKILL; then
gdb returns a trace of the thread we are interested in:
| #0 memset () at ../sysdeps/x86_64/memset.S:93
| No locals.
| #1 0x000000080089bbf0 in alloc_perturb (n=<optimized out>, p=<optimized out>) at malloc.c:1864
| No locals.
| #2 _int_malloc (av=av@entry=0x800b84b40 <main_arena>, bytes=bytes@entry=51539607552) at malloc.c:3796
| iters = <optimized out>
| nb = <optimized out>
| idx = <optimized out>
| bin = <optimized out>
| victim = <optimized out>
| size = <optimized out>
| victim_index = <optimized out>
| remainder = <optimized out>
| remainder_size = <optimized out>
| block = <optimized out>
| bit = <optimized out>
| map = <optimized out>
| fwd = <optimized out>
| bck = <optimized out>
| errstr = 0x0
| __func__ = "_int_malloc"
| #3 0x000000080089e581 in __libc_calloc (n=<optimized out>, elem_size=<optimized out>) at malloc.c:3213
| av = 0x800b84b40 <main_arena>
| oldtop = 0x606250
| p = <optimized out>
| bytes = 51539607552
| sz = 51539607552
| csz = <optimized out>
| oldtopsize = 130480
| mem = <optimized out>
| clearsize = <optimized out>
| nclears = <optimized out>
| d = <optimized out>
| hook = <optimized out>
| __func__ = "__libc_calloc"
| #4 0x000000080090006e in __GI_hcreate_r (nel=<optimized out>, htab=0x800b873d0 <htab>) at hsearch_r.c:99
| No locals.
| #5 0x0000000000401187 in test_size (size=2147483645) at ../../misc/bug18240.c:29
The problem is the large memory allocation by hcreate(INT_MAX-2), when
M_PERTURB option is also set (by test-skeleton.c). It takes some time
allocating and zeroing that memory, until the 2-second timeout is
reached, or memory exhausted.
A more condensed testcase is:
#include <search.h>
#include <malloc.h>
int main() {
mallopt (M_PERTURB, 42);
int res = hcreate(2147483645);
return 0;
}
$ LD_LIBRARY_PATH=. /usr/bin/time ./testcase
Command terminated by signal 9
0.70user 2.75system 0:04.11elapsed 84%CPU (17avgtext+589avgdata 5981064maxresident)k
0inputs+0outputs (0major+1492254minor)pagefaults 0swaps
Regards,
--
Steven Chamberlain
steven@pyro.eu.org
Attachment:
signature.asc
Description: Digital signature