https://llvm.org/bugs/show_bug.cgi?id=30293
Bug ID: 30293 Summary: clang-cl miscompilation of Firefox's netwerk/base/nsSocketTransportService2.cpp Product: new-bugs Version: trunk Hardware: PC OS: Windows NT Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: froy...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 17216 --> https://llvm.org/bugs/attachment.cgi?id=17216&action=edit preprocessed source and runscript While debugging why Firefox crashes when compiled with clang-cl, I ran across this miscompilation. In nsSocketTransport2.cpp, we have: nsSocketTransportService* gSocketTransportService = nullptr; ... void nsSocketTransportService::OnKeepaliveEnabledPrefChange() { // Dispatch to socket thread if we're not executing there. if (PR_GetCurrentThread() != gSocketThread) { gSocketTransportService->Dispatch( NewRunnableMethod( this, &nsSocketTransportService::OnKeepaliveEnabledPrefChange), nsIEventTarget::DISPATCH_NORMAL); return; } ... } The preprocessed source file, along with the command-line flags used to compile it, are provided in the attached tarball. What I see happening in the debugger running Firefox is: 1. At the start of OnKeepaliveEnabledPrefChange, ecx contains |this|, and so does gSocketTransportService. 2. When we load from gSocketTransportService, we adjust its value by 4. 3. When we're preparing to call Dispatch, I think the code is assembling a member function pointer to be used with some kind of thunk. Whatever it's doing, the adjusted value we constructed in step (2) winds up in 0(%ecx) 3. When Dispatch() is invoked, we go through what looks like a thunk, but none of the arguments are massaged in any way; the thunk jumps directly to the Dispatch() implementation. (I think this is a thunk, anyway; it doesn't appear in llvm-objdump -d output, but it's definitely there in the debugger, for reasons I do not understand.) 4. The real Dispatch implementation receives the adjusted pointer from step (3) in 0(%ecx), acts on it as though it's the actual |this| pointer and things go south from there. We call nsSocketTransportService::GetThreadSafely() with the wrong |this| value and it loads a null pointer instead of the actual pointer it's supposed to load. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs