-
Notifications
You must be signed in to change notification settings - Fork 13.5k
LLVM miscompiles dlls/oleaut32/tmarshal.c from Wine #10074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please attach preprocessed C, not .ll files, for reports against clang. |
If I compile dlls/oleaut32/tmarshal.c with gcc, the original crash is gone, but I still get a crash: compiling all of dlls/oleaut32/ with gcc and the rest of wine with clang has the same result. I'll attach tmarshal.i, which is the preprocessed C file for this crash: |
This also fails under Dragonegg SVN (r137784) (breaks dlls/ieframe/tests/ie.c test). |
Still present, as of and wine-1.4-rc3-23-gd548af4. Not a stack alignment issue, the wine patch from bug 9830 does not help here. |
Still present in: |
Follow up, I've noticed that this is the only wine test failure I that I don't have with gcc on my machine. Exact versions: austin@debian-home:~$ gcc --version |
(Fixing title to be more specific)
Seriously, this is some crazy stuff in here. This particular file will actually emit x86 machine code to be executed later (i.e. in a COM type-library marshaller stub-less proxy call; cf. init_proxy_entry_point() starting on line 1735 in the original source). Then, when someone makes a COM v-call on the proxy object, one of these machine-code stubs will actually be executed. More investigation is required. I'll get back to you if I figure out exactly how LLVM is miscompiling this (if at all).
|
There's actually two crashes here. The first is another stack-alignment issue (the xCall() function needs to force-align its stack). But the second is another matter entirely. I don't even know if you'll see it. The second crash I'm seeing is in test_typelibmarshal() (running the oleaut32:tmarshal test), after the RPC to KindaEnum::Next() returns. The method succeeded, and yet it returns a null pointer. I have no idea why this happens, but I'm going to go out on a limb here and say that somehow, the pointer isn't getting marshaled properly on return. Another, possibly related issue is that this particular code only works at all at -O2. Below that, and I get strange segfaults in memset(3) when the stubless proxy marshals pointers to the callee--probably related to the way it grabs the arguments to the target method off the stack (it actually takes the address of its last parameter, then walks up the stack, assuming right-to-left argument passing order). Could this actually "work" at -O2 by accident, getting the wrong pointer off the stack and writing to who knows where? Could this be why we're crashing and burning after the RPC completes? I wish I knew more about how COM RPCs work in Wine. Maybe someone over there knows more. |
I'll wait for Austin to confirm that this is indeed the problem, and then decide what to do about this bug. |
Yes, I can confirm this. However, it was fixed upstream in Wine today, by: the previous code works on gcc, though, so may still be a valid (albeit less important) bug. |
The subsequent use of "args" is undefined behavior. tpinfo is a single pointer-sized variable; we make no guarantees about the layout of other variables/arguments/etc. relative to it. The only supported way to do varargs in C is to use stdarg.h. |
…round-gvn 🍒[cxx-interop] Workaround a template instantiation issue
Extended Description
Part 1 of a long series filed on behalf of Austin English.
Lots of Wine code is miscompiled. (Seriously, you should consider pulling Wine into LLVM's test suite. It's a huge compiler stress test.) One such source file is dlls/oleaut32/tmarshal.c. A .ll file will be attached (I don't have one on hand at the moment). This miscompilation results in yet another AV within Wine, breaking not one but two of Wine's regression tests (see http://bugs.winehq.org/show_bug.cgi?id=25808 and http://bugs.winehq.org/show_bug.cgi?id=25828).
This happens at all optimization levels. This probably happens without the integrated assembler as well.
The text was updated successfully, but these errors were encountered: