Closed Bug 1102388 Opened 10 years ago Closed 9 years ago

DMD does not work in a content process

Categories

(Core :: DMD, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
e10s + ---
firefox40 --- fixed

People

(Reporter: mccr8, Assigned: jld)

References

Details

Attachments

(2 files)

I mentioned this in IRC, but I figured I should have a bug on file, too.  It looks like in the DMDFuncs::Singleton ctor that ReplaceMalloc::GetDMDFuncs() is returning null, so any later attempts to call into DMD don't do anything.

This is a non-optimized debug Clang build on Linux, with --enable-dmd.  I'm running DMD with |./mach mochitest-plain --e10s --dmd|.

(I'm marking this as MemShrink because it is impeding a leak investigation, though presumably I could back out bug 1097507 locally for now.)
In ReplaceMallocBridge::Get(), sSingleton->mVersion appears to be... 0?  I don't know how that is even possible.
In the child process, it looks like the ctor for ReplaceMallocBridge is being called after ReplaceMallocBridge::Get(), which I suppose explains why mVersion is 0.
Knowing if this happens in a vanilla |mach run --dmd| invocation would be useful.
Whiteboard: [MemShrink]
This is a minimal example that demonstrates the problem. It runs in the XPConnect ctor just because that always runs, but isn't super early.
with a non-e10s mochitest run it works:
  DMD='--mode=live' ./mach mochitest-plain --dmd

runtests.py | Application pid: 8163
DMD[8163] $DMD = '--mode=live'
(process:8163): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
### XPCOM_MEM_BLOAT_LOG defined -- logging bloat/leaks to /tmp/tmpasRHBk.mozrunner/runtests_leaks.log
[8163] WARNING: Re-registering a CID?: file /home/amccreight/mc/xpcom/components/nsComponentManager.cpp, line 531
[8163] WARNING: DMDFuncs exist: file /home/amccreight/mc/js/xpconnect/src/nsXPConnect.cpp, line 77


with an e10s mochitest run it does not work in the child process:
  DMD='--mode=live' ./mach mochitest-plain --dmd --e10s

DMD[8311] $DMD = '--mode=live'
...
[8311] WARNING: DMDFuncs exist: file /home/amccreight/mc/js/xpconnect/src/nsXPConnect.cpp, line 77
...
DMD[8363] $DMD = '--mode=live'
...
[Child 8363] WARNING: DMDFuncs do not exist: file /home/amccreight/mc/js/xpconnect/src/nsXPConnect.cpp, line 79

With a regular run with e10s enabled it again does not work in the child process:
  ./mach run --dmd --mode live -P debug

DMD[8435] $DMD = '--mode=live'
...
[8435] WARNING: DMDFuncs exist: file /home/amccreight/mc/js/xpconnect/src/nsXPConnect.cpp, line 77
...
DMD[8490] $DMD = '--mode=live'
...
[Child 8490] WARNING: DMDFuncs do not exist: file /home/amccreight/mc/js/xpconnect/src/nsXPConnect.cpp, line 79
Do you see different behavior than me?
Flags: needinfo?(n.nethercote)
tracking-e10s: --- → ?
(In reply to Andrew McCreight [:mccr8] from comment #6)
> Do you see different behavior than me?

I do. I have DMDFuncs set in all those cases. That's with a non-debug DMD build on Linux.
Flags: needinfo?(n.nethercote)
> I do. I have DMDFuncs set in all those cases. That's with a non-debug DMD
> build on Linux.

And likewise with a debug build.
Very weird.  Are you using gcc?  I'm using clang.  Maybe that's the difference?
Both my builds were with clang.
(In reply to Andrew McCreight [:mccr8] from comment #1)
> In ReplaceMallocBridge::Get(), sSingleton->mVersion appears to be... 0?  I
> don't know how that is even possible.

Idea: DMDFuncs::sSingleton's ctor (in libxul) is being called before sDMDBridge's ctor (in libdmd).  So, the path that takes the address of sDMDBridge, passes it down through {replace_,}get_bridge to ReplaceMallocBridge::Get, and reads its mVersion field… runs before the constructor that initializes the mVersion field.
Assignee: nobody → jld
See patch commit message for more info.  Tested by using about:memory in DMD-enabled e10s mode and observing the non-empty child process DMD file.  Also, https://treeherder.mozilla.org/#/jobs?repo=try&revision=08fcd20f11a4 (ASan and V failures seem to be expected given --enable-dmd).
Attachment #8595144 - Flags: review?(continuation)
Comment on attachment 8595144 [details] [diff] [review]
Patch: avoid ctor order dependency with dynamic allocation.

Review of attachment 8595144 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for investigating and fixing this!
Attachment #8595144 - Flags: review?(continuation) → review+
(See testing notes in comment #12.)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/f2fac0a0d4e2
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Nice catch, jld!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: