[Mono-dev] mmap problem

Jonathan Pryor jonpryor at vt.edu
Mon Oct 29 21:57:25 EDT 2007

On Mon, 2007-10-29 at 20:28 -0300, buhochileno at gmail.com wrote:
> About the gdb test, this is my result:
> //I don't pass the /pr.txt file as parameter, internally I open allways 
> this file
> (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 pr1mmap.exe
> Starting program: /usr/bin/mono pr1mmap.exe
> Reading symbols from shared object read from target memory...done.
> Loaded system supplied DSO at 0x4ff000
> [Thread debugging using libthread_db enabled]
> [New Thread 2311872 (LWP 26956)]
> [New Thread 5647264 (LWP 26973)]
> [New Thread 5200800 (LWP 26974)]
> Breakpoint 2 at 0xd37cc3: file sys-mman.c, line 27.
> Pending breakpoint "Mono_Posix_Syscall_mmap" resolved
> fstat ok
> length = 6
> [Switching to Thread 2311872 (LWP 26956)]
> Breakpoint 2, Mono_Posix_Syscall_mmap (start=0x6, length=6, prot=6, flags=6,
>     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
> 28              mph_return_val_if_off_t_overflow (offset, MAP_FAILED);
> (gdb) n
> 36      }

This is the important difference -- you never hit
Mono_Posix_FromMmapProts(), but instead return immediately after the
offset check.  Which implies that gcc thinks that 0 won't fit within an
off_t, which is...weird.

> The little diference that I can see from your result is the prot=6, 
> flags=6, in your case is 1 and 2 values.

This just illustrates different flags we're passing to Syscall.mmap().
I passed MmapProts.PROT_READ (1), while you presumably passed
MmapProts.PROT_EXEC|MmapProts.PROT_WRITE (6), and I passed
MmapFlags.MAP_PRIVATE (2) while you presumably passed...I have no idea
what you passed for `flags', as no flag has the value 0x04. :-/

Going back to the weirdness of mph_return_val_if_off_t_overflow()
failing 0...  Compile the attached program as:

        gcc -DHAVE_LARGE_FILE_SUPPORT=1 -DSIZEOF_SIZE_T=4 off_t-ovf.c \
        	-o off_t-ovf `pkg-config --cflags --libs glib-2.0`

Then execute ./off_t-ovf and send me the output.

You might also try building your own copy of Mono; see:


This may come in handy because if off_t-ovf works successfully (which I
fully expect it to), I'll need to resort to reading the <config.h> file
generated by Mono's configure script...which won't be included with
Fedora's install. :-/

 - Jon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: off_t-ovf.c
Type: text/x-csrc
Size: 5978 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071029/4c7e5bcf/attachment.bin 

More information about the Mono-devel-list mailing list