Heap-use-after-free BuildTextRunsScanner::BreakSink::SetBreaks
Originally disclosed on Mozilla
- Fixed in 4 months
- Paid in 5 months
- Disclosed after 4 months
Created attachment 636135 Testcase
Reproduces on trunk reliably when run from command line. The testcase is ugly, but seems to be dependent on text runs. 20120623201000 http://hg.mozilla.org/mozilla-central/rev/cb2904476d14
================================================================= ==29398== ERROR: AddressSanitizer heap-use-after-free on address 0x7fd3dc188480 at pc 0x7fd40e3c1930 bp 0x7fffbbf91e10 sp 0x7fffbbf91e08 READ of size 8 at 0x7fd3dc188480 thread T0 #0 0x7fd40e3c1930 in BuildTextRunsScanner::BreakSink::SetBreaks(unsigned int, unsigned int, unsigned char*) layout/generic/nsTextFrameThebes.cpp:855 #1 0x7fd40f6b79bc in nsLineBreaker::FlushCurrentWord() content/base/src/nsLineBreaker.cpp:123 #2 0x7fd40f6c293a in nsLineBreaker::AppendText(nsIAtom*, unsigned char const*, unsigned int, unsigned int, nsILineBreakSink*) content/base/src/nsLineBreaker.cpp:352 #3 0x7fd40e2f188b in BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun*, void const*, unsigned int) layout/generic/nsTextFrameThebes.cpp:2216 #4 0x7fd40e2dc353 in BuildTextRunsScanner::SetupLineBreakerContext(gfxTextRun*) layout/generic/nsTextFrameThebes.cpp:2127 #5 0x7fd40e2d934f in BuildTextRunsScanner::FlushFrames(bool, bool) layout/generic/nsTextFrameThebes.cpp:1337 #6 0x7fd40e2fcad8 in BuildTextRuns(gfxContext*, nsTextFrame*, nsIFrame*, nsLineList_iterator const*, nsTextFrame::TextRunType) layout/generic/nsTextFrameThebes.cpp:1285 #7 0x7fd40e2f8754 in nsTextFrame::EnsureTextRun(nsTextFrame::TextRunType, gfxContext*, nsIFrame*, nsLineList_iterator const*, unsigned int*) layout/generic/nsTextFrameThebes.cpp:2371 #8 0x7fd40e37cd6d in nsTextFrame::ReflowText(nsLineLayout&, int, nsRenderingContext*, bool, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsTextFrameThebes.cpp:7388 #9 0x7fd40e1904e8 in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:836 #10 0x7fd40e160ebd in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) layout/generic/nsInlineFrame.cpp:680 #11 0x7fd40e15d5ed in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsInlineFrame.cpp:543 #12 0x7fd40e15a8fa in nsInlineFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsInlineFrame.cpp:397 #13 0x7fd40e19016f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:824 #14 0x7fd40e160ebd in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) layout/generic/nsInlineFrame.cpp:680 #15 0x7fd40e15d5ed in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsInlineFrame.cpp:543 #16 0x7fd40e15a8fa in nsInlineFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsInlineFrame.cpp:397 #17 0x7fd40e19016f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:824 #18 0x7fd40de4b52f in nsBlockFrame::ReflowInlineFrame(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsIFrame*, LineReflowStatus*) layout/generic/nsBlockFrame.cpp:3834 #19 0x7fd40de44f8a in nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) layout/generic/nsBlockFrame.cpp:3630 #20 0x7fd40de37a07 in nsBlockFrame::ReflowInlineFrames(nsBlockReflowState&, nsLineList_iterator, bool*) layout/generic/nsBlockFrame.cpp:3482 #21 0x7fd40de263bc in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) layout/generic/nsBlockFrame.cpp:2570 #22 0x7fd40de0b821 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) layout/generic/nsBlockFrame.cpp:2020 #23 0x7fd40ddff2bf in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsBlockFrame.cpp:1069 #24 0x7fd40deeed97 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) layout/generic/nsContainerFrame.cpp:906 #25 0x7fd40e0bf237 in nsCanvasFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsCanvasFrame.cpp:429 #26 0x7fd40deeed97 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) layout/generic/nsContainerFrame.cpp:906 #27 0x7fd40e038b7e in nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState*, bool, bool, nsHTMLReflowMetrics*, bool) layout/generic/nsGfxScrollFrame.cpp:517 #28 0x7fd40e03e42a in nsHTMLScrollFrame::ReflowContents(ScrollReflowState*, nsHTMLReflowMetrics const&) layout/generic/nsGfxScrollFrame.cpp:617 #29 0x7fd40e04274f in nsHTMLScrollFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsGfxScrollFrame.cpp:858 #30 0x7fd40deeed97 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) layout/generic/nsContainerFrame.cpp:906 #31 0x7fd40e416ff1 in ViewportFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsViewportFrame.cpp:200 #32 0x7fd40db70356 in PresShell::DoReflow(nsIFrame*, bool) layout/base/nsPresShell.cpp:7382 #33 0x7fd40db9dded in PresShell::ProcessReflowCommands(bool) layout/base/nsPresShell.cpp:7523 #34 0x7fd40db9c4fd in PresShell::FlushPendingNotifications(mozFlushType) layout/base/nsPresShell.cpp:3852 #35 0x7fd40dc3f45b in nsRefreshDriver::Notify(nsITimer*) layout/base/nsRefreshDriver.cpp:396 #36 0x7fd41884a086 in nsTimerImpl::Fire() xpcom/threads/nsTimerImpl.cpp:477 #37 0x7fd41884bbfc in nsTimerEvent::Run() xpcom/threads/nsTimerImpl.cpp:558 #38 0x7fd41880e2b3 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:625 #39 0x7fd41849e55d in NS_ProcessNextEvent_P(nsIThread*, bool) objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:217 #40 0x7fd4175fbff6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:82 #41 0x7fd418ac088a in MessageLoop::RunInternal() ipc/chromium/src/base/message_loop.cc:209 #42 0x7fd418ac06d3 in MessageLoop::RunHandler() ipc/chromium/src/base/message_loop.cc:202 #43 0x7fd418ac05b8 in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:176 #44 0x7fd416b3991e in nsBaseAppShell::Run() widget/xpwidgets/nsBaseAppShell.cpp:165 #45 0x7fd415783518 in nsAppStartup::Run() toolkit/components/startup/nsAppStartup.cpp:256 #46 0x7fd40c1756d7 in XREMain::XRE_mainRun() toolkit/xre/nsAppRunner.cpp:3786 #47 0x7fd40c17c092 in XREMain::XRE_main(int, char**, nsXREAppData const*) toolkit/xre/nsAppRunner.cpp:3863 #48 0x7fd40c17f54b in XRE_main toolkit/xre/nsAppRunner.cpp:3939 #49 0x40a91f in do_main(int, char**) browser/app/nsBrowserApp.cpp:160 #50 0x40834d in main browser/app/nsBrowserApp.cpp:330 #51 0x7fd4269c1c4d in ?? ??:0 0x7fd3dc188480 is located 0 bytes inside of 160-byte region [0x7fd3dc188480,0x7fd3dc188520) freed by thread T0 here: #0 0x4a2ed2 in free ??:0 #1 0x7fd42384f5c3 in moz_free memory/mozalloc/mozalloc.cpp:49 #2 0x7fd40e406fb3 in gfxTextRun::operator delete(void*) ../../dist/include/gfxFont.h:2335 #3 0x7fd418e38148 in ~gfxTextRun gfx/thebes/gfxFont.cpp:4338 #4 0x7fd40e2f778e in nsTextFrame::ClearTextRun(nsTextFrame*, nsTextFrame::TextRunType) layout/generic/nsTextFrameThebes.cpp:4242 #5 0x7fd40e2f3717 in BuildTextRunsScanner::AssignTextRun(gfxTextRun*, float) layout/generic/nsTextFrameThebes.cpp:2343 #6 0x7fd40e2e34b8 in BuildTextRunsScanner::BuildTextRunForFrames(void*) layout/generic/nsTextFrameThebes.cpp:2005 #7 0x7fd40e2d96fd in BuildTextRunsScanner::FlushFrames(bool, bool) layout/generic/nsTextFrameThebes.cpp:1356 #8 0x7fd40e2e95ba in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1521 #9 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #10 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #11 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #12 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #13 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #14 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #15 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #16 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #17 0x7fd40e2fc896 in BuildTextRuns(gfxContext*, nsTextFrame*, nsIFrame*, nsLineList_iterator const*, nsTextFrame::TextRunType) layout/generic/nsTextFrameThebes.cpp:1260 #18 0x7fd40e2f8754 in nsTextFrame::EnsureTextRun(nsTextFrame::TextRunType, gfxContext*, nsIFrame*, nsLineList_iterator const*, unsigned int*) layout/generic/nsTextFrameThebes.cpp:2371 #19 0x7fd40e37cd6d in nsTextFrame::ReflowText(nsLineLayout&, int, nsRenderingContext*, bool, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsTextFrameThebes.cpp:7388 #20 0x7fd40e1904e8 in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:836 #21 0x7fd40e160ebd in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) layout/generic/nsInlineFrame.cpp:680 #22 0x7fd40e15d5ed in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsInlineFrame.cpp:543 #23 0x7fd40e15a8fa in nsInlineFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsInlineFrame.cpp:397 #24 0x7fd40e19016f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:824 #25 0x7fd40e160ebd in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) layout/generic/nsInlineFrame.cpp:680 #26 0x7fd40e15d5ed in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsInlineFrame.cpp:543 #27 0x7fd40e15a8fa in nsInlineFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) layout/generic/nsInlineFrame.cpp:397 #28 0x7fd40e19016f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:824 #29 0x7fd40de4b52f in nsBlockFrame::ReflowInlineFrame(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsIFrame*, LineReflowStatus*) layout/generic/nsBlockFrame.cpp:3834 previously allocated by thread T0 here: #0 0x4a2f92 in malloc ??:0 #1 0x7fd42384fa23 in moz_malloc memory/mozalloc/mozalloc.cpp:64 #2 0x7fd418e36a66 in gfxTextRun::AllocateStorageForTextRun(unsigned long, unsigned int) gfx/thebes/gfxFont.cpp:4277 #3 0x7fd418e19dbf in gfxTextRun::Create(gfxTextRunFactory::Parameters const*, unsigned int, gfxFontGroup*, unsigned int) gfx/thebes/gfxFont.cpp:4294 #4 0x7fd418e1d585 in gfxFontGroup::MakeTextRun(unsigned char const*, unsigned int, gfxTextRunFactory::Parameters const*, unsigned int) gfx/thebes/gfxFont.cpp:3367 #5 0x7fd40e2efc31 in gfxTextRun* MakeTextRun<unsigned char>(unsigned char const*, unsigned int, gfxFontGroup*, gfxTextRunFactory::Parameters const*, unsigned int) layout/generic/nsTextFrameThebes.cpp:517 #6 0x7fd40e2e2ea5 in BuildTextRunsScanner::BuildTextRunForFrames(void*) layout/generic/nsTextFrameThebes.cpp:1965 #7 0x7fd40e2d96fd in BuildTextRunsScanner::FlushFrames(bool, bool) layout/generic/nsTextFrameThebes.cpp:1356 #8 0x7fd40e2e95ba in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1521 #9 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #10 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #11 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #12 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #13 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #14 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #15 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #16 0x7fd40e2e9d99 in BuildTextRunsScanner::ScanFrame(nsIFrame*) layout/generic/nsTextFrameThebes.cpp:1559 #17 0x7fd40e2fc896 in BuildTextRuns(gfxContext*, nsTextFrame*, nsIFrame*, nsLineList_iterator const*, nsTextFrame::TextRunType) layout/generic/nsTextFrameThebes.cpp:1260 #18 0x7fd40e2f8754 in nsTextFrame::EnsureTextRun(nsTextFrame::TextRunType, gfxContext*, nsIFrame*, nsLineList_iterator const*, unsigned int*) layout/generic/nsTextFrameThebes.cpp:2371 #19 0x7fd40e37cd6d in nsTextFrame::ReflowText(nsLineLayout&, int, nsRenderingContext*, bool, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsTextFrameThebes.cpp:7388 #20 0x7fd40e1904e8 in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) layout/generic/nsLineLayout.cpp:836 #21 0x7fd40e160ebd in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) layout/generic/nsInlineFrame.cpp:680 #22 0x7fd40e15d5ed in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) layout/generic/nsInlineFrame.cpp:543 ==29398== ABORTING Stats: 158M malloced (192M for red zones) by 474222 calls Stats: 42M realloced by 20531 calls Stats: 114M freed by 238653 calls Stats: 0M really freed by 0 calls Stats: 380M (97330 full pages) mmaped in 95 calls mmaps by size class: 8:393192; 9:57337; 10:20475; 11:18423; 12:3072; 13:2048; 14:1536; 15:384; 16:576; 17:128; 18:176; 19:48; 20:16; mallocs by size class: 8:383056; 9:48867; 10:17897; 11:17190; 12:2587; 13:1929; 14:1466; 15:348; 16:547; 17:118; 18:163; 19:41; 20:13; frees by size class: 8:167524; 9:37955; 10:14368; 11:13945; 12:1647; 13:991; 14:1252; 15:291; 16:471; 17:103; 18:58; 19:38; 20:10; rfrees by size class: Stats: malloc large: 335 small slow: 2133 Shadow byte and word: 0x1ffa7b831090: fd 0x1ffa7b831090: fd fd fd fd fd fd fd fd More shadow bytes: 0x1ffa7b831070: fa fa fa fa fa fa fa fa 0x1ffa7b831078: fa fa fa fa fa fa fa fa 0x1ffa7b831080: fa fa fa fa fa fa fa fa 0x1ffa7b831088: fa fa fa fa fa fa fa fa =>0x1ffa7b831090: fd fd fd fd fd fd fd fd 0x1ffa7b831098: fd fd fd fd fd fd fd fd 0x1ffa7b8310a0: fd fd fd fd fd fd fd fd 0x1ffa7b8310a8: fd fd fd fd fd fd fd fd 0x1ffa7b8310b0: fa fa fa fa fa fa fa fa
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A critical-severity memory corruption bug in Layout: Text and Fonts. Mozilla made it public on 6 November 2012 as CVE-2012-4218.
About Memory corruption
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.