[llvm-bugs] [Bug 30293] New: clang-cl miscompilation of Firefox's netwerk/base/nsSocketTransportService2.cpp

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 6 08:41:51 PDT 2016


            Bug ID: 30293
           Summary: clang-cl miscompilation of Firefox's
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: froydnj at gmail.com
                CC: llvm-bugs at 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;
    // Dispatch to socket thread if we're not executing there.
    if (PR_GetCurrentThread() != gSocketThread) {
                this, &nsSocketTransportService::OnKeepaliveEnabledPrefChange),

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160906/674d4664/attachment.html>

More information about the llvm-bugs mailing list