emulators/linux-wine: Help in porting to FreeBSD

Scot Hetzel swhetzel at gmail.com
Fri Mar 9 20:51:31 UTC 2007


On 3/9/07, Tijl Coosemans <tijl at ulyssis.org> wrote:
> This is a problem with the FreeBSD mmap.
>
> * The wine executable is loaded at 0x7bf00000.
> * It reserves 0x00000000-0x60000000 and 0x80000000-(stack).
> * Then a couple dlls are dlopen'ed (ntdll,kernel32,...).
> * This fails because the freebsd mmap, when called without MAP_FIXED
>   and NULL for the addr argument, looks for free space after the
>   executable + maximum possible data segment (to preserve space for
>   brk(2) style allocations). The default maximum data segment size is
>   512MiB, so mmap is looking for free space well beyond 0x80000000
>   which isn't there.
>
> In current you could work around this by setting kern.maxdsiz="8M" or
> so in /boot/loader.conf, but that probably causes problems for programs
> that use brk(2). A better solutions would be to create a wrapper
> program that reduces the data segment size with setrlimit(2) and then
> runs wine with execv(3).
>

Thanks for the hint, I didn't find kern.maxdsiz in the sysctl tree,
but I did find 2 other maxdsiz settings.

hp010# sysctl -a | grep maxdsiz
compat.ia32.maxdsiz: 536870912
compat.linux32.maxdsiz: 536870912

hp010# /compat/linux/usr/bin/wineprefixcreate
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map
segment from shared object: Cannot allocate memory

hp010# /compat/linux/usr/bin/wine --version
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map
segment from shared object: Cannot allocate memory

Changing only compat.linux32.maxdsiz to 8M,  allowed wineprefixcreate
to run without giving the above error, but instead resulted in a core
dump.

hp010# sysctl compat.linux32.maxdsiz=8388608
compat.linux32.maxdsiz: 536870912 -> 8388608

hp010# /compat/linux/usr/bin/wineprefixcreate
modify_ldt: Success
Segmentation fault (core dumped)

hp010$ /compat/linux/usr/bin/wine --version
Wine 0.9.24

$ /compat/linux/usr/bin/winemine
modify_ldt: Success
Segmentation fault (core dumped)

Mar  9 14:38:36 hp010 kernel: pid 98889 (wine-preloader), uid 1001:
exited on signal 11 (core dumped)

Both wineprefixcreate and winemine are core dumping when wine-preloader is run.

I tried other settings for maxdsiz ranging from 10-100M, and I found
that the highest value that can be set is 47M.  Though I did have a
problem when setting it to 45M.

hp010# sysctl compat.linux32.maxdsiz=46137344 (44M)
compat.linux32.maxdsiz: 45088768 -> 46137344
hp010# /compat/linux/usr/bin/wine --version
Wine 0.9.24

hp010# sysctl compat.linux32.maxdsiz=47185920 (45M)
compat.linux32.maxdsiz: 41943040 -> 47185920
hp010# /compat/linux/usr/bin/wine --version
wine: failed to initialize: libm.so.6: failed to map segment from
shared object: Cannot allocate memory

hp010# sysctl compat.linux32.maxdsiz=48234496 (46M)
compat.linux32.maxdsiz: 46137344 -> 48234496
hp010# /compat/linux/usr/bin/wine --version
Wine 0.9.24

hp010# sysctl compat.linux32.maxdsiz=49283072 (47M)
compat.linux32.maxdsiz: 48234496 -> 49283072
hp010# /compat/linux/usr/bin/wine --version
Wine 0.9.24

hp010# sysctl compat.linux32.maxdsiz=50331648 (48M)
compat.linux32.maxdsiz: 49283072 -> 50331648
hp010# /compat/linux/usr/bin/wine --version
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map
segment from shared object: Cannot allocate memory

So it looks like we may be closer to running linux-wine on
FreeBSD/amd64 than what we had originally thought.

$ /compat/linux/usr/bin/wineserver
$ ps -ax | grep wineserver
98895  ??  Ss     0:00.00 /compat/linux/usr/bin/wineserver

Mar  9 14:39:14 hp010 kernel: linux: pid 98895 (wineserver): syscall
epoll_create not implemented

I can run wineserver manually, but /var/log/messages is showing that
it needs epoll_create function, but it doesn't stop wineserver from
running.

Scot

$ uname -a
FreeBSD hp010.hetzel.org 7.0-CURRENT FreeBSD 7.0-CURRENT #19: Sat Mar
3 04:48:54 CST 2007
swhetzel at hp010.hetzel.org:/usr/obj/usr/src/7x/sys/GENERIC.debug  amd64

-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.


More information about the freebsd-emulation mailing list