Closed Bug 1477073 Opened 8 years ago Closed 8 years ago

AddressSanitizer: attempting to call malloc_usable_size() for pointer which is not owned: 0x60d00002a988 [@ malloc_usable_size]

Categories

(Core :: JavaScript: WebAssembly, defect)

x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox-esr52 --- unaffected
firefox-esr60 --- wontfix
firefox61 --- wontfix
firefox62 --- wontfix
firefox63 --- fixed

People

(Reporter: decoder, Assigned: bbouvier)

References

(Blocks 1 open bug)

Details

(4 keywords)

Attachments

(2 files, 1 obsolete file)

The attached crash information was submitted via the ASan Nightly Reporter on mozilla-central-asan-nightly revision 63.0a1-20180719100142-https://hg.mozilla.org/mozilla-central/rev/183ee39bf309cd8463d8db5b5c8eb232cd0dac53. For detailed crash information, see attachment.
Flags: needinfo?(bbouvier)
Brian, thanks for your report! Do you remember any specific steps that caused this crash? It looks related to wasm and collecting memory reports (maybe automatic or from about:memory).
The browser never crashed, but I've been flipping knobs and twisting dials every since I read the blog post about this exciting project! I was indeed playing with about:memory earlier, but other then a brief hang while saving verbose gc & cc logs, I didn't notice any unusual behavior.
I can't tell if it is the same thing, but if I'm running the WebAssembly demo at https://webassembly.org/demo/ and I get a memory report in about:memory it seems to always crash.
Decoder told me how to find the ASan reports in my local profile directory (under an ASan subdirectory) and I can confirm that this looks the same as the original report.
Seems like a good candidate to run under rr.
Can confirm the https://webassembly.org/demo tab crashes when I go into about:memory and hit the measure button.
The 3 additional ASan logs that showed up in my profile directory as a result of testing that match the one attached to this report.
Wow, nice catch. Pretty sure it's benign: we're just double counting the memory of an attribute, which pointer is within the bounds of an another object malloc'd before for which we've counted mallocSizeOf(this). I think that's what ASAN is complaining about here. Not a security issue, I think: this API is only used for about:memory reporting, as far as I can tell (I got through the call stack as reported by Searchfox up to JS::CollectRuntimeStats [1]). Will make a patch. [1] https://searchfox.org/mozilla-central/source/js/src/vm/MemoryMetrics.cpp#882
Flags: needinfo?(bbouvier)
Attached patch fix.patch (obsolete) — — Splinter Review
(Assigning review once I've confirmed this is the right fix)
Assignee: nobody → bbouvier
Status: NEW → ASSIGNED
Attached patch fix.patch — — Splinter Review
Hi Luke, welcome back! (See previous comment for explanation of the issue) Another count issue (revealed by a local browser ASAN build) happens when a CompileTask's sizeof(this) is added in HelperThread sizeOfExcludingThis. We can just make them use sizeOfExcludingThis. This makes me think that our memory reporting might be incorrect in other places related to wasm, and it would not be caught by ASAN: - either when we call sizeOfExcludingThis on an object several times during the same report collection, - or when we forget to call it (for instance that might happen for some structures belonging to the ModuleGenerator).
Attachment #8993710 - Attachment is obsolete: true
Attachment #8993743 - Flags: review?(luke)
(In reply to Benjamin Bouvier [:bbouvier] from comment #11) > This makes me think that our memory reporting might be incorrect in other > places related to wasm, and it would not be caught by ASAN: > - either when we call sizeOfExcludingThis on an object several times during > the same report collection, > - or when we forget to call it (for instance that might happen for some > structures belonging to the ModuleGenerator). You can check for both of these things using a DMD build.
(In reply to Andrew McCreight [:mccr8] from comment #12) > (In reply to Benjamin Bouvier [:bbouvier] from comment #11) > > This makes me think that our memory reporting might be incorrect in other > > places related to wasm, and it would not be caught by ASAN: > > - either when we call sizeOfExcludingThis on an object several times during > > the same report collection, > > - or when we forget to call it (for instance that might happen for some > > structures belonging to the ModuleGenerator). > > You can check for both of these things using a DMD build. More specifically add: 1) 'ac_add_options --enable-dmd' to your .mozconfig 2) |./mach run --dmd https://webassembly.org/demo/| 3) load about:memory, click 'Save' under 'Save DMD output' Benjamin, in addition to your patch can you also add a test? We run tests under ASAN which should be enough to catch this type of issue in the future. The WebAudio reporter [1] might be a good example. [1] https://searchfox.org/mozilla-central/rev/8384a6519437f5eefbe522196f9ddf5c8b1d3fb4/dom/media/webaudio/test/test_WebAudioMemoryReporting.html
Flags: needinfo?(bbouvier)
Opening this up based on Benjamin's comments.
Group: javascript-core-security
Comment on attachment 8993743 [details] [diff] [review] fix.patch Review of attachment 8993743 [details] [diff] [review]: ----------------------------------------------------------------- Thanks!
Attachment #8993743 - Flags: review?(luke) → review+
(In reply to Eric Rahm [:erahm] from comment #13) > Benjamin, in addition to your patch can you also add a test? Opened bug 1477969 for this, to not block landing of this patch.
Flags: needinfo?(bbouvier)
Pushed by bbouvier@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/1be8ad5a7f3f Don't double-count wasm structures when creating a memory report; r=luke
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
No longer blocks: asan-nightly-project
Sounds like this can ride the trains to me, but feel free to nominate for Beta approval if you feel strongly otherwise.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: