Sat 07 Jan 2006 08:45:13 PM UTC, original submission:
In trying to get gnupg to work on the Hurd, I boiled the problem down to the following code snippet:
---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
int main()
{
char *pool;
int err;
long int pgsize = getpagesize();
pool = mmap( 0, 32768 + pgsize, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
//pool = malloc (32768 + pgsize);
if( !pool )
return 2;
pool += (pgsize - ((long int)pool % pgsize));
err = mlock( pool, 32768);
printf ("err is %d, errno = %d\n", err, errno);
if (err)
printf ("EKERN_FAILURE = %d\n", EKERN_FAILURE);
return err;
}
---
One strange thing to note is that mlock'ing malloc'ed memory works.
I think the EKERN_FAILURE comes from gnumach/vm/vm_map.c:vm_map_pageable_common, but I'm not certain as I haven't run it through a debugger.
I hope that somebody else has the skill required to investigate this bug further.
Regards,
Ben
|