Started playing with Wineserver on mingw/cygwin again

Chris Tooley chris at tooley.com
Thu Feb 6 15:31:52 CST 2003


On Thu, 2003-02-06 at 15:10, Alexandre Julliard wrote:
> Geoff Thorpe <geoff at geoffthorpe.net> writes:
> 
> > Do we have a definitive explanation of just how bad the current
> > wine/pthread incompatibilities are, and/or where current efforts are at?
> > I'd not known there were any efforts to get wine working with nptl
> > (hence my perhaps exaggerated alarm) until the link to Ingo's kernel
> > patch was posted (aug2002 moreover) which suggests at least that some
> > people *are* working on this (phew). I would be very grateful to know
> > what the status is. Anyone? TIA.
> 
> I've been in touch with Ingo, and I'm looking into the issue. However
> I'm currently moving, so things are a bit hectic around here, and I
> don't have good internet access. Hopefully things will settle down a
> bit soon so that I can get some real work done...

I realize that this discussion is targeted at a real solution to the
problem, however some of us are already in the situation and are too
dumb to know how to deal with it.  On the RedHat Phoebe (Beta versions
already exhibit this problem) it was said that using
LD_ASSUME_KERNEL=2.2.5 would solve the problem but that didn't work for
me.  However, there was a workaround on the vmware newsgroup (vmware is
afflicted with a similar disease) that preloads a small .so to make it
work.  This might be useful for some people.  I've used it with some
success on my installation of wine.  I've attached the modified
newsgroup posting below in case someone else would like it.

<stolen from newsgroup and modified>
In the interest of posterity (and helping anyone else using wine with
rawhide glibc), here's what ended up working.

Compile the attached file q.c into q.so.  Put q.so into /usr/lib/, and
chmod it 555.  Then rename the files /opt/wine/bin/wine.bin,
giving it a (second) ".bin" extension.  Then create two new files named
/opt/wine/bin/wine-bin instead that contain:
-------------------
#!/bin/bash
LD_PRELOAD=q.so exec "$0.bin" "$@"
-------------------

chmod a+rx these new files, and all should be well.

The basic problem is that vmware binaries have their own copy of errno and
related functions, and there is a clash with the new glibc ones.  q.so will
resolve this problem.  The need for the scripts above arises from the fact
that each of the binaries launched by the initial /opt/wine/bin/wine.bin call
needs to have the q.so preloaded.  

q.c was written by Petr Vendrovec, and many thanks go to him for the work
he put into the debugging of the problem and the attached code!

In summary, q.c qorreqts the formerly inqurable qrashes.


-------------------------------------------------------
/*
 * Build with: gcc -W -Wall -shared -o q.so q.c
 */

#include <dlfcn.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>

void go(void) __attribute__((constructor));

void go(void) {
	void* qh;
	unsigned char *__real_errno_location, *__vm_errno_location;

	qh = dlopen("libc.so.6", RTLD_GLOBAL);
	__real_errno_location = dlsym(qh, "__errno_location");
	__vm_errno_location = dlsym(NULL, "__errno_location");
	printf("Got eroloc %p & %p\n", __vm_errno_location, __real_errno_location);
	if (__real_errno_location && __vm_errno_location && __real_errno_location != __vm_errno_location) {
		unsigned int errnobase = (int)__vm_errno_location;
		unsigned int mpbase = errnobase & ~0xFFF;
		unsigned int mplen = 4096;

		if (errnobase + 5 > mpbase + mplen) {
			mplen = mplen + 4096;
		}
		mprotect((void*)mpbase, mplen, PROT_READ|PROT_WRITE|PROT_EXEC);
		*__vm_errno_location = 0xE9;
		*(int*)(__vm_errno_location + 1) = __real_errno_location - __vm_errno_location - 5;
		mprotect((void*)mpbase, mplen, PROT_READ|PROT_EXEC);
	}
}
-------------------------------------------------------
</stolen from newsgroup and modified>

I make no guarantees that this will work, but I'm hopeful.

-- 
Chris Tooley <chris at tooley.com>



More information about the wine-devel mailing list