Bug 194757

Summary: unhandled syscall: mdep: 5 (i386_set_ldt)
Product: [Developer tools] valgrind Reporter: Stefan Dösinger <stefandoesinger>
Component: generalAssignee: Julian Seward <jseward>
Status: ASSIGNED ---    
Severity: normal CC: jan, njn, rhyskidd
Priority: NOR    
Version: 3.5 SVN   
Target Milestone: wanted3.6.0   
Platform: unspecified   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: valgring -v log

Description Stefan Dösinger 2009-05-31 15:37:37 UTC
Created attachment 34143 [details]
valgring -v log

I tried to run a Wine(www.winehq.org) build on OSX in Valgrind. Valgrind complains about this unimplemented syscall:

--46758-- WARNING: unhandled syscall: 50331653
--46758--            a.k.a.: 5
==46758==    at 0x6015EAF3: i386_set_ldt (in /usr/lib/libSystem.B.dylib)
==46758==    by 0x6002100E: wine_ldt_init_fs (in /Users/stefan/build/wine/libs/wine/libwine.1.dylib)
==46758==    by 0x7BC6B133: signal_init_thread (in /Users/stefan/build/wine/dlls/ntdll/ntdll.dll.so)
==46758==    by 0x7BC72859: thread_init (in /Users/stefan/build/wine/dlls/ntdll/ntdll.dll.so)
==46758==    by 0x7BC428A7: __wine_process_init (in /Users/stefan/build/wine/dlls/ntdll/ntdll.dll.so)
==46758==    by 0x60022572: wine_init (in /Users/stefan/build/wine/libs/wine/libwine.1.dylib)
==46758==    by 0x7BF00E4C: main (in /Users/stefan/build/wine/loader/wine)
--46758-- You may be able to write your own handler.
--46758-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--46758-- Nevertheless we consider this a bug.  Please report
--46758-- it at http://valgrind.org/support/bug_reports.html.
eq_SyscallStatus:
  {78 0 43}
  {78 0 41}

valgrind: m_syswrap/syswrap-main.c:384 (eq_SyscallStatus): the 'impossible' happened.
$ uname && uname -r
Darwin
9.7.0

I'll attach a full valgrind -v log. The command used was:valgrind --trace-children=yes --auto-run-dsymutil=yes -v /Users/stefan/build/wine/wine notepad

Another notepad instance was already running outside valgrind as suggested by the Wine valgrind wiki page to avoid running wineserver in valgrind.
Comment 1 Nicholas Nethercote 2009-06-03 03:57:12 UTC
This is i386_set_ldt, which is syscall number 5 in Darwin's "machine-dependent" syscalls.  i386_get_ldt will probably be hit soon after, it's number 6.
Comment 2 Nicholas Nethercote 2009-06-04 06:05:41 UTC
If you update your SVN trunk check-out, you'll now get a slightly more informative error message -- it should better identify the syscall class and number.  

But that doesn't solve your problem.  LDTs are tricky, unfortunately...
Comment 3 Julian Seward 2009-06-05 14:50:30 UTC
This should not be too difficult to fix, but I will need a
test case to develop/verify the fix with.  How difficult is
it to build Wine on MacOSX?  It would be helpful if you could
send step by step instructions to build Wine on a MacOSX
box and reproduce the failure.
Comment 4 Nicholas Nethercote 2009-06-29 07:11:44 UTC
Stefan, can you provide the info that Julian asked for?
Comment 5 Stefan Dösinger 2009-06-29 09:09:38 UTC
Ah, sorry, I did not see Julian's posting

Building Wine on OSX is not much harder than on Linux, but you have to provide many libraries that exist on a standard Linux systems manually, like libpng or libjpeg. You also need the newest release of Apple's X server. I think OpenGL still does not work right with the standard X server, but it is not needed to reproduce this bug.

Wine has a wiki page for OSX: http://wiki.winehq.org/MacOSX. If you run into problems, feel free to ask back
Comment 6 Stefan Dösinger 2009-06-29 09:15:14 UTC
Actually, that wiki page has a lot of outdated information. The best is to download the source, run configure and see where it complains.
Comment 7 Jan Kneschke 2010-06-02 21:02:41 UTC
After building 'valgrind-devel' (aka r11104 + VEX r1965) with --enable-32bitonly I ran into the same bug:

--97875-- WARNING: unhandled syscall: mdep:  5
--97875-- You may be able to write your own handler.
--97875-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--97875-- Nevertheless we consider this a bug.  Please report
--97875-- it at http://valgrind.org/support/bug_reports.html.
eq_SyscallStatus:
  {78 0 43}
  {78 0 41}

valgrind: m_syswrap/syswrap-main.c:384 (eq_SyscallStatus): the 'impossible' happened.
==97875==    at 0xF00AB1F5: ???
==97875==    by 0xF00AB3B8: ???
==97875==    by 0xF010A66C: ???
==97875==    by 0xF010B933: ???
==97875==    by 0xF01072B3: ???
==97875==    by 0xF0108409: ???
==97875==    by 0xF012EF5F: ???

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable
==97875==    at 0x4015D5F7: i386_set_ldt (in /usr/lib/libSystem.B.dylib)
==97875==    by 0x4001E8B4: wine_ldt_init_fs (in /opt/local/lib/libwine.1.0.dylib)
==97875==    by 0x7BC657CA: signal_init_thread (in /opt/local/lib/wine/ntdll.dll.so)
==97875==    by 0x7BC6E9BA: thread_init (in /opt/local/lib/wine/ntdll.dll.so)
==97875==    by 0x7BC42793: __wine_process_init (in /opt/local/lib/wine/ntdll.dll.so)
==97875==    by 0x4001F8D0: wine_init (in /opt/local/lib/libwine.1.0.dylib)
==97875==    by 0x7BF00D8C: main (in /opt/local/libexec/wine/wine)

wine is wine-1.2rc2 (aka wine-devel from macports).
Comment 8 Julian Seward 2010-09-01 17:26:17 UTC
It might be possible to make progress on this by looking at
how the equivalent syscall on x86-linux is handled.  I'm sure
there is one for setting LDT entries.  Look in syswrap-x86-linux.c.