Closed Bug 300122 Opened 19 years ago Closed 19 years ago

Crash [@ ConvertUnicharToUCS4]

Categories

(Core :: Layout, defect)

x86
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: bastiaan, Assigned: bastiaan)

References

Details

(Keywords: crash, testcase)

Crash Data

Attachments

(2 files)

This crash is triggered by testcases 3 and 4 in bug 252970. However, that bug
has been declared a windows-only problem and the stacktrace is different, so
I've started a new bug.

This crash seems to originate in nsTextFrame::GetPointFromOffset(), which
sometimes calls nsRenderingContextGTK::GetWidth() with an invalid aLength
parameter, as you can see in frame 5 in the stacktrace.
Attached file gdb stacktrace
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/layout/generic/nsTextFrame.cpp&mark=4193,4213#4180


The problem is that ip[inOffset] contains a rather large number, which causes
ConvertUnicharToUCS4() to overflow the buffer. The attached patch checks for
that and corrects if necessary.

The next step is to determine _why_ ip[inOffset] contains such a large number.
 Some thunderbird stack traces (mentioned in bug 252970)  go through
GetPointFromOffset so that it may prevent TB from crashing.

re: gdb stacktrace

#4  nsRenderingContextGTK::GetWidth (... aLength=142683648 ...)
#5  nsTextFrame::GetPointFromOffset (... inOffset=1 )

It all looks very fishy. How can a simple inOffset=1 lead to such a huge length.
It is not even that inOffset is big (implying that some other code/loop kicks in
and messes things up). It gives the impression that no code (or little code) is
reached, leaving things uninitialized by the time we get there.
I get a lot of UMRs with valgrind starting with:
Conditional jump or move depends on uninitialised value(s)
 nsTextFrame::PrepareUnicodeText(nsTextTransformer&, nsAutoIndexBuffer*,
nsAutoTextBuffer*, int*, int, int*) (nsTextFrame.cpp:1900)
 nsTextFrame::GetPointFromOffset(nsPresContext*, nsIRenderingContext*, int,
nsPoint*) (nsTextFrame.cpp:4171)
 nsTypedSelection::GetPointFromOffset(nsIFrame*, int, nsPoint*)
(nsSelection.cpp:6734)
 nsTypedSelection::GetCachedFrameOffset(nsIFrame*, int, nsPoint&)
(nsSelection.cpp:5086)

nsTextFrame.cpp:1900 is
   if ((ip[mContentLength] - mContentOffset) < textLength) {
ip[mContentLength] was the uninitialized part.
I forgot to mention this sems to be gtk1-only.  And nightly builds seem immune
to the crash.
Keywords: testcase
This occurs in my gtk2 build.
The fixes for bug 252970 seem to have fixed this bug as well. If you can
reproduce the crash and you're seeing the stacktrace in attachment 188693 [details],
please reopen.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Summary: Crash @ [ConvertUnicharToUCS4] → Crash [@ ConvertUnicharToUCS4]
*** Bug 312782 has been marked as a duplicate of this bug. ***
Reopening based on the stack in bug 312782.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
This is probably not happening again on the trunk and RC1 - because they have
the fix from bug 307875 which protects against such crashes once for all.
Adam, generally, same or similar stack does not necessarily mean same bug, esp.
if the testcases in one bug are fixed...
Sorry for the trouble. I should have verified this myself in the latest builds
before reopening.
Status: REOPENED → RESOLVED
Closed: 19 years ago19 years ago
Resolution: --- → FIXED
Crash Signature: [@ ConvertUnicharToUCS4]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: