#180 closed defect (fixed)
Userspace allocator cannot handle big sizes
Reported by: | Jiri Svoboda | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 0.4.2 |
Component: | helenos/lib/c | Version: | mainline |
Keywords: | malloc | Cc: | |
Blocker for: | Depends on: | ||
See also: |
Description (last modified by )
As of revision mainline,236, if I create a disk image on tmpfs, create a FAT filesystem on it, mount it and create a file, it crashes. To reproduce, follow these steps:
# mkfile --size 2m /scratch/img # file_bd /scratch/img bd/fdev0 # mkfat bd/fdev0 # mkdir /fat # mount fat /fat bd/fdev0 # mkfile --size 32k /fat/test
The command appears to be hung, in klog we can see that Thread 0x80083000 crashed at 0x1af76 (_heap+0x7f76). FP = 0x80028438.
The stack trace appears to be bogus:
0x80028438: 0x1af76 (_heap+0x7f76) Warning: udebug_mem_read() failed.
Attachments (3)
Change History (10)
follow-up: 2 comment:1 by , 15 years ago
comment:2 by , 15 years ago
The second example is still reproducible as of head,250.
From the "coredump" data and the kill message, it looks like the task it touching unmapped memory, 8 bytes behind the end of an address space area. Are we growing the heap insufficiently?
by , 15 years ago
Attachment: | Screenshot.png added |
---|
Screenshot showing the stack trace, address space areas and the kill message.
comment:3 by , 15 years ago
Component: | unspecified → uspace/libc |
---|---|
Keywords: | malloc added |
I think this is an allocator bug.
From the attached screenshot and core file, we have:
(gdb) printf "%p\n", &_heap
0x14000
(gdb) inspect heap_pages
$5 = 101
(gdb) printf "%x\n", 101*4096
65000
(gdb) printf "%p\n", heap_end
0x79000
So both according to the kernel address space areas and the heap variables, the heap ends at 0x79000, but the allocator touched 0x79008 which killed the task. The offending instruction is:
0x0000bd6b <malloc_internal+459>: movl $0xbeef0101,0x8(%edx)
where 0xbeef0101 is a magic pattern used by the allocator to mark the heap block footer.
by , 15 years ago
TMPFS binary which produced the already attached core file.
comment:4 by , 15 years ago
I found a simple reproducible test case, based on the file system behavior above:
=== modified file 'uspace/app/tester/mm/malloc1.c' --- uspace/app/tester/mm/malloc1.c 2009-08-04 11:19:19 +0000 +++ uspace/app/tester/mm/malloc1.c 2010-02-10 21:01:41 +0000 @@ -629,6 +629,8 @@ char *test_malloc1(void) { + realloc(malloc(184320), 4294965248ULL); + init_mem(); unsigned int phaseno;
comment:5 by , 15 years ago
Summary: | Tmpfs crashes when using FAT image on tmpfs → Userspace allocator cannot handle big sizes |
---|
comment:7 by , 14 years ago
Description: | modified (diff) |
---|
Repeating the same with 180k image size gave me a different stack trace, which I painstakingly copied here: