Closed Bug 183639 Opened 23 years ago Closed 23 years ago

Crash |delete datasource| in NS_NewRDFInMemoryDataSource

Categories

(Core Graveyard :: RDF, defect)

x86
Linux
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timeless, Assigned: timeless)

Details

(Keywords: crash)

Attachments

(2 files, 5 obsolete files)

debug cvs build (phroggy, linux, gtk) from this afternoon timeless@boffo:/public/temp/obj-i686-pc-linux-gnu-gtk/dist/bin$ ./run-mozilla.sh -g ./xpcshell 155192.js contains the script from bug 155192 comment 0 because simford and i encountered a crash that matches that stack so i'm about to reopen it... (gdb) r 155192.js Starting program: /mnt/hda3/temp/obj-i686-pc-linux-gnu-gtk/js/src/xpconnect/shell/xpcshell 155192.js GLib-CRITICAL **: file ghash.c: line 138 (g_hash_table_lookup): assertion `hash_table != NULL' failed. Gtk-WARNING **: gtk_type_create(): unknown parent type `21'. GLib-CRITICAL **: file ghash.c: line 138 (g_hash_table_lookup): assertion `hash_table != NULL' failed. GLib-CRITICAL **: file ghash.c: line 152 (g_hash_table_insert): assertion `hash_table != NULL' failed. Gtk-WARNING **: invalid class type `GtkInvisible' in cast to `(unknown)' GLib-CRITICAL **: file ghash.c: line 138 (g_hash_table_lookup): assertion `hash_table != NULL' failed. Gtk-WARNING **: gtk_type_create(): unknown parent type `21'. Gtk-CRITICAL **: file gtkwidget.c: line 4871 (gtk_widget_ref): assertion `GTK_IS_WIDGET (widget)' failed. Gtk-WARNING **: invalid class type `GtkInvisible' in cast to `(unknown)' Gtk-CRITICAL **: file gtkobject.c: line 457 (gtk_object_sink): assertion `GTK_IS_OBJECT (object)' failed. GLib-CRITICAL **: file ghash.c: line 138 (g_hash_table_lookup): assertion `hash_table != NULL' failed. Gtk-WARNING **: gtk_type_create(): unknown parent type `21'. Gtk-CRITICAL **: file gtkwidget.c: line 1641 (gtk_widget_realize): assertion `GTK_IS_WIDGET (widget)' failed. Gtk-WARNING **: invalid class type `GtkInvisible' in cast to `(unknown)' Gtk-CRITICAL **: file gtksignal.c: line 725 (gtk_signal_connect): assertion `GTK_IS_OBJECT (object)' failed. Gtk-WARNING **: invalid class type `GtkInvisible' in cast to `(unknown)' Gtk-CRITICAL **: file gtksignal.c: line 725 (gtk_signal_connect): assertion `GTK_IS_OBJECT (object)' failed. Program received signal SIGSEGV, Segmentation fault. 0x403606e0 in __morecore () from /lib/libc.so.6 (gdb) where #0 0x403606e0 in __morecore () from /lib/libc.so.6 #1 0x4095c27d in NS_NewRDFInMemoryDataSource (aOuter=0x0, aIID=@0xbfffdbb0, aResult=0xbfffdbac) at /mnt/hda3/temp/mozilla/rdf/base/src/nsInMemoryDataSource.cpp:867 #2 0x401671f3 in nsGenericFactory::CreateInstance (this=0x80f4d80, aOuter=0x0, aIID=@0xbfffdbb0, aResult=0xbfffdbac) at /mnt/hda3/temp/mozilla/xpcom/glue/nsGenericFactory.cpp:84 #3 0x4012313e in nsComponentManagerImpl::CreateInstance (this=0x8052d58, aClass=@0x81fe72c, aDelegate=0x0, aIID=@0xbfffdbb0, aResult=0xbfffdbac) at /mnt/hda3/temp/mozilla/xpcom/components/nsComponentManager.cpp:1816 #4 0x40127060 in nsComponentManager::CreateInstance (aClass=@0x81fe72c, aDelegate=0x0, aIID=@0xbfffdbb0, aResult=0xbfffdbac) at /mnt/hda3/temp/mozilla/xpcom/components/nsComponentManagerObsolete.cpp:102 #5 0x4039ae8d in nsJSCID::CreateInstance (this=0x81fe718, _retval=0xbfffdd7c) at /mnt/hda3/temp/mozilla/js/src/xpconnect/src/xpcjsid.cpp:793 #6 0x40146338 in XPTC_InvokeByIndex () from ./libxpcom.so #7 0x403aa765 in XPCWrappedNative::CallMethod (ccx=@0xbfffde48, mode=CALL_METHOD) at /mnt/hda3/temp/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp:2016 #8 0x403b0a05 in XPC_WN_CallMethod (cx=0x80b3490, obj=0x81bc580, argc=1, argv=0x80ceb7c, vp=0xbfffdf64) at /mnt/hda3/temp/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:1294 #9 0x40049112 in js_Invoke (cx=0x80b3490, argc=1, flags=0) at /mnt/hda3/temp/mozilla/js/src/jsinterp.c:839 #10 0x400507a5 in js_Interpret (cx=0x80b3490, result=0xbfffe284) at /mnt/hda3/temp/mozilla/js/src/jsinterp.c:2803 #11 0x40049597 in js_Execute (cx=0x80b3490, chain=0x808acc0, script=0x80cea08, down=0x0, special=0, result=0xbfffe284) at /mnt/hda3/temp/mozilla/js/src/jsinterp.c:1020 #12 0x40029b09 in JS_ExecuteScript (cx=0x80b3490, obj=0x808acc0, script=0x80cea08, rval=0xbfffe284) at /mnt/hda3/temp/mozilla/js/src/jsapi.c:3277 #13 0x0804a5f6 in Process (cx=0x80b3490, obj=0x808acc0, filename=0xbffff53d "155192.js", filehandle=0x0) at /mnt/hda3/temp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:479 #14 0x0804abc4 in ProcessArgs (cx=0x80b3490, obj=0x808acc0, argv=0xbffff3b8, argc=1) at /mnt/hda3/temp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:639 #15 0x0804b32c in main (argc=1, argv=0xbffff3b8) at /mnt/hda3/temp/mozilla/js/src/xpconnect/shell/xpcshell.cpp:912 #16 0x4025e17d in __libc_start_main () from /lib/libc.so.6 timeless@boffo:~/mozilla/netwerk$ free total used free shared buffers cached Mem: 513068 509816 3252 0 4052 136880 -/+ buffers/cache: 368884 144184 Swap: 0 0 0 timeless@boffo:~/mozilla/netwerk$ free -m total used free shared buffers cached Mem: 501 497 3 0 3 132 -/+ buffers/cache: 361 139 Swap: 0 0 0 I have lots of dead or partially dead mozilla/viewer/xpcshell's living in gdb's on phroggy's box. drepper: so um, is __morecore buggy? Linux boffo 2.4.18 #9 SMP Fri Nov 22 20:06:15 PST 2002 i686 unknown
> drepper: so um, is __morecore buggy? I very much doubt it. Like all memory allocators the state of glibc's malloc is fragile. Overwriting the wron byte leads to desaster. As a (welcome) sideeffect of the design is glibc's malloc you'll see crashes at the slightest disturbence. This prevent bugs in the long run. What I expect is that somewhere a buffer overflowed. I suggest using valgrind or some other form of memory debugging.
up one level to look at the thing being deleted: (gdb) p datasource $1 = (InMemoryDataSource *) 0x81fe868 (gdb) p *datasource $2 = {<nsIRDFDataSource> = {<nsISupports> = { _vptr. = 0x40360688}, <No data fields>}, <nsIRDFInMemoryDataSource> = {<nsISupports> = { _vptr. = 0x40360688}, <No data fields>}, <nsIRDFPurgeableDataSource> = {<nsISupports> = { _vptr. = 0x4097e780}, <No data fields>}, mAllocator = {mPool = {first = {next = 0x0, base = 136308872, limit = 136308872, avail = 136308872}, current = 0x81fe874, arenasize = 1072, mask = 7}, mBuckets = 0x81fe930}, mForwardArcs = {ops = 0x40173ea0, data = 0x0, hashShift = 28, maxAlphaFrac = 192 'À', minAlphaFrac = 64 '@', entrySize = 12, entryCount = 0, removedCount = 0, generation = 0, entryStore = 0x81fed40 "\210\0066@\210\0066@"}, mReverseArcs = {ops = 0x40173ea0, data = 0x0, hashShift = 28, maxAlphaFrac = 192 'À', minAlphaFrac = 64 '@', entrySize = 12, entryCount = 0, removedCount = 0, generation = 0, entryStore = 0x81fee08 ""}, mObservers = {<nsCOMPtr_base> = { mRawPtr = 0x81feed0}, <No data fields>}, mNumObservers = 0, mRefCnt = {mValue = 1}, fOuter = 0x81fe8e4, fAggregated = {<nsISupports> = {_vptr. = 0x4097e830}, <No data fields>}} fwiw i reproduced this once so we're going to claim it's a real bug
Status: UNCONFIRMED → ASSIGNED
Component: Browser-General → RDF
Ever confirmed: true
QA Contact: asa → tever
Summary: Crash [@ __morecore] (really out of memory) → Crash |delete datasource| in NS_NewRDFInMemoryDataSource
Attached patch Patch (from Timeless) (obsolete) — — Splinter Review
I ran this under Purify, and started to hit the two cases below: [E] NPR: NULL pointer read in nsViewManager::~nsViewManager(void) {1 occurrence} EXU: Unhandled exception in nsViewManager::~nsViewManager(void) {1 occurrence} Timeless says those are other bugs (obviously, by the stack), which seems to indicate that I've cleared the other crash.
Attachment #108539 - Flags: superreview+
Comment on attachment 108539 [details] [diff] [review] Patch (from Timeless) The patch from timeless will cause RDF's in-memory datasource to leak. Consult the lines of code after Init() in NS_NewRDFInMemoryDataSource()
Attachment #108539 - Flags: review-
Attached patch A possible solution (obsolete) — — Splinter Review
Here's what I saw. The Aggregatted QI failed and I think that's the key. The subsequent release on fAggregated freed datasource, the next if statement falls through and doesn't return since the QI failed, and then the delete on datasource occurs and crashes because the thing has already been deleted. So I took out the if, and just returned. This seems the correct thing to do, since if the AggregatedQI failed, it should have set result to null, and it should be just time to return. But I haven't looked at all the relationships, and someone familiar with the code needs to verify this is a proper fix or devise a correct fix.
Attachment #108539 - Attachment is obsolete: true
Comment on attachment 108565 [details] [diff] [review] A possible solution Just return'ing is bad becaue if AggregatedQueryInterface() fails and you merely return, you leak the InMemoryDataSource() that was created just prior. Try this: Set a breakpoint at AggregatedQueryInterface(), step into it (it is a trivial method) when it fires, and see if it is failing due to "fAggregated" being NULL.
Attachment #108565 - Flags: review-
It's failing because the IID passed in isn't recognized. That's why the release of fAggregated cleans up datasource, the addref in the AggregatedQI never occured, and why I suggested returning for both error and success at that point. There are only two error paths out of AggregatedQI that I could see. One is if the out parameter's pointer is null, the other is if the IID passed in isn't recognized, there doesn't appear to be any test of fAggregated, and in this case it's not null anyway. Both error paths don't increment the reference count. The bottom line, is that datasource is deleted during the release call after AggregatedQueryInterface. If relying on release to cleanup on error condition isn't the answer, then there's a problem in the reference system between datasource and it's aggregation, at least in error conditions. And that's beyond my resources to deal with.
Attachment #108531 - Attachment is obsolete: true
Attachment #108532 - Attachment is obsolete: true
Attachment #108533 - Attachment is obsolete: true
Attachment #108565 - Attachment is obsolete: true
Attached file testcase —
timeless@boffo:/public/temp/obj-i686-pc-linux-gnu-gtk/dist/bin$ ./run-mozilla.sh ./xpcshell 183639.js [xpconnect wrapped nsISupports] uncaught exception: [Exception... "Component returned failure code: 0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE) [nsIJSCID.createInstance]" nsresult: "0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE)" location: "JS frame :: 183639.js :: <TOP_LEVEL> :: line 5" data: no] timeless@boffo:/public/temp/obj-i686-pc-linux-gnu-gtk/dist/bin$
Attachment #108610 - Flags: review?(rjc)
Comment on attachment 108610 [details] [diff] [review] third time's the charm? r=rjc OK, the flow looks acceptable
Attachment #108610 - Flags: review?(rjc) → review+
Attachment #108610 - Flags: superreview?(roc+moz)
Comment on attachment 108610 [details] [diff] [review] third time's the charm? >@@ -842,6 +842,7 @@ > NS_PRECONDITION(aResult != nsnull, "null ptr"); > if (! aResult) > return NS_ERROR_NULL_POINTER; No need for this null check (just the NS_PRECONDITION is enough). > datasource->fAggregated.AddRef(); > rv = datasource->AggregatedQueryInterface(aIID, aResult); // This'll AddRef() > datasource->fAggregated.Release(); I'm not convinced these extra AddRef and Release are needed (I didn't look beyond this function, though), but that's a separate issue, so leave them for now... sr=dbaron.
Attachment #108610 - Flags: superreview?(roc+moz) → superreview+
checked in (dbaron was ok w/ me not removing the if check -- we can file a new bug to remove it, it took me a bit but i finally understood why bz/dbaron wanted it removed).
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
tever is not RDF QA anymore
QA Contact: tever → nobody
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: