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 673273 - ephy-embed-prefs: check webkit_settings before using
ephy-embed-prefs: check webkit_settings before using
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-01 02:13 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2012-04-10 19:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ephy-embed-prefs: check webkit_settings before using (1.36 KB, patch)
2012-04-01 02:13 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
ephy-embed-single: do not handle ephy-embed-prefs (2.09 KB, patch)
2012-04-01 02:19 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review
ephy-embed-single-test: unref the created EphyShell (726 bytes, patch)
2012-04-02 10:47 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2012-04-01 02:13:35 UTC
See the attached patch comment. I seem to need this to prevent a crash
in EphyEmbedSingle tests:

TEST: test-ephy-embed-single... (pid=31942)
  /embed/ephy-embed-single/new:                                        OK
  /embed/ephy-embed-single/get_from_shell:                             OK
  /embed/ephy-embed-single/form_auth:                                  OK

(test-ephy-embed-single:31942): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed


In /new we create a EphyEmbedSingle and destroy it. Then we get the one from the shell, which is only a pointer to the one that was created in _ephy_shell_create_instance.

When we reach /form_auth, the g_object_unref that we called in /new has called ephy_embed_prefs_shutdown (), which means that webkit_settings no longer is valid. This causes the assertion fail.

I would prefer to move ephy_embed_prefs_init/shutdown somewhere else. Just like we use ephy_file_helpers_init/shutdown.

I don't know where would be the best place to put this though. I am tempted to use src/ephy-main.c

Anyway, filing this with this patch to raise the issue. I think the patch could be the worst-case solution if we want to keep everything "working" like now.
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2012-04-01 02:13:37 UTC
Created attachment 211056 [details] [review]
ephy-embed-prefs: check webkit_settings before using

ephy_embed_prefs_shutdown is called every time a EphyEmbedSingle is
finalized. In tests EphyEmbedSingle can be created multiple times, which
means that as soon as the first one finalizes ephy_embed_prefs_shutdown
is gonna operate on an invalid webkit_settings.

In the same spirit, protect ourselves from multiple calls to
ephy_embed_prefs_init by checking webkit_settings.
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2012-04-01 02:19:49 UTC
Created attachment 211058 [details] [review]
ephy-embed-single: do not handle ephy-embed-prefs

ephy-embed-prefs acts like a singleton.

Instead of calling init and shutdown in EphyEmbedSingle instances.
Handle it in ephy-main as a true init/shutdown API like
ephy-file-helpers.

----

Thought about it. I prefer this solution.
Comment 3 Xan Lopez 2012-04-02 10:17:58 UTC
First dumb comment from my side... this used to work, what changed?
Comment 4 Diego Escalante Urrelo (not reading bugmail) 2012-04-02 10:47:37 UTC
Created attachment 211123 [details] [review]
ephy-embed-single-test: unref the created EphyShell

This commit, correcting a forgotten unref, will trigger the problem
described in this bug.
Comment 5 Xan Lopez 2012-04-10 16:53:34 UTC
Review of attachment 211123 [details] [review]:

OK. May I use this opportunity to suggest again to write a ephy_test_init () ephy_test_shutdown () thing that does all this.
Comment 6 Xan Lopez 2012-04-10 16:58:32 UTC
Review of attachment 211058 [details] [review]:

OK.
Comment 7 Diego Escalante Urrelo (not reading bugmail) 2012-04-10 19:32:01 UTC
(In reply to comment #5)
> Review of attachment 211123 [details] [review]:
> 
> OK. May I use this opportunity to suggest again to write a ephy_test_init ()
> ephy_test_shutdown () thing that does all this.

Will look into that.
Comment 8 Diego Escalante Urrelo (not reading bugmail) 2012-04-10 19:36:08 UTC
Attachment 211058 [details] pushed as 27c169f - ephy-embed-single: do not handle ephy-embed-prefs
Attachment 211123 [details] pushed as bbb6e24 - ephy-embed-single-test: unref the created EphyShell