error: can't mmap pool
Werner Koch
wk@gnupg.org
Thu May 16 09:13:02 2002
On Wed, 15 May 2002 14:59:03 -0500, Callaghan, Brian said:
> I started trying with 1.0.7 and will go back and retry 1.0.6 am also seeing
> if I can get it to run on AIX.
No need to go back, I just checked that the code did not change from
1.0.6.
I'd appreciate to see an strace or replace the function
util/secmem.c:init_pool with that instrumented code:
static void
init_pool( size_t n)
{
size_t pgsize;
poolsize = n;
if( disable_secmem )
log_bug("secure memory is disabled");
#ifdef HAVE_GETPAGESIZE
pgsize = getpagesize();
#else
pgsize = 4096;
#endif
#if HAVE_MMAP
poolsize = (poolsize + pgsize -1 ) & ~(pgsize-1);
#ifdef MAP_ANONYMOUS
log_debug ("secmem: using anonymous mapping (%lu,%lu,%d,%d)\n",
(unsigned long)pgsize,
(unsigned long)poolsize, MAP_PRIVATE, MAP_ANONYMOUS);
pool = mmap( 0, poolsize, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#else /* map /dev/zero instead */
{ int fd;
fd = open("/dev/zero", O_RDWR);
if( fd == -1 ) {
log_error("can't open /dev/zero: %s\n", strerror(errno) );
pool = (void*)-1;
}
else {
log_debug ("secmem: using /dev/zero mapping (%lu,%lu,%d,%d)\n",
(unsigned long)pgsize,
(unsigned long)poolsize, MAP_PRIVATE, fd);
pool = mmap( 0, poolsize, PROT_READ|PROT_WRITE,
MAP_PRIVATE, fd, 0);
}
}
#endif
if( pool == (void*)-1 )
log_info("can't mmap pool of %u bytes: %s - using malloc\n",
(unsigned)poolsize, strerror(errno));
else {
pool_is_mmapped = 1;
pool_okay = 1;
}
#endif
if( !pool_okay ) {
pool = malloc( poolsize );
if( !pool )
log_fatal("can't allocate memory pool of %u bytes\n",
(unsigned)poolsize);
else
pool_okay = 1;
}
lock_pool( pool, poolsize );
poollen = 0;
}
Werner