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 710602 - soup_server_pause_message() should work before I/O begins
soup_server_pause_message() should work before I/O begins
Status: RESOLVED OBSOLETE
Product: libsoup
Classification: Core
Component: API
unspecified
Other All
: Normal minor
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2013-10-22 07:07 UTC by Philip Withnall
Modified: 2018-09-21 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
soup-message-io: Don’t assert on [un]pausing an unsent SoupMessage (2.79 KB, patch)
2013-10-22 07:13 UTC, Philip Withnall
rejected Details | Review
soup-server: Document restriction on SoupMessages given to SoupServer methods (1.73 KB, patch)
2013-10-23 07:59 UTC, Philip Withnall
reviewed Details | Review
soup-server: Document restriction on SoupMessages given to SoupServer methods (1.91 KB, patch)
2013-10-24 07:07 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2013-10-22 07:07:55 UTC
If you call soup_server_[un]pause_message() on a SoupMessage which didn’t come from a SoupServerCallback (e.g. one which has just been created using soup_message_new(), you get:

(process:28960): libsoup-CRITICAL **: soup_message_io_unpause: assertion 'io != NULL' failed

Patch coming up to downgrade the assertion to an if statement.
Comment 1 Philip Withnall 2013-10-22 07:13:08 UTC
Created attachment 257814 [details] [review]
soup-message-io: Don’t assert on [un]pausing an unsent SoupMessage

If a SoupMessage which hasn’t yet been sent is passed into
soup_server_[un]pause_message(), an assertion will fail in soup-message-io.c
because the message doesn’t yet have any I/O data.

Instead of asserting, use an if statement and return silently.
Comment 2 Dan Winship 2013-10-22 17:01:00 UTC
Comment on attachment 257814 [details] [review]
soup-message-io: Don’t assert on [un]pausing an unsent SoupMessage

um... what are you doing exactly? The test case is invalid. soup_server_pause_message() isn't expected to work on a message that didn't come from the SoupServer.

Are you trying to pause a message from a SoupServer::request-started callback? If so, then the fix is that soup_server_pause_message() should be handling that in some way other than by calling soup_message_io_pause().

If you are actually trying to call soup_server_pause_message() on a message that was not generated by the SoupServer, then, No.
Comment 3 Philip Withnall 2013-10-23 07:59:16 UTC
(In reply to comment #2)
> (From update of attachment 257814 [details] [review])
> um... what are you doing exactly? The test case is invalid.
> soup_server_pause_message() isn't expected to work on a message that didn't
> come from the SoupServer.

The test case isn’t actually what my code does, it’s just a simple way of replicating the crash I saw. I can’t reproduce the crash (and don’t have a backtrace, sadly), which suggests it’s something more subtle.

The code I’m using is Aurena’s server: https://github.com/pwithnall/aurena/tree/dlna-playback

The soup_server_unpause_message() call is here: https://github.com/pwithnall/aurena/blob/dlna-playback/src/daemon/snra-server-client.c#L611

It operates on a SoupMessage which comes from snra_server_client_new(), which is called here: https://github.com/pwithnall/aurena/blob/dlna-playback/src/daemon/snra-manager.c#L391, which is a callback from soup_server_add_handler().

Tracing through the libsoup code, I can’t find a path which should cause this crash, but it definitely happened. I remember from the trace that the SoupMessage’s private data was pretty much all zeroes, so new_iostream() hadn’t been called on it.

> If you are actually trying to call soup_server_pause_message() on a message
> that was not generated by the SoupServer, then, No.

Sorry this is such a vague bug report; I really should have saved the stack trace when I had it. I guess the best we can do is better document that soup_server_[un]pause_message() should only be called with SoupMessages from a SoupServerCallback.
Comment 4 Philip Withnall 2013-10-23 07:59:38 UTC
Created attachment 257895 [details] [review]
soup-server: Document restriction on SoupMessages given to SoupServer methods

If a SoupMessage which hasn’t yet been sent is passed into
soup_server_[un]pause_message(), an assertion will fail in soup-message-io.c
because the message doesn’t yet have any I/O data.

Document that passing such SoupMessages into those methods is naughty and
shouldn’t be done.
Comment 5 Dan Winship 2013-10-24 02:17:48 UTC
Comment on attachment 257895 [details] [review]
soup-server: Document restriction on SoupMessages given to SoupServer methods

>If a SoupMessage which hasn't yet been sent is passed into
>soup_server_[un]pause_message(), an assertion will fail in soup-message-io.c
>because the message doesn't yet have any I/O data.

It's not "hasn't yet been sent", it's "hasn't yet starting being received".

>+ * This must only be called on #SoupMessage<!-- -->s which come from a
>+ * #SoupServerCallback added with soup_server_add_handler().

That's not 100% true; you can call it on a message that came from one of the SoupServer signals, as long as you only call it at the right times...

Something like "SoupMessages that were created by the SoupServer and are currently doing I/O".

Oh, and btw, you don't need to say "#SoupMessage<!-- -->s". gtk-doc has recognized regular plurals for a long time now, so it will linkify "#SoupMessages" correctly.
Comment 6 Philip Withnall 2013-10-24 07:07:53 UTC
Created attachment 257987 [details] [review]
soup-server: Document restriction on SoupMessages given to SoupServer methods

If a SoupMessage which hasn’t yet started to be received is passed into
soup_server_[un]pause_message(), an assertion will fail in soup-message-io.c
because the message doesn’t yet have any I/O data.

Document that passing such SoupMessages into those methods is naughty and
shouldn’t be done.
Comment 7 Philip Withnall 2013-10-24 07:09:59 UTC
(In reply to comment #5)
> That's not 100% true; you can call it on a message that came from one of the
> SoupServer signals, as long as you only call it at the right times...

This documentation feels icky. It isn’t precise enough to say “are currently doing I/O”, since that requires the user to know when libsoup schedules I/O internally.

I really think the functions should be changed to fail gracefully if the SoupMessage isn’t doing I/O.

Anyway, here’s a patch which fixes your comments.
Comment 8 Dan Winship 2013-11-17 14:14:47 UTC
committed the documentation patch. updating the bug summary to reflect what the "complete" fix would be
Comment 9 Dan Winship 2015-02-10 11:58:30 UTC
[mass-moving all "UNCONFIRMED" libsoup bugs to "NEW" after disabling the "UNCONFIRMED" status for this product now that bugzilla.gnome.org allows that. bugspam-libsoup-20150210]
Comment 10 GNOME Infrastructure Team 2018-09-21 16:16:43 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/libsoup/issues/59.