DMD does not work in a content process

RESOLVED FIXED in Firefox 40

Status

()

Core
DMD
RESOLVED FIXED
4 years ago
3 years ago

People

(Reporter: mccr8, Assigned: jld)

Tracking

Trunk
mozilla40
Points:
---

Firefox Tracking Flags

(e10s+, firefox40 fixed)

Details

Attachments

(2 attachments)

(Reporter)

Description

4 years ago
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.)
(Reporter)

Comment 1

4 years ago
In ReplaceMallocBridge::Get(), sSingleton->mVersion appears to be... 0?  I don't know how that is even possible.
(Reporter)

Comment 2

4 years ago
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]
(Reporter)

Comment 4

4 years ago
Created attachment 8559283 [details] [diff] [review]
Print out if we got the DMD funcs.

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.
(Reporter)

Comment 5

4 years ago
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
(Reporter)

Comment 6

4 years ago
Do you see different behavior than me?
Flags: needinfo?(n.nethercote)
(Reporter)

Updated

4 years ago
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.
(Reporter)

Comment 9

4 years ago
Very weird.  Are you using gcc?  I'm using clang.  Maybe that's the difference?

Updated

4 years ago
tracking-e10s: ? → +
Both my builds were with clang.
(Assignee)

Comment 11

3 years ago
(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)

Updated

3 years ago
Assignee: nobody → jld
(Assignee)

Comment 12

3 years ago
Created attachment 8595144 [details] [diff] [review]
Patch: avoid ctor order dependency with dynamic allocation.

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)
(Reporter)

Comment 13

3 years ago
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+
(Assignee)

Comment 14

3 years ago
(See testing notes in comment #12.)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/f2fac0a0d4e2
Status: NEW → RESOLVED
Last Resolved: 3 years ago
status-firefox40: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Nice catch, jld!
You need to log in before you can comment on or make changes to this bug.