Bug#672415: virtual memory allocation problem on kfreebsd-i386 (solved in wine 1.4)

May 10th, 2012 - 05:40 pm ET by Robert Millan | Report spam
Package: wine-bin
Version: 1.2.2-0.1
Severity: grave
User: debian-bsd@lists.debian.org
Usertags: kfreebsd

wine 1.2.2 introduces a severe regression on kfreebsd-i386, all programs fail
due to virtual memory allocation problems:

$ notepad
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map segment from shared object: Cannot allocate memory

this has been fixed in wine upstream, and the fix is included in wine 1.4.

As I understand that the plan for Wheezy is to release with wine 1.4, I'm
not providing a fix to solve this in wine 1.2. If plans are changed to
release with 1.2, then please let me know and I'll cherry-pick the relevant
commits from upstream (and test them).

Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: kfreebsd-i386 (i386)

Kernel: kFreeBSD 8.1-1-amd64
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages wine-bin depends on:
ii libc0.1 2.13-32
ii libwine-bin 1.2.2-0.1
ii x11-utils 7.7~1

wine-bin recommends no packages.

Versions of packages wine-bin suggests:
ii libwine-gl 1.2.2-0.1
ii libwine-print 1.2.2-0.1

Versions of packages libwine depends on:
ii libc0.1 2.13-32
ii libfreetype6 2.4.9-1
ii libhal1 0.5.14-8
ii libice6 2:1.0.8-2
ii libjpeg8 8d-1
ii libmpg123-0 1.14.0-1
ii libpng12-0 1.2.49-1
ii libsm6 2:1.2.1-2
ii libssl1.0.0 1.0.1b-1
ii libx11-6 2:1.4.99.901-2
ii libxcursor1 1:1.1.13-1
ii libxext6 2:1.3.1-2
ii libxi6 2:1.6.0-1
ii libxinerama1 2:1.1.2-1
ii libxml2 2.7.8.dfsg-9
ii libxrandr2 2:1.3.2-2
ii libxrender1 1:0.9.7-1
ii zlib1g 1:1.2.7.dfsg-1

Versions of packages libwine recommends:
ii libgsm1 1.0.13-4

Versions of packages libwine suggests:
pn wine-doc <none>




To UNSUBSCRIBE, email to debian-bugs-rc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 6 repliesReplies Make a reply

Similar topics

Replies

#1 Hilko Bengen
May 13th, 2012 - 05:10 pm ET | Report spam
* Robert Millan:

Package: wine-bin
Version: 1.2.2-0.1
Severity: grave
User:
Usertags: kfreebsd

wine 1.2.2 introduces a severe regression on kfreebsd-i386, all programs fail
due to virtual memory allocation problems:

$ notepad
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map segment from shared object: Cannot allocate memory

this has been fixed in wine upstream, and the fix is included in wine 1.4.



Am I guessing correctly that this is the relevant upstream commit?

,-
| commit 5f694ddf4c211c1c167a15541c2654175ce42a62
| Author: Francois Gouget
| Date: Fri Nov 26 16:18:32 2010 +0100
|
| configure: Load wine lower in memory on FreeBSD to leave more space for mmap
|
| If not provided an explicit address, FreeBSD won't mmap any memory
| below the executable. In particularly this means any memory below that
| is unavailable to dlopen() and malloc(). This fixes the bug where
| large WineLib binaries, in particular winetest, failed to load because
| there was not enough space left for them and the native libraries they
| linked to. The drawback is that we can no longer load very large
| Windows executables (between about 1.5 and 2 GB).
`-

Cheers,
-Hilko



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#2 Robert Millan
May 16th, 2012 - 02:40 am ET | Report spam
2012/5/13 Hilko Bengen :
Am I guessing correctly that this is the relevant upstream commit?



It's probably needed. And at least
535a55ec9eff83ac1cdf58a6514f4a76cab46a57 is needed too.

But please don't guess, one would have to test it. If you intend to
aim for 1.2 I'll be glad to help, just let me know.

Robert Millan



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#3 Hilko Bengen
May 18th, 2012 - 11:20 am ET | Report spam
tag 672415 +patch
thank you

But please don't guess, one would have to test it. If you intend to
aim for 1.2 I'll be glad to help, just let me know.



It turns out this is Wine Bug#20314 and that four patches by Austin
English titled "{libwine,server,ntdll,loader}: Add missing checks for
FreeBSD_kernel." are needed. (They don't apply as-is to 1.2.3, but
whatever.)

I have only been able to briefly test the attached patch with a
console-only program (cmd.exe) which had failed previously with the
memor allocation problem.

Could you please verify that the patch fixes the problem?

Cheers,
-Hilko


diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 3cbcbe7..bb5c1e5 100644
a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -1132,7 +1132,7 @@ void fill_cpu_info(void)
fclose(f);
}
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
{
int ret, num;
size_t len;
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index c08693e..9603f56 100644
a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -210,6 +210,8 @@ typedef struct trapframe SIGCONTEXT;

#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)

+#include <machine/trap.h>
+
typedef struct sigcontext SIGCONTEXT;

#define EAX_sig(context) ((context)->sc_eax)
@@ -428,7 +430,7 @@ extern void DECLSPEC_NORETURN __wine_restore_regs( const CONTEXT *context );
enum i386_trap_code
{
TRAP_x86_UNKNOWN = -1, /* Unknown fault (TRAP_sig not defined) */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
TRAP_x86_DIVIDE = T_DIVIDE, /* Division by zero exception */
TRAP_x86_TRCTRAP = T_TRCTRAP, /* Single-step exception */
TRAP_x86_NMI = T_NMI, /* NMI interrupt */
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 48f8b6d..4807103 100644
a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -136,7 +136,7 @@ extern int arch_prctl(int func, void *ptr);

#define FPU_sig(context) ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.fpregs))

-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
#include <sys/ucontext.h>

#define RAX_sig(context) ((context)->uc_mcontext.mc_rax)
@@ -2335,7 +2335,7 @@ void signal_init_thread( TEB *teb )

#if defined __linux__
arch_prctl( ARCH_SET_GS, teb );
-#elif defined __FreeBSD__
+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
amd64_set_gsbase( teb );
#else
# error Please define setting %gs for your architecture
diff --git a/libs/wine/ldt.c b/libs/wine/ldt.c
index d56790f..94f15c6 100644
a/libs/wine/ldt.c
+++ b/libs/wine/ldt.c
@@ -434,7 +434,7 @@ void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry )
ldt_info.entry_number = sel >> 3;
fill_modify_ldt_struct( &ldt_info, entry );
if ((ret = set_thread_area( &ldt_info ) < 0)) perror( "set_thread_area" );
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
i386_set_fsbase( wine_ldt_get_base( entry ));
#endif
}
diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c
index b400189..db80e35 100644
a/libs/wine/mmap.c
+++ b/libs/wine/mmap.c
@@ -375,7 +375,7 @@ void mmap_init(void)
char *base = stack_ptr - ((unsigned int)stack_ptr & granularity_mask) - (granularity_mask + 1);
if (base > user_space_limit) reserve_area( user_space_limit, base );
base = stack_ptr - ((unsigned int)stack_ptr & granularity_mask) + (granularity_mask + 1);
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
/* Heuristic: assume the stack is near the end of the address */
/* space, this avoids a lot of futile allocation attempts */
end = (char *)(((unsigned long)base + 0x0fffffff) & 0xf0000000);
diff --git a/loader/main.c b/loader/main.c
index 628a0fa..5bb4e80 100644
a/loader/main.c
+++ b/loader/main.c
@@ -164,7 +164,7 @@ static int pre_exec(void)
return 1;
}

-#elif defined(__FreeBSD__) && defined(__i386__)
+#elif (defined(__FreeBSD__) || defined (__FreeBSD_kernel__)) && defined(__i386__)

static int pre_exec(void)
{
diff --git a/server/ptrace.c b/server/ptrace.c
index 111368b..e6c43b3 100644
a/server/ptrace.c
+++ b/server/ptrace.c
@@ -235,7 +235,7 @@ static inline int tkill( int tgid, int pid, int sig )
if (ret >= 0) return ret;
errno = -ret;
return -1;
-#elif defined(__FreeBSD__) && defined(HAVE_THR_KILL2)
+#elif (defined(__FreeBSD__) || defined (__FreeBSD_kernel__)) && defined(HAVE_THR_KILL2)
return thr_kill2( tgid, pid, sig );
#else
errno = ENOSYS;




To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#4 Robert Millan
May 19th, 2012 - 09:00 am ET | Report spam
2012/5/18 Hilko Bengen :
But please don't guess, one would have to test it.  If you intend to
aim for 1.2 I'll be glad to help, just let me know.



It turns out this is Wine Bug#20314 and that four patches by Austin
English titled "{libwine,server,ntdll,loader}: Add missing checks for
FreeBSD_kernel." are needed. (They don't apply as-is to 1.2.3, but
whatever.)

I have only been able to briefly test the attached patch with a
console-only program (cmd.exe) which had failed previously with the
memor allocation problem.

Could you please verify that the patch fixes the problem?



Uhm that won't be enough, you need at least
535a55ec9eff83ac1cdf58a6514f4a76cab46a57 (I know because I traced this
problem myself back then).

I'll test a combination of what you sent me +
535a55ec9eff83ac1cdf58a6514f4a76cab46a57

Robert Millan



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#5 Robert Millan
May 19th, 2012 - 09:40 am ET | Report spam
2012/5/19 Robert Millan :
Uhm that won't be enough, you need at least
535a55ec9eff83ac1cdf58a6514f4a76cab46a57 (I know because I traced this
problem myself back then).

I'll test a combination of what you sent me +
535a55ec9eff83ac1cdf58a6514f4a76cab46a57



It works (tested with notepad). You need both patches, the one you
provided + 535a55ec9eff83ac1cdf58a6514f4a76cab46a57.

Robert Millan



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
Help Create a new topicNext page Replies Make a reply
Search Make your own search