Date: Thu, 2 Sep 1999 00:02:46 +0200 From: Juergen Lock <nox@jelal.kn-bremen.de> To: wine-devel@winehq.com Cc: freebsd-emulation@FreeBSD.ORG Subject: wine signal handlers lose %fs on FreeBSD Message-ID: <19990902000245.A7319@saturn.kn-bremen.de>
next in thread | raw e-mail | index | archive | help
Here's a strange one: Sometimes apparently wine's signal handlers receive %fs messed up (zeroed actually) and therefore crash/hang on FreeBSD (3.2-stable, wine current-cvs). Patch this and watch for `warn:seh:EXC_SaveContext teb=0xsomewhere teb_sel=something, fs=0, gs=foo' messages, teb_sel is what fs really should have been (and what is loaded back there after the message, so the program actually continues too.) Any idea/explanation from the experts? I have looked at the sources a bit but came up empty. (well i found out that fs and gs aren't set/used in the sigcontext struct for non-vm86 processes but wine knows that and simply uses the registers directly, and i couldn't find anything that looked like it would change them on the way into and out of the signal handler, or anywhere else in the kernel for that matter...) Btw could someone please subscribe this address to -emulation for me? freebsd-emulation-l@jelal.kn-bremen.de (which is a local mailpost alias in case anyone wonders, i prefer reading the lists with trn...) I mailed majordomo with this a while ago (and yes i did send the auth command back :) but alas, no messages. Index: dlls/ntdll/exception.c =================================================================== RCS file: /home/wine/wine/dlls/ntdll/exception.c,v retrieving revision 1.10 diff -u -u -r1.10 exception.c --- dlls/ntdll/exception.c 1999/08/01 14:54:16 1.10 +++ dlls/ntdll/exception.c 1999/09/01 16:21:49 @@ -152,7 +152,8 @@ EXCEPTION_RECORD newrec; DWORD res; - TRACE( "code=%lx flags=%lx\n", rec->ExceptionCode, rec->ExceptionFlags ); + /*TRACE( "code=%lx flags=%lx\n", rec->ExceptionCode, rec->ExceptionFlags );*/ + TRACE( "code=%lx flags=%lx, fs=%lx, gs=%lx\n", rec->ExceptionCode, rec->ExceptionFlags, (long)FS_reg(context), (long)GS_reg(context) ); if ((PROCESS_Current()->flags & PDB32_DEBUGGED) && (DEBUG_SendExceptionEvent( rec, TRUE ) == DBG_CONTINUE)) @@ -372,6 +373,28 @@ #else GET_FS( FS_reg(context) ); FS_reg(context) &= 0xffff; +#if 1 + { + extern TEB *THREAD_First; + TEB *teb = THREAD_First; + int pid = getpid(); + + while (teb) + { + if (teb->pid == pid) break; + teb = teb->next; + } + if (teb) { + if (teb->teb_sel != FS_reg(context)) { + WARN( "teb=%p teb_sel=%x, fs=%lx, gs=%lx\n", teb, (int)teb->teb_sel, (long)FS_reg(context), (long)GS_reg(context) ); + FS_reg(context) = teb->teb_sel; + SET_FS(teb->teb_sel); + } + } else { + WARN( "teb=%p, fs=%lx, gs=%lx\n", teb, (long)FS_reg(context), (long)GS_reg(context) ); + } + } +#endif #endif #ifdef GS_sig GS_reg(context) = LOWORD(GS_sig(sigcontext)); Index: include/thread.h =================================================================== RCS file: /home/wine/wine/include/thread.h,v retrieving revision 1.23 diff -u -u -r1.23 thread.h --- include/thread.h 1999/06/26 08:43:27 1.23 +++ include/thread.h 1999/09/01 16:21:54 @@ -71,6 +71,7 @@ /* The following are Wine-specific fields */ struct _TEB *next; /* Global thread list */ DWORD cleanup; /* Cleanup service handle */ + int pid; } TEB; /* Thread exception flags */ Index: scheduler/sysdeps.c =================================================================== RCS file: /home/wine/wine/scheduler/sysdeps.c,v retrieving revision 1.14 diff -u -u -r1.14 sysdeps.c --- scheduler/sysdeps.c 1999/06/22 11:43:43 1.14 +++ scheduler/sysdeps.c 1999/09/01 16:22:05 @@ -112,6 +112,11 @@ */ void SYSDEPS_SetCurThread( TEB *teb ) { +#if 1 + int pid = getpid(); + TRACE("teb %p, teb->teb_sel 0x%x, pid %d\n", teb, (int)teb->teb_sel, pid ); + teb->pid = pid; +#endif #ifdef __i386__ /* On the i386, the current thread is in the %fs register */ SET_FS( teb->teb_sel ); Thanx and Regards, -- Juergen Lock <nox.foo@jelal.kn-bremen.de> (remove dot foo from address to reply) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990902000245.A7319>