Closed Bug 1623083 Opened 6 years ago Closed 6 years ago

Stack overflow crash in [@ nsTArray_base<T>::SwapArrayElements<T> | mozilla::CycleCollectedJSContext::CleanupIDBTransactions]

Categories

(Core :: DOM: File, defect, P2)

Unspecified
Windows 10
defect

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox-esr68 --- wontfix
firefox74 --- wontfix
firefox75 --- wontfix
firefox76 --- fixed

People

(Reporter: mccr8, Assigned: baku)

Details

(Keywords: crash)

Crash Data

Attachments

(1 file)

This bug is for crash report bp-c7138472-dd1a-4bb6-8b11-7c7cc0200317.

Top 10 frames of crashing thread:

0 xul.dll nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyWithMemutils>::SwapArrayElements<nsTArrayInfallibleAllocator, nsTArrayInfallibleAllocator> xpcom/ds/nsTArray-inl.h:385
1 xul.dll mozilla::CycleCollectedJSContext::CleanupIDBTransactions xpcom/base/CycleCollectedJSContext.cpp:417
2 xul.dll mozilla::CycleCollectedJSContext::AfterProcessMicrotasks xpcom/base/CycleCollectedJSContext.cpp:482
3 xul.dll mozilla::CycleCollectedJSContext::PerformMicroTaskCheckPoint xpcom/base/CycleCollectedJSContext.cpp:585
4 xul.dll mozilla::CycleCollectedJSContext::AfterProcessTask xpcom/base/CycleCollectedJSContext.cpp:461
5 xul.dll nsThread::ProcessNextEvent xpcom/threads/nsThread.cpp:1245
6 xul.dll NS_ProcessNextEvent xpcom/threads/nsThreadUtils.cpp:486
7 xul.dll mozilla::dom::WorkerPrivate::RunCurrentSyncLoop dom/workers/WorkerPrivate.cpp:3820
8 xul.dll mozilla::dom::FileReaderSync::SyncRead dom/file/FileReaderSync.cpp:439
9 xul.dll mozilla::dom::FileReaderSync::SyncRead dom/file/FileReaderSync.cpp:399

While I was looking for variant signatures for the shutdown hang in bug 1622114, I came across this interesting crash. Looking at a few of them, it is a stack overflow on workers, where the apparently unbounded recursion is happening in mozilla::dom::FileReaderSync::SyncRead(nsIInputStream*, char*, unsigned int, unsigned int*). The crash volume looks low, but maybe there's an easy fix.

Assignee: nobody → sgiesecke
Assignee: sgiesecke → nobody
Component: Storage: IndexedDB → DOM: File

This looks like a bug in mozilla::dom::FileReaderSync::SyncRead, i.e. in DOM: File, to me. Maybe this can be change not to use recursion at all and clean up its internal resources such as the ReadCallback before the next attempt. In addition, maybe it makes sense to somehow limit the number of retries before giving up?

(In reply to Simon Giesecke [:sg] [he/him] from comment #1)

This looks like a bug in mozilla::dom::FileReaderSync::SyncRead, i.e. in DOM: File, to me. Maybe this can be change not to use recursion at all and clean up its internal resources such as the ReadCallback before the next attempt. In addition, maybe it makes sense to somehow limit the number of retries before giving up?

I read here:: "Loop would be nicer, hopefully we don't end up doing too deep recursive calls." as part of the review. Probably it's time to make it a loop without recursion (I see no real need for it, too)?

I think I could rework the function, if someone clarifies if it makes sense to give up at some point, and what a sensible criterion for that might be. With each attempt, we must have read at least read 1 byte, IIUC, so we're definitely making some progress. So maybe replacing the recursion without imposing a limit on retries is sufficient.

baku, can you give me some advice on that?

Flags: needinfo?(amarchesini)
Assignee: nobody → amarchesini
Status: NEW → ASSIGNED

Yes, we can simply remove the recursion here. Reading the code I changed the code a bit to avoid the recursion. Let me know if it looks correct to you.

Flags: needinfo?(amarchesini)
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d30df7470df1 No recursion in FileReaderSync::SyncRead, r=sg
Priority: -- → P2
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: