Public bug reported: This (possible) bug is not related to any package but to the libc itself maybe (or the kernel or whatever).
When executing this program on Kubuntu 9.10: #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> void segfault_handler(int num) { fprintf(stderr, "Segfault happened, exiting.\n"); exit(EXIT_FAILURE); } int main(void) { signal(SIGSEGV, &segfault_handler); for (int i = 0; i < 0x8048000; i += 4096) { printf("Mapping 0x%08X... ", i); fflush(stdout); printf("Mapped to: 0x%08X\n", (unsigned int)mmap((void *)i, 4096, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)); } return EXIT_SUCCESS; } (compiled it with "gcc mmap.c -Wall -Wextra -std=gnu99 -pedantic -Xlinker -Ttext -Xlinker 0x70000000 -m32 -o mmap") I get the message "Segmentation Fault.", the position varies. I tried it under openSuSE 11.2 and it works. I tried it under Linux from Scratch 6.5 (kernel 2.6.30.9) and it works, too. Note that the segfault is not handled: The message is not "Segfault happened, exiting" but simply "Segmentation Fault.". I think this behavior is incorrect, because the mmap manpage says: "On success, mmap() returns a pointer to the mapped area. On error, the value MAP_FAILED (that is, (void *) -1) is returned, and errno is set appropriately." So I expect something like this: "Mapping 0x0011C000... Mapped to: 0xFFFFFFFF" and not "Mapping 0x0011C000... Segmentation Fault." Though the manpage also tells me: "Use of a mapped region can result in these signals: SIGSEGV - Attempted write into a region mapped as read- only." But that's about the use of a mmap'ed region and not about the call itself. Furthermore this SIGSEGV should be at least catchable. OK, the manpage also says: "By default, any process can be killed at any moment when the system runs out of memory." But first of all a SIGKILL ("killing a process" sounds like "sending SIGKILL" to me) is in my opinion not equal to a SIGSEGV and second, the system doesn't run out of memory (because first of all mmap shouldn't really allocate the memory (as far as I know) and second the addresses are below the size of free memory available (the program never stops for example at 10 MB and "free" tells me there are still 50 MB of free memory). By the way: You may remove the "-Xlinker -Ttext -Xlinker 0x70000000" part, but I need it for another program hence I compiled this test program with those parameters (it also dies without these parameters). ** Affects: ubuntu Importance: Undecided Status: New -- Anonymous mmap crashes with SIGSEGV https://bugs.launchpad.net/bugs/495101 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs