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 667114 - Missing check for valid GSocket in g_socket_condition_check()
Missing check for valid GSocket in g_socket_condition_check()
Status: RESOLVED DUPLICATE of bug 667245
Product: glib
Classification: Platform
Component: gio
2.31.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-01-02 07:31 UTC by Thierry Reding
Modified: 2012-01-05 11:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] GSocket: Check for a valid socket in g_socket_condition_check (1.04 KB, patch)
2012-01-02 07:31 UTC, Thierry Reding
rejected Details | Review

Description Thierry Reding 2012-01-02 07:31:41 UTC
Created attachment 204435 [details] [review]
[PATCH] GSocket: Check for a valid socket in g_socket_condition_check

g_socket_condition_check() is missing a check for a valid (!= NULL)
GSocket. Other functions already have this check.

Besides the g_socket_condition_check() function, there are others
which are missing the check. Should I submit a patch to add it as
well, or should this rather be added as bugs are reported?
Comment 1 Dan Winship 2012-01-03 17:16:01 UTC
Comment on attachment 204435 [details] [review]
[PATCH] GSocket: Check for a valid socket in g_socket_condition_check

>This patch fixes a bug

No, it doesn't. g_return_val_if_fail() means "this is never supposed to happen". It may get rid of a crash in the particular case you're seeing, but the underlying bug is still there and probably messing up other things.

(There probably ought to be a g_return_val_if_fail() there, and in another other public APIs that don't currently have one, for consistency, but it doesn't *fix* anything.)
Comment 2 Frederic Peters 2012-01-03 20:51:09 UTC
I just had epiphany segfault and tracked it to a crash related to this issue; maybe this will need to be reassigned to libsoup or epiphany.

274	  if (!socket->priv->inited)
(gdb) bt full
  • #0 check_socket
    at gsocket.c line 274
  • #1 g_socket_condition_check
    at gsocket.c line 2695
  • #2 soup_connection_get_state
    at soup-connection.c line 889
  • #3 soup_session_cleanup_connections
    at soup-session.c line 1742
  • #4 run_queue
    at soup-session-async.c line 453
  • #5 idle_run_queue
    at soup-session-async.c line 487
  • #6 g_idle_dispatch
    at gmain.c line 4632
  • #7 g_main_dispatch
    at gmain.c line 2513
  • #8 g_main_context_dispatch
    at gmain.c line 3050
  • #9 g_main_context_iterate
    at gmain.c line 3121
  • #10 g_main_context_iteration
    at gmain.c line 3182
  • #11 g_application_run
    at gapplication.c line 1599
  • #12 main
    at ephy-main.c line 472

Comment 3 Thierry Reding 2012-01-04 07:15:41 UTC
(In reply to comment #1)
> (From update of attachment 204435 [details] [review])
> >This patch fixes a bug
> 
> No, it doesn't. g_return_val_if_fail() means "this is never supposed to
> happen". It may get rid of a crash in the particular case you're seeing, but
> the underlying bug is still there and probably messing up other things.

You are right. "fixes a crash" would have been the correct wording. I can
change that in a follow-up patch.

I was actually hesitating to report this "bug" to GLib because it obviously
is caused by libsoup. Then again, I wasn't certain whether what libsoup was
doing wasn't a legitimate use of GSocket and if there really is a bug.

After reporting this to GLib I was going to write about this to the libsoup
mailing list, but then I saw that you were on the Cc list of this bug anyway
and didn't.

> (There probably ought to be a g_return_val_if_fail() there, and in another
> other public APIs that don't currently have one, for consistency, but it
> doesn't *fix* anything.)

Yes, as I mentioned there are others (I think 3 or 4) that don't have this
check. I can add them in a follow-up patch (perhaps along with the rewording
you mentioned).
Comment 4 Thierry Reding 2012-01-04 07:16:32 UTC
(In reply to comment #2)
> I just had epiphany segfault and tracked it to a crash related to this issue;
> maybe this will need to be reassigned to libsoup or epiphany.
> 
> 274      if (!socket->priv->inited)
> (gdb) bt full

That's exactly the same backtrace that I've been seeing. That segfault should
be fixed by the patch I posted earlier.
Comment 5 Dan Winship 2012-01-04 15:35:51 UTC
The epiphany crash is 667245. return-if-fails are being added to gsocket in bug 667225.

*** This bug has been marked as a duplicate of bug 667245 ***
Comment 6 Claudio Saavedra 2012-01-05 11:50:20 UTC
(In reply to comment #2)
> I just had epiphany segfault and tracked it to a crash related to this issue;
> maybe this will need to be reassigned to libsoup or epiphany.
> 
> 274      if (!socket->priv->inited)
> (gdb) bt full
> 

Fred, could you please follow up in bug 667245?