Closed Bug 1577534 Opened 6 years ago Closed 6 years ago

Perma tier2 LeakSanitizer | leak at NewSegment, CreateSegment, mozilla::ipc::Shmem::Alloc, mozilla::ipc::IToplevelProtocol::CreateSharedMemory

Categories

(Core :: Audio/Video: MediaStreamGraph, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox-esr60 --- unaffected
firefox-esr68 --- unaffected
firefox68 --- unaffected
firefox69 --- unaffected
firefox70 --- fixed
firefox71 --- fixed

People

(Reporter: intermittent-bug-filer, Assigned: pehrsons)

References

(Regression)

Details

(Keywords: intermittent-failure, regression, Whiteboard: [stockwell disable-recommended])

Attachments

(1 file)

Filed by: apavel [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer.html#?job_id=264060060&repo=autoland
Full log: https://queue.taskcluster.net/v1/task/NbNkvZ8pS0uSja3lhKVYzg/runs/0/artifacts/public/logs/live_backing.log


task 2019-08-29T15:02:50.302Z] 15:02:50 INFO - TEST-START | /mixed-content/worklet-paint-data-import/meta-csp/same-host-http/top-level/no-redirect/blockable/opt-in-blocks.https.html
[task 2019-08-29T15:02:50.306Z] 15:02:50 INFO - Closing window 119
[task 2019-08-29T15:02:50.465Z] 15:02:50 INFO - PID 18385 | -----------------------------------------------------
[task 2019-08-29T15:02:50.466Z] 15:02:50 INFO - PID 18385 | Suppressions used:
[task 2019-08-29T15:02:50.466Z] 15:02:50 INFO - PID 18385 | count bytes template
[task 2019-08-29T15:02:50.466Z] 15:02:50 INFO - PID 18385 | 27 832 nsComponentManagerImpl
[task 2019-08-29T15:02:50.466Z] 15:02:50 INFO - PID 18385 | 611 17713 libfontconfig.so
[task 2019-08-29T15:02:50.466Z] 15:02:50 INFO - PID 18385 | 1 29 libglib-2.0.so
[task 2019-08-29T15:02:50.467Z] 15:02:50 INFO - PID 18385 | -----------------------------------------------------
[task 2019-08-29T15:02:51.392Z] 15:02:51 INFO - .
[task 2019-08-29T15:02:51.392Z] 15:02:51 INFO - TEST-OK | /mixed-content/worklet-paint-data-import/meta-csp/same-host-http/top-level/no-redirect/blockable/opt-in-blocks.https.html | took 1091ms

[task 2019-08-29T15:02:55.211Z] 15:02:55 INFO - Browser exited with return code 0
[task 2019-08-29T15:02:55.211Z] 15:02:55 INFO - PROCESS LEAKS None
[task 2019-08-29T15:02:55.212Z] 15:02:55 INFO - ERROR | LeakSanitizer | SUMMARY: AddressSanitizer: 176 byte(s) leaked in 2 allocation(s).
[task 2019-08-29T15:02:55.212Z] 15:02:55 INFO - LeakSanitizer | To show the addresses of leaked objects add report_objects=1 to LSAN_OPTIONS
[task 2019-08-29T15:02:55.212Z] 15:02:55 INFO - This can be done in testing/mozbase/mozrunner/mozrunner/utils.py
[task 2019-08-29T15:02:55.212Z] 15:02:55 INFO - Allowed depth was 4
[task 2019-08-29T15:02:55.212Z] 15:02:55 INFO - TEST-UNEXPECTED-FAIL | LeakSanitizer | leak at NewSegment, CreateSegment, mozilla::ipc::Shmem::Alloc, mozilla::ipc::IToplevelProtocol::CreateSharedMemory
[task 2019-08-29T15:02:55.213Z] 15:02:55 INFO - TEST-UNEXPECTED-FAIL | LeakSanitizer | leak at mozilla::layers::BufferTextureData::CreateInternal, mozilla::layers::BufferTextureData::CreateForYCbCr, mozilla::layers::TextureClient::CreateForYCbCr, mozilla::layers::YCbCrTextureClientAllocationHelper::Allocate
[task 2019-08-29T15:02:55.214Z] 15:02:55 INFO - Closing logging queue

Summary: Intermittent LeakSanitizer | leak at NewSegment, CreateSegment, mozilla::ipc::Shmem::Alloc, mozilla::ipc::IToplevelProtocol::CreateSharedMemory → Perma tier2 LeakSanitizer | leak at NewSegment, CreateSegment, mozilla::ipc::Shmem::Alloc, mozilla::ipc::IToplevelProtocol::CreateSharedMemory
Regressed by: 1574965
Whiteboard: [retriggered]
Assignee: nobody → apehrson
Status: NEW → ASSIGNED
Component: DOM: Security → Audio/Video: MediaStreamGraph
Flags: needinfo?(apehrson)
Priority: P5 → P2

I can see where these shmem buffers are allocated -- but the question is where they're held when we leak. I'll have to dig deeper tomorrow.

This is the relevant part of the stack when releasing that gfx resource, from a try run where I elevated the gfx error:

[task 2019-08-29T19:17:01.714Z] 19:17:01     INFO - PID 18332 |     #23 0x7f8b7e1c33ed in mozilla::layers::SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() /builds/worker/workspace/build/src/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp:36:51
[task 2019-08-29T19:17:01.724Z] 19:17:01     INFO - PID 18332 |     #24 0x7f8b81efa3be in Release /builds/worker/workspace/build/src/obj-firefox/dist/include/ImageContainer.h:194:3
[task 2019-08-29T19:17:01.726Z] 19:17:01     INFO - PID 18332 |     #25 0x7f8b81efa3be in Release /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:48
[task 2019-08-29T19:17:01.727Z] 19:17:01     INFO - PID 18332 |     #26 0x7f8b81efa3be in Release /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:373
[task 2019-08-29T19:17:01.729Z] 19:17:01     INFO - PID 18332 |     #27 0x7f8b81efa3be in ~RefPtr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:79
[task 2019-08-29T19:17:01.731Z] 19:17:01     INFO - PID 18332 |     #28 0x7f8b81efa3be in ~VideoFrame /builds/worker/workspace/build/src/dom/media/VideoSegment.cpp:30
[task 2019-08-29T19:17:01.732Z] 19:17:01     INFO - PID 18332 |     #29 0x7f8b81efa3be in ~VideoChunk /builds/worker/workspace/build/src/dom/media/VideoSegment.h:65
[task 2019-08-29T19:17:01.734Z] 19:17:01     INFO - PID 18332 |     #30 0x7f8b81efa3be in Destruct /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:554
[task 2019-08-29T19:17:01.735Z] 19:17:01     INFO - PID 18332 |     #31 0x7f8b81efa3be in DestructRange /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:2224
[task 2019-08-29T19:17:01.737Z] 19:17:01     INFO - PID 18332 |     #32 0x7f8b81efa3be in ClearAndRetainStorage /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:1329
[task 2019-08-29T19:17:01.738Z] 19:17:01     INFO - PID 18332 |     #33 0x7f8b81efa3be in ~nsTArray_Impl /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:910
[task 2019-08-29T19:17:01.740Z] 19:17:01     INFO - PID 18332 |     #34 0x7f8b81efa3be in mozilla::MediaSegmentBase<mozilla::VideoSegment, mozilla::VideoChunk>::~MediaSegmentBase() /builds/worker/workspace/build/src/dom/media/MediaSegment.h:235
[task 2019-08-29T19:17:01.741Z] 19:17:01     INFO - PID 18332 |     #35 0x7f8b81eea3ed in ~VideoSegment /builds/worker/workspace/build/src/dom/media/VideoSegment.cpp:112:32
[task 2019-08-29T19:17:01.743Z] 19:17:01     INFO - PID 18332 |     #36 0x7f8b81eea3ed in mozilla::VideoSegment::~VideoSegment() /builds/worker/workspace/build/src/dom/media/VideoSegment.cpp:112
[task 2019-08-29T19:17:01.744Z] 19:17:01     INFO - PID 18332 |     #37 0x7f8b82257dbc in ~nsAutoPtr /builds/worker/workspace/build/src/obj-firefox/dist/include/nsAutoPtr.h:65:18
[task 2019-08-29T19:17:01.746Z] 19:17:01     INFO - PID 18332 |     #38 0x7f8b82257dbc in ~Track /builds/worker/workspace/build/src/dom/media/StreamTracks.h:70
[task 2019-08-29T19:17:01.747Z] 19:17:01     INFO - PID 18332 |     #39 0x7f8b82257dbc in ~nsAutoPtr /builds/worker/workspace/build/src/obj-firefox/dist/include/nsAutoPtr.h:65
[task 2019-08-29T19:17:01.748Z] 19:17:01     INFO - PID 18332 |     #40 0x7f8b82257dbc in Destruct /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:554
[task 2019-08-29T19:17:01.749Z] 19:17:01     INFO - PID 18332 |     #41 0x7f8b82257dbc in DestructRange /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:2224
[task 2019-08-29T19:17:01.750Z] 19:17:01     INFO - PID 18332 |     #42 0x7f8b82257dbc in ClearAndRetainStorage /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:1329
[task 2019-08-29T19:17:01.750Z] 19:17:01     INFO - PID 18332 |     #43 0x7f8b82257dbc in Clear /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:1805
[task 2019-08-29T19:17:01.750Z] 19:17:01     INFO - PID 18332 |     #44 0x7f8b82257dbc in mozilla::StreamTracks::Clear() /builds/worker/workspace/build/src/dom/media/StreamTracks.cpp:98
[task 2019-08-29T19:17:01.765Z] 19:17:01     INFO - PID 18332 |     #45 0x7f8b822104d3 in mozilla::MediaStream::DestroyImpl() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1985:11
[task 2019-08-29T19:17:01.765Z] 19:17:01     INFO - PID 18332 |     #46 0x7f8b82214c3f in mozilla::SourceMediaStream::DestroyImpl() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:2412:16
[task 2019-08-29T19:17:01.765Z] 19:17:01     INFO - PID 18332 |     #47 0x7f8b82239f1c in mozilla::MediaStream::Destroy()::Message::Run() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1999:16
[task 2019-08-29T19:17:01.767Z] 19:17:01     INFO - PID 18332 |     #48 0x7f8b82206cd9 in mozilla::MediaStreamGraphImpl::RunMessagesInQueue() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1167:20
[task 2019-08-29T19:17:01.770Z] 19:17:01     INFO - PID 18332 |     #49 0x7f8b8220aed6 in mozilla::MediaStreamGraphImpl::OneIterationImpl(long) /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1400:3
[task 2019-08-29T19:17:01.770Z] 19:17:01     INFO - PID 18332 |     #50 0x7f8b81f60be7 in mozilla::AudioCallbackDriver::DataCallback(float const*, float*, long) /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:882:36

It looks like what leads to this is a window being closed and a CubebOperation (driver switch/start ?) taking some time to finish, leading us to iterate the graph later than expected:

[task 2019-08-29T19:16:59.974Z] 19:16:59     INFO - TEST-START | /mediacapture-streams/MediaStream-finished-add.https.html
[task 2019-08-29T19:16:59.974Z] 19:16:59     INFO - Closing window 61
[task 2019-08-29T19:17:00.100Z] 19:17:00     INFO - PID 18332 | SharedThreadPool in xpcom-shutdown-threads. Waiting for pools "CubebOperation"
...
[task 2019-08-29T19:17:00.753Z] 19:17:00     INFO - PID 18332 | Crash Annotation GraphicsCriticalError: |[C0][GFX1]: Texture deallocated too late during shutdown (t=4.40205) [GFX1]: Texture deallocated too late during shutdown
[task 2019-08-29T19:17:00.753Z] 19:17:00     INFO - PID 18332 | Assertion failure: false (Texture deallocated too late during shutdown), at /builds/worker/workspace/build/src/gfx/layers/client/TextureClient.cpp:481

Having a MediaStream around in xpcom-shutdown-threads is unexpected.

MediaStreamGraph has an AsyncShutdownBlocker -- are we removing that before all streams are removed?

Right, if the blocker is notified of shutdown after the last stream has been removed on main thread (graph removed from gGraphs), that graph won't be notified, and shutdown progresses too soon.

See Also: → 1577755
See Also: 1577755

Hi Andreas. seeing that this has a very high occurrence rate, can you give a time estimate for a fix?

Flags: needinfo?(apehrson)

I wonder whether it is possible to create a ShutdownTicket when we remove the graph from gGraphs, which I assume is when we know the graph will be shutdown, but that is assuming that remaining ports will be removed soon. Maybe it would be more consistent to only remove from gGraphs when there are neither streams nor ports.

Whiteboard: [retriggered][stockwell disable-recommended] → [stockwell needswork]

I expect to get a fix in today. I wrote up a patch on friday that hit some issues but now largely works. It does a bit much perhaps and is prone to create leaks. I'll write up a simpler thing today that focuses on MediaStreamGraph rather than the general ShutdownBlocker/ShutdownTicket mechanisms.

Flags: needinfo?(apehrson)
See Also: → 1568176
Blocks: 1568176
See Also: 1568176
Attachment #9089870 - Attachment description: Bug 1577534 - Give MediaStreamGraphs individual ShutdownBlockers. r?padenot → Bug 1577534 - Give MediaStreamGraphs individual ShutdownBlockers. r?karlt

This will have to wait until tomorrow, because of the timezone difference to the reviewer. padenot was not able to review today.

Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4feb20ebb67d Give MediaStreamGraphs individual ShutdownBlockers. r=karlt
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71

Comment on attachment 9089870 [details]
Bug 1577534 - Give MediaStreamGraphs individual ShutdownBlockers. r?karlt

Beta/Release Uplift Approval Request

  • User impact if declined: Possible small leak if a content process is shut down at the wrong time. High frequency in CI.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Slight functionality refactor that looks fairly large. No timing or threading changes which is why I consider it low risk.
  • String changes made/needed:
Attachment #9089870 - Flags: approval-mozilla-beta?

Comment on attachment 9089870 [details]
Bug 1577534 - Give MediaStreamGraphs individual ShutdownBlockers. r?karlt

Fix for shutdown memory leak, OK for uplift for beta 4.

Attachment #9089870 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: