Wednesday, September 13, 2006

Warning: User mode Linux mmap() is broken

On my linode, this program hangs instead of dying with a segfault:
#include <sys/mman.h>
#include <stdlib.h>

int main()
{
int pagesize = getpagesize();

int *array = mmap((void*)0,pagesize,
PROT_NONE,MAP_ANON | MAP_PRIVATE,-1,0);

if(!array)
abort();

printf("%x\n",*array);
}

This is a serious issue. It causes Factor to hang on stack underflow if the underflow was caused by a memory read (eg, dup with an empty stack).

Of course I don't use stack underflow errors for control flow, but it makes debugging on the server rather annoying. Perhaps its time to find another hosting provider.

3 comments:

Anonymous said...

Hi Slava, have you heard about textdrive.com?

They were one of the first Ruby on Rails hosting providers and quoting from their own home page: "TextDrive proudly supports open source software [...] through the provision of servers, infrastructure, development tools and funding".

They run FreeBSD on their servers and after reading their acceptable use policy I think it could be posible to compile and run the Factor HTTP server inside them after requesting their permission.

Their plans have features like Subversion repositories, darcs or Edgewall Trac and may be that you could get from them some support for your project.

Anonymous said...

Upgrade you kernel? It works here:

mmap2(NULL, 4096, PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f65000

--- SIGSEGV (Segmentation fault) @ 0 (0) ---

2.6.17.3

Slava Pestov said...

Hi falva, thanks for the suggestion. I prefer hosting providers where I can have root access on a virtual (or real) server, since I also run my own SMTP and POP3 host.