[Mono-dev] Syscall.mmap problem

Jonathan Pryor jonpryor at vt.edu
Sun Oct 28 19:31:04 EDT 2007

On Sun, 2007-10-28 at 18:20 -0300, Mauricio Henriquez wrote:
> in my mmap test the "/pr.txt" file exist so the "error handling" is only 
> for test porpuses and to watch if any of the mmap paremeter is wronge 
> (this is a test of the mmap not the final working with the mmap on the 
> video4linus.net), in my case the file descriptor is correct (not < 0), 
> in any case thak you Jonathan for your test code, if I run your code I 
> get the same Console.WriteLine(start.ToString()) = -1 and this message 
> with the error handling:
> mmap: Value too large for defined data type //I don't know what means

The only ideas I have left are:

1. What are the permissions of `/pr.txt'?

2. What platform is this on?  x86?  PPC?  Which operating system?

3. What version of Mono?

4. Are you compiling Mono yourself?

The mere fact you got "mmap: Value too large for defined data type" as
output implies that you're running svn (as perror() used to always write
"Success"), and still suggests the problem is in

If this is the case, then please run within gdb (see input after (gdb)

$ gdb `which mono`
(gdb) b Mono_Posix_Syscall_mmap
Function "Mono_Posix_Syscall_mmap" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (Mono_Posix_Syscall_mmap) pending.
(gdb) r mmap.exe /pr.txt
Starting program: /home/jon/Development/mono-HEAD/install/bin/mono
mmap.exe /pr.txt
warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at
[Thread debugging using libthread_db enabled]
[New Thread 4158057136 (LWP 20303)]
[New Thread 4149185440 (LWP 20306)]
[New Thread 4149037984 (LWP 20307)]
Breakpoint 2 at 0xf73a0da0: file sys-mman.c, line 27.
Pending breakpoint "Mono_Posix_Syscall_mmap" resolved
fstat ok
length = 6
[Switching to Thread 4158057136 (LWP 20303)]

Breakpoint 2, Mono_Posix_Syscall_mmap (start=0x0, length=6, prot=1,
flags=2, fd=6, offset=0) at sys-mman.c:27
27              mph_return_val_if_size_t_overflow (length, MAP_FAILED);
(gdb) n
24      {
(gdb) n
27              mph_return_val_if_size_t_overflow (length, MAP_FAILED);
(gdb) n
30              if (Mono_Posix_FromMmapProts (prot, &_prot) == -1)
(gdb) n
32              if (Mono_Posix_FromMmapFlags (flags, &_flags) == -1)
(gdb) n
35              return mmap (start, (size_t) length, _prot, _flags, fd,
(off_t) offset);
(gdb) n
36      }
(gdb) c

The point is to see where Mono_Posix_Syscall_mmap() returns -- does it
actually call mmap()?  Or does it exit early because of an overflow or
translation error?  If it does exit early, where does it ext?

 - Jon

More information about the Mono-devel-list mailing list