After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733957 - Shell search provider crashes in gcr_collection_contains()
Shell search provider crashes in gcr_collection_contains()
Status: RESOLVED FIXED
Product: seahorse
Classification: Applications
Component: general
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: Seahorse Maintainer
Seahorse Maintainer
Depends on:
Blocks:
 
 
Reported: 2014-07-30 06:09 UTC by Branko Grubic (bitlord)
Modified: 2014-09-23 08:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bt (22.44 KB, text/plain)
2014-07-30 06:09 UTC, Branko Grubic (bitlord)
  Details
search-provider: Comment about hacky stuff going on with scanf (1.03 KB, patch)
2014-07-30 13:53 UTC, Stef Walter
none Details | Review
search-provider: Don't assume handles are still valid (4.48 KB, patch)
2014-07-30 15:52 UTC, Stef Walter
committed Details | Review
backported_fix_crash (1.21 KB, text/plain)
2014-08-28 06:05 UTC, Branko Grubic (bitlord)
  Details
bt (6.28 KB, text/plain)
2014-09-22 20:56 UTC, Branko Grubic (bitlord)
  Details

Description Branko Grubic (bitlord) 2014-07-30 06:09:26 UTC
Created attachment 281996 [details]
bt

Crash, search provider related? 

If you need more info, or more debug symbols installed, I can probably do it.
Comment 1 Stef Walter 2014-07-30 13:53:01 UTC
Created attachment 282067 [details] [review]
search-provider: Comment about hacky stuff going on with scanf
Comment 2 Stef Walter 2014-07-30 15:33:19 UTC
Comment on attachment 282067 [details] [review]
search-provider: Comment about hacky stuff going on with scanf

I was going to fix this in gcr ... but actually lets just fix it properly in seahorse.
Comment 3 Stef Walter 2014-07-30 15:52:50 UTC
Created attachment 282089 [details] [review]
search-provider: Don't assume handles are still valid

We were crashing when we got back search provider handles from
the shell for objects that no longer existed.

We can't just call gcr_collection_contains() as it assumes that
it's receiving a valid GObject.

So hold a table of all the handles we've returned and update
it via weak references.
Comment 4 Stef Walter 2014-07-30 15:53:18 UTC
Giovanni, could you review this patch?
Comment 5 Giovanni Campagna 2014-07-30 16:32:50 UTC
Review of attachment 282089 [details] [review]:

At some point I had a patch that used mincore() to check if a pointer was valid or not. I suppose this is a better idea in terms of readability and reliability, at the expense of increased memory usage. Looks good to me anyway.
Comment 6 Stef Walter 2014-07-30 16:37:13 UTC
(In reply to comment #5)
> Review of attachment 282089 [details] [review]:
> 
> At some point I had a patch that used mincore() to check if a pointer was valid
> or not. 

Hmmm, there would still be corner cases when that would return invalid results. For example the pointer could be near the end of a page, and the next page might not be mapped in. Or the pointer could be to garbage, and then G_IS_OBJECT() (or similar) would dereferece yet another bad pointer.

> I suppose this is a better idea in terms of readability and
> reliability, at the expense of increased memory usage. Looks good to me anyway.

OK. Thanks for reviewing it. Will merge.
Comment 7 Stef Walter 2014-07-30 16:38:44 UTC
Attachment 282089 [details] pushed as 073a958 - search-provider: Don't assume handles are still valid
Comment 8 Branko Grubic (bitlord) 2014-08-28 06:05:00 UTC
Created attachment 284656 [details]
backported_fix_crash

For now I won't reopen this (maybe I should file another report?).
This bugfix was backported to 3.10.x in fedora 20 ( https://admin.fedoraproject.org/updates/seahorse-3.10.2-2.fc20 ), I tested the update and search provider works, it finds my gpg key (only key which is trusted in my keyring), but when I click on it, seahorse segfaults. I'll attach backtrace, but no symbols currently, I can install them if needed.
Comment 9 Stef Walter 2014-09-01 07:24:00 UTC
Symbols would indeed be helpful. Thanks.
Comment 10 Branko Grubic (bitlord) 2014-09-22 20:56:23 UTC
Created attachment 286842 [details]
bt

Sorry for late answer on this issue, I didn't have time to do it, and I upgraded to f21 (where seahorse search provider doesn't work (didn't reported that)).

And now I set up a VM with f20, and actually that crash from comment #8 is probably unrelated to changes done about random crashes ... which you fixed. Because I can reproduce it with regular f20 seahorse package without backports.
So this is data from f20 seahorse package without fixes mentioned in this bug report (that package got unpushed form updates-testing (I can get same trace from it too (find it in koji ...)), and probably this should go to another bug report. 

Same situation, search for a gpg key, click on it, and it crashes. (I'm not an expert in getting traces, looks like some symbols are missing, but I installed them with 'debuginfo-install seahorse')
Comment 11 Branko Grubic (bitlord) 2014-09-22 21:12:34 UTC
Sorry for this noise, I was looking at the code (3.10 branch) and if I'm not wrong it crashes in this line 'window = GTK_WINDOW (seahorse_widget_get_widget (key_manager, key_manager->name));' and it does that because 'key_manager' is NULL (0x0)?

in gdb, "after" the crash, if I say 
p key_manager it says
$1 = (SeahorseWidget *) 0x0
so it actually fails at both code paths to "get" 'key_manager'?  

(Again sorry for this, I want to learn more, just I'm too limited)
Comment 12 Stef Walter 2014-09-23 07:33:06 UTC
(In reply to comment #11)
> Sorry for this noise, I was looking at the code (3.10 branch) and if I'm not
> wrong it crashes in this line 'window = GTK_WINDOW (seahorse_widget_get_widget
> (key_manager, key_manager->name));' and it does that because 'key_manager' is
> NULL (0x0)?
> 
> in gdb, "after" the crash, if I say 
> p key_manager it says
> $1 = (SeahorseWidget *) 0x0
> so it actually fails at both code paths to "get" 'key_manager'?  

Indeed. Looks like a different crash. Another bug with a backtrace would be most appreciated.
Comment 13 Branko Grubic (bitlord) 2014-09-23 08:04:36 UTC
filled bug #737153