qemu on ARM hosts asserts due to code buffer/libc heap conflict

Bug #883133 reported by Peter Maydell on 2011-10-28
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro QEMU
Fix Released
Dr. David Alan Gilbert

Bug Description

On ARM hosts qemu (about half the time) asserts on startup:

qemu-system-i386: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) -
__builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

This turns out to be because code_gen_alloc() is using mmap(MAP_FIXED) to map the code buffer at address 0x01000000UL, which is in the area glibc happens to be using for its heap. This tends to make the next malloc() abort, although occasionally the stars align and we pass that and fail weirdly later on.

I suspect we need to drop the MAP_FIXED requirement and fix the TCG code to cope with emitting code for longer-range
branches for calls to host fns etc (calls/branches within the generated code should be ok to keep using the short-range
branch insn I think). There is already no guarantee that the generated code and the host C code are within short
branch range of each other...

Peter Maydell (pmaydell) on 2011-11-10
summary: - qemu on ARM hosts asserts on startup
+ qemu on ARM hosts asserts due to code buffer/libc heap conflict
Changed in qemu-linaro:
assignee: nobody → Dr. David Alan Gilbert (davidgil-uk)
status: New → In Progress

Fix pushed into QEMU upstream today.

Peter Maydell (pmaydell) on 2011-12-15
Changed in qemu:
status: New → Fix Committed
Peter Maydell (pmaydell) on 2012-01-04
Changed in qemu-linaro:
status: In Progress → Fix Committed
Michael Hope (michaelh1) on 2012-01-05
Changed in qemu-linaro:
importance: Undecided → Medium
Peter Maydell (pmaydell) wrote :

NB: this would typically only happen when the ARM host had address space randomization including brk randomization enabled (ie /proc/sys/kernel/randomize_va_space is 2).

Peter Maydell (pmaydell) on 2012-01-12
Changed in qemu-linaro:
status: Fix Committed → Triaged
status: Triaged → Fix Released
Peter Maydell (pmaydell) on 2012-07-10
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related blueprints