[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fixing gnumachs vm_map
From: |
Justus Winter |
Subject: |
Fixing gnumachs vm_map |
Date: |
Fri, 5 Sep 2014 14:53:52 +0200 |
Hi :)
there is a bug affecting vm_map. Contrary to the documentation,
address is not ignored if anywhere is given, leading to spurious
KERN_NO_SPACE errors. Test case below.
I'm not sure the fix is correct, maybe we have to do
if (... || start + size > map->max_offset)...
or something. Please have a look.
I have one Hurd patch that consistently triggers this while copying
files, and one that sometimes triggers this while compiling random
stuff. I cannot believe this isn't causing more trouble all over the
place...
Justus
/* The documentation of vm_map says:
kern_return_t vm_map (vm_task_t target_task,
vm_address_t *address,
..., boolean_t anywhere, ...)
[...] target_task is the task to be affected. The starting address
is address. If the anywhere option is used, this address is
ignored. [...]
But:
% ./gnumach_vm_map_bug
*addr is (nil)
*addr is 0xffffffff
gnumach_vm_map_bug: gnumach_vm_map_bug.c:23: map: Unexpected error:
(os/kern) no space available.
*/
#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <mach.h>
#include <stdio.h>
void
map (vm_address_t *addr)
{
error_t err;
printf ("*addr is %p\n", *addr);
err = vm_map (mach_task_self (),
addr,
1024,
0, /* mask */
1, /* anywhere */
MACH_PORT_NULL,
0, /* offset */
0, /* copy */
VM_PROT_READ,
VM_PROT_READ,
VM_INHERIT_NONE);
assert_perror (err);
}
int
main (int argv, char **argc)
{
vm_address_t addr;
addr = 0;
map (&addr);
addr = ~0;
map (&addr);
return 0;
}
- Fixing gnumachs vm_map,
Justus Winter <=