Closed Bug 424780 Opened 13 years ago Closed 12 years ago
Typing into <select> dropdown can cause ns
String Buffer leak
640 bytes, text/plain
15.71 KB, text/plain
203 bytes, text/html
3.24 KB, patch
|Details | Diff | Splinter Review|
4.01 KB, patch
|Details | Diff | Splinter Review|
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9b5pre) Gecko/2008032320 Firefox/3.0b5pre ID:2008032320 found this leak during running the Surf's up Test in Litmus. Steps to reproduce: -> Load https://litmus.mozilla.org/show_test.cgi?id=4390 -> Go to http://www.alabe.com/freechart/ -> Enter some Dates and -> on the following result site, move the Star Chart around -> Close Firefox --> Leaks nsStringBuffer Only small leak and so not requesting blocking. 0 TOTAL 25 8 10134557 1 ( 7427.45 +/- 5704.58) 21652820 1 ( 5026.63 +/- 7590.61)
Simpler steps: 1. Go to http://www.alabe.com/freechart/ 2. Enter "Los Angeles" and "California", leaving the dates alone. 3. Close Firefox.
Err, missed a "submit the form" step in there ;)
Actually, you don't need to submit the form. The leak involves the incremental typing feature of the <select> dropdown. Typing 'C' while the dropdown has focus is enough to trigger the leak. (I figured this out after looking at the leak log, which pointed at nsListControlFrame::KeyPress.)
Summary: Firefox leaks nsStringBuffer when i move the chart on http://www.alabe.com around → Typing into <select> dropdown can cause nsStringBuffer leak
Component: General → Layout: Form Controls
QA Contact: general → layout.form-controls
The leak log seems to implicate the "static nsString incrementalString;" that lives in nsListControlFrame::GetIncrementalString. I think this means you can only leak one of these at a time. http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/forms/nsListControlFrame.cpp&rev=1.436&mark=2496#2492 Is it a bug that this is a static variable rather than a member variable? Or would it be sufficient to add a "GetIncrementalString().Truncate();" somewhere?
To reproduce the leak: click the textbox, press Tab, press 'c', quit.
This should be a static nsString*, allocated and destroyed when we init/shutdown layout. imo.
yeah, static strings can crash XR apps rather easily too. We have an assertion that catches most of them, but apparently not this one...
Yeah, we're not going to catch that as the string isn't going to be initialized until the first time that function is called.
Sicking recommended allocating the nsString in nsListControlFrame::GetIncrementalString rather than when initing layout.
Bug 425068 prevents me from running mochitests locally, so I don't know whether the code that cares about sIncrementalString is covered by existing mochitests.
Jesse you should probably update the comment in the patch since those strings are not static..
Need to address the question raised in Comment #10 about whether or not we've test coverage for sIncrementalString. When requesting approvals, please: * Include an assessment of the risk associated with this patch. * Give a sentence or two why it's so important to take your patch this late in the release process. * Included tests so we don't have to ask for them.
Comment on attachment 311490 [details] [diff] [review] patch Please re-request approval once the question of test coverage is addressed.
So we don't really have tests for leaks yet. But I think what we should do is to add a mochitest that sends key events to a dropdown and checks that that results in the correct being selected. Once we do leak tests on mochitest that will catch this issue and in the meantime we're checking that the patch won't regress the functionality.
Assuming this is cross-platform code, once we use runtests.py on the OS X box and add a --leak-threshold=0 to the command to invoke Mochitests, we'll get orange if this were to break. Other platforms (including the recently added bm-pgo box, which uses runtests.py and would only need the addition of --leak-threshold) have different sets of leaks which prevent doing this there immediately, unfortunately.
> Jesse you should probably update the comment in the patch since those > strings are not static.. They're static members of the class (rather than per-instance members), but their values can change.
The mochitest currently fails due to script-generated events having timestamps in microseconds instead of milliseconds. See bug 238041. With my patch in that bug, the mochitest passes.
Depends on: 238041
I'm going to land this fix without the test, and file a new bug for landing the test (depends on bug 238041).
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.