<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>9476</bug_id>
          
          <creation_ts>2006-06-16 18:58:17 -0700</creation_ts>
          <short_desc>REGRESSION: Reproducible crash after closing window after viewing css2.1/t0803-c5501-imrgn-t-00-b-ag.html</short_desc>
          <delta_ts>2006-06-17 04:15:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction, Regression</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adele</cc>
    
    <cc>ggaren</cc>
    
    <cc>mjs</cc>
    
    <cc>timothy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>46009</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-16 18:58:17 -0700</bug_when>
    <thetext>I believe this may be a regression from Bug 7080.

Steps to Reproduce:

1. Open WebKit+Safari.
2. Open LayoutTests/css2.1/t0803-c5501-imrgn-t-00-b-ag.html
3. Close the browser window.
4. WebKit+Safari crashes.

Relevant part of stack trace:

Date/Time:      2006-06-16 20:51:52.614 -0500
OS Version:     10.4.6 (Build 8I127)
Report Version: 4

Command: Safari
Path:    /Applications/Safari.app/Contents/MacOS/Safari
Parent:  bash [263]

Version:        2.0.3 (417.9.3)
Build Version:  2
Project Name:   WebBrowser
Source Version: 4170903

PID:    25147
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x6f6e546f

Thread 0 Crashed:
0   com.apple.JavaScriptCore       	0x0101578c KJS::Debugger::detach(KJS::Interpreter*) + 140 (debugger.cpp:79)
1   com.apple.JavaScriptCore       	0x01023c40 KJS::Interpreter::~Interpreter [not-in-charge]() + 240 (interpreter.cpp:264)
2   com.apple.WebCore              	0x01a6b694 KJS::ScriptInterpreter::~ScriptInterpreter [in-charge deleting]() + 64 (kjs_binding.cpp:75)
3   com.apple.WebCore              	0x01a894a4 WebCore::KJSProxy::~KJSProxy [in-charge]() + 92 (kjs_proxy.cpp:48)
4   com.apple.WebCore              	0x01c02644 WebCore::FramePrivate::~FramePrivate [in-charge]() + 116 (FramePrivate.h:112)
5   com.apple.WebCore              	0x01869e0c WebCore::Frame::~Frame [not-in-charge]() + 1076 (Frame.cpp:221)
6   com.apple.WebCore              	0x0187f120 WebCore::FrameMac::~FrameMac [in-charge deleting]() + 248 (FrameMac.mm:173)
7   com.apple.WebCore              	0x01bae92c WebCore::Shared&lt;WebCore::Frame&gt;::deref() + 144 (Shared.h:32)
8   com.apple.WebCore              	0x01bae980 WTF::RefPtr&lt;WebCore::Frame&gt;::~RefPtr [in-charge]() + 64 (RefPtr.h:41)
9   com.apple.WebCore              	0x0198ecc4 WebCore::Page::~Page [in-charge]() + 340 (Page.cpp:63)
10  com.apple.WebCore              	0x018af8f0 -[WebCorePageBridge dealloc] + 64 (WebCorePageBridge.mm:83)
11  com.apple.WebKit               	0x0039811c -[WebView(WebPrivate) _close] + 224 (WebView.m:575)
12  com.apple.Safari               	0x00047d2c 0x1000 + 290092
13  com.apple.Foundation           	0x9297d5e8 -[NSArray makeObjectsPerformSelector:withObject:] + 264
14  com.apple.Safari               	0x0005c608 0x1000 + 374280
15  com.apple.Safari               	0x0005a9c8 0x1000 + 367048
16  com.apple.Foundation           	0x92975ad8 _nsnote_callback + 180
17  com.apple.CoreFoundation       	0x9080b010 __CFXNotificationPost + 368
18  com.apple.CoreFoundation       	0x908030ec _CFXNotificationPostNotification + 684
19  com.apple.Foundation           	0x9295fee0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
20  com.apple.AppKit               	0x937c1820 -[NSWindow _close] + 100
21  com.apple.AppKit               	0x937c1784 -[NSWindow close] + 36
22  com.apple.Safari               	0x0005a96c 0x1000 + 366956
23  com.apple.Safari               	0x0005c498 0x1000 + 373912
24  com.apple.AppKit               	0x937c0ff0 -[NSApplication sendAction:to:from:] + 108
25  com.apple.Safari               	0x00029adc 0x1000 + 166620
26  com.apple.AppKit               	0x937c0f24 -[NSControl sendAction:to:] + 96
27  com.apple.AppKit               	0x937c0e04 -[NSCell _sendActionFrom:] + 156
28  com.apple.AppKit               	0x937c08e4 -[NSButtonCell performClick:] + 472
29  com.apple.AppKit               	0x937c0ff0 -[NSApplication sendAction:to:from:] + 108
30  com.apple.Safari               	0x00029adc 0x1000 + 166620
31  com.apple.AppKit               	0x9381b838 -[NSMenu performActionForItemAtIndex:] + 392
32  com.apple.AppKit               	0x9381b5bc -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 104
33  com.apple.AppKit               	0x9381b064 -[NSMenu performKeyEquivalent:] + 272
34  com.apple.AppKit               	0x9381acb0 -[NSApplication _handleKeyEquivalent:] + 328
35  com.apple.AppKit               	0x937247a8 -[NSApplication sendEvent:] + 2944
36  com.apple.Safari               	0x000217a8 0x1000 + 133032
37  com.apple.AppKit               	0x9371c0b0 -[NSApplication run] + 508
38  com.apple.AppKit               	0x9380cbfc NSApplicationMain + 452
39  com.apple.Safari               	0x0005cb98 0x1000 + 375704
40  com.apple.Safari               	0x0005ca40 0x1000 + 375360</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46010</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-16 19:08:19 -0700</bug_when>
    <thetext>Trying a clean build.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46011</commentid>
    <comment_count>2</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2006-06-16 19:32:23 -0700</bug_when>
    <thetext>This code is now being exercised by my debugger change in r14890. Debug builds attach a debugger that can be accessed from another process if needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46012</commentid>
    <comment_count>3</comment_count>
      <attachid>8875</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2006-06-16 20:54:27 -0700</bug_when>
    <thetext>Created attachment 8875
Speculative Patch

We think the problem is that the code deletes an item in a linked list without fixing up the previous item&apos;s next pointer. Speculative patch attached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46013</commentid>
    <comment_count>4</comment_count>
      <attachid>8875</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2006-06-16 21:03:00 -0700</bug_when>
    <thetext>Comment on attachment 8875
Speculative Patch

That&apos;ll teach me to debug without a build. *p = q-&gt;next fixes up the previous item&apos;s next pointer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46015</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-16 21:47:49 -0700</bug_when>
    <thetext>For my simple test case in Comment #0, what&apos;s happening is that KJS::Debugger::~Debugger() gets called *first* which calls detach(0), then KJS::Interpreter::~Interpreter() gets called *second* which calls detach(this), which by that time has already had its debugger detached (and thus bad pointers are dereferenced).

The while() loop in detach() doesn&apos;t call setDebugger(0) on every Debugger it destroys, so some Interpreters will think they still need to destroy theirs.

The solution is to call setDebugger(0) on every Interpreter that is destroyed regardless of whether it&apos;s &quot;ours&quot; or not.  The initial code in detach() is therefore no longer needed.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46016</commentid>
    <comment_count>6</comment_count>
      <attachid>8876</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-16 21:57:36 -0700</bug_when>
    <thetext>Created attachment 8876
Patch v1

Patch v1 does what I said to do in Comment #5.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46020</commentid>
    <comment_count>7</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-16 23:04:59 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Patch v1 does what I said to do in Comment #5.

All tests pass except as noted in Bug 9477 and Bug 9478, which are different causes.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46021</commentid>
    <comment_count>8</comment_count>
      <attachid>8876</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2006-06-16 23:25:10 -0700</bug_when>
    <thetext>Comment on attachment 8876
Patch v1

The word &quot;interpreter&quot; is a little confused here. We&apos;re not deleting interpreters. Rather, we&apos;re deleting nodes in a linked list of interpreters, leaving the interpreters themselves around.

A better description might be, &quot;Call setDebugger(0) for all interpreters removed from the &apos;attached to a debugger&apos; list.&quot;

Anyway, patch=good, r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46064</commentid>
    <comment_count>9</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-17 03:43:30 -0700</bug_when>
    <thetext>Committed revision 14896.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46065</commentid>
    <comment_count>10</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-17 03:44:04 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; A better description might be, &quot;Call setDebugger(0) for all interpreters
&gt; removed from the &apos;attached to a debugger&apos; list.&quot;

FWIW, I fixed up the comment in the ChangeLog to the above before I committed.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46075</commentid>
    <comment_count>11</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2006-06-17 04:15:50 -0700</bug_when>
    <thetext>Something was bothering me about KJS::Debugger::detach()--if the code always updated the linked list (whose head was &apos;rep-&gt;interps&apos;) correctly, then why did the second call to detach fail with a bad pointer dereference?

The answer is that KJS::Debugger::~Debugger() deletes &apos;rep&apos; itself after calling detach(0), thus &apos;&amp;rep-&gt;interps&apos; will point to something invalid the next time detach() is called.
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>8875</attachid>
            <date>2006-06-16 20:54:27 -0700</date>
            <delta_ts>2006-06-16 21:57:36 -0700</delta_ts>
            <desc>Speculative Patch</desc>
            <filename>patch.txt</filename>
            <type>text/plain</type>
            <size>1044</size>
            <attacher name="Geoffrey Garen">ggaren</attacher>
            
              <data encoding="base64">SW5kZXg6IGRlYnVnZ2VyLmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBkZWJ1Z2dlci5jcHAJKHJldmlzaW9u
IDE0ODY2KQorKysgZGVidWdnZXIuY3BwCSh3b3JraW5nIGNvcHkpCkBAIC02OCwxOSArNjgsMjMg
QEAKIAogdm9pZCBEZWJ1Z2dlcjo6ZGV0YWNoKEludGVycHJldGVyKiBpbnRlcnApCiB7Ci0gIGlm
IChpbnRlcnAgJiYgaW50ZXJwLT5kZWJ1Z2dlcigpID09IHRoaXMpCisgIGlmIChpbnRlcnApIHsK
KyAgICBBU1NFUlQoaW50ZXJwLT5kZWJ1Z2dlcigpID09IHRoaXMpOwogICAgIGludGVycC0+c2V0
RGVidWdnZXIoMCk7CisgIH0KIAotICAvLyBpdGVyYXRlIHRoZSBhZGRyZXNzZXMgd2hlcmUgQXR0
YWNoZWRJbnRlcnByZXRlciBwb2ludGVycyBhcmUgc3RvcmVkCi0gIC8vIHNvIHdlIGNhbiB1bmxp
bmsgaXRlbXMgZnJvbSB0aGUgbGlzdAotICBBdHRhY2hlZEludGVycHJldGVyICoqcCA9ICZyZXAt
PmludGVycHM7Ci0gIEF0dGFjaGVkSW50ZXJwcmV0ZXIgKnE7Ci0gIHdoaWxlICgocSA9ICpwKSkg
ewotICAgIGlmICghaW50ZXJwIHx8IHEtPmludGVycCA9PSBpbnRlcnApIHsKLSAgICAgICpwID0g
cS0+bmV4dDsKLSAgICAgIGRlbGV0ZSBxOworICBBdHRhY2hlZEludGVycHJldGVyKiBjdXJyZW50
ID0gcmVwLT5pbnRlcnBzOworICBBdHRhY2hlZEludGVycHJldGVyKiBwcmV2ID0gMDsKKyAgd2hp
bGUgKGN1cnJlbnQpIHsKKyAgICBpZiAoIWludGVycCB8fCBwLT5pbnRlcnAgPT0gaW50ZXJwKSB7
CisgICAgICBBdHRhY2hlZEludGVycHJldGVyKiB0bXAgPSBjdXJyZW50LT5uZXh0OworICAgICAg
ZGVsZXRlIGN1cnJlbnQ7CisgICAgICBjdXJyZW50ID0gdG1wOworICAgICAgaWYgKHByZXYpCisg
ICAgICAgICAgcHJldi0+bmV4dCA9IHRtcDsKICAgICB9IGVsc2UgewotICAgICAgcCA9ICZxLT5u
ZXh0OworICAgICAgcHJldiA9IGN1cnJlbnQ7CisgICAgICBjdXJyZW50ID0gY3VycmVudC0+bmV4
dDsKICAgICB9CiAgIH0KIH0K
</data>
<flag name="review"
          id="2589"
          type_id="1"
          status="-"
          setter="ggaren"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>8876</attachid>
            <date>2006-06-16 21:57:36 -0700</date>
            <delta_ts>2006-06-16 23:25:10 -0700</delta_ts>
            <desc>Patch v1</desc>
            <filename>bug-9476-v1.diff</filename>
            <type>text/plain</type>
            <size>1505</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">SW5kZXg6I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mV2aXNpb24gMTQ4OTUpCisrKyBKYXZh
U2NyaXB0Q29yZS9ranMvZGVidWdnZXIuY3BwCSh3b3JraW5nIGNvcHkpCkBAIC02OCw5ICs2OCw2
IEBAIHZvaWQgRGVidWdnZXI6OmF0dGFjaChJbnRlcnByZXRlciogaW50ZXIKIAogdm9pZCBEZWJ1
Z2dlcjo6ZGV0YWNoKEludGVycHJldGVyKiBpbnRlcnApCiB7Ci0gIGlmIChpbnRlcnAgJiYgaW50
ZXJwLT5kZWJ1Z2dlcigpID09IHRoaXMpCi0gICAgaW50ZXJwLT5zZXREZWJ1Z2dlcigwKTsKLQog
ICAvLyBpdGVyYXRlIHRoZSBhZGRyZXNzZXMgd2hlcmUgQXR0YWNoZWRJbnRlcnByZXRlciBwb2lu
dGVycyBhcmUgc3RvcmVkCiAgIC8vIHNvIHdlIGNhbiB1bmxpbmsgaXRlbXMgZnJvbSB0aGUgbGlz
dAogICBBdHRhY2hlZEludGVycHJldGVyICoqcCA9ICZyZXAtPmludGVycHM7CkBAIC03OCwxMCAr
NzUsMTAgQEAgdm9pZCBEZWJ1Z2dlcjo6ZGV0YWNoKEludGVycHJldGVyKiBpbnRlcgogICB3aGls
ZSAoKHEgPSAqcCkpIHsKICAgICBpZiAoIWludGVycCB8fCBxLT5pbnRlcnAgPT0gaW50ZXJwKSB7
CiAgICAgICAqcCA9IHEtPm5leHQ7CisgICAgICBxLT5pbnRlcnAtPnNldERlYnVnZ2VyKDApOwog
ICAgICAgZGVsZXRlIHE7Ci0gICAgfSBlbHNlIHsKKyAgICB9IGVsc2UKICAgICAgIHAgPSAmcS0+
bmV4dDsKLSAgICB9CiAgIH0KIH0KIAo=
</data>
<flag name="review"
          id="2590"
          type_id="1"
          status="+"
          setter="ggaren"
    />
          </attachment>
      

    </bug>

</bugzilla>