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 602156 - GDataUploadStream should close GOutputStream on dispose
GDataUploadStream should close GOutputStream on dispose
Status: RESOLVED FIXED
Product: libgdata
Classification: Platform
Component: General
git master
Other All
: High major
: ---
Assigned To: libgdata-maint
libgdata-maint
Depends on:
Blocks:
 
 
Reported: 2009-11-17 03:53 UTC by Richard Schwarting
Modified: 2009-11-21 20:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to close output stream before unreffing it (568 bytes, patch)
2009-11-17 04:45 UTC, Richard Schwarting
rejected Details | Review
Bug 602156 — GDataUploadStream should close GOutputStream on dispose (1.33 KB, patch)
2009-11-17 12:49 UTC, Philip Withnall
committed Details | Review

Description Richard Schwarting 2009-11-17 03:53:26 UTC
I take the following assert (hit after calling g_cancellable_cancel () during an upload from gdata_picasaweb_service_upload_file ()) to indicate that I should implement a parse_error_response for GDataPicasaWebService.


upload_thread (self=0xb412f920) at gdata-upload-stream.c:520
520			g_assert (klass->parse_error_response != NULL);
Missing separate debuginfos, use: debuginfo-install expat-2.0.1-6.fc11.1.i586 gnutls-2.6.6-3.fc11.i586 lcms-libs-1.18-2.fc11.i586 libcroco-0.6.2-2.fc11.i586 libexif-0.6.16-3.fc11.i586 libproxy-0.2.3-10.fc11.i586 libvorbis-1.2.0-9.fc11.i586 nss-mdns-0.10-7.fc11.i586 pycairo-1.8.2-2.fc11.i586 pygobject2-2.16.1-4.fc11.i586 pygtk2-2.14.1-2.fc11.i586
(gdb) l
515		if (SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
516			GDataServiceClass *klass = GDATA_SERVICE_GET_CLASS (priv->service);
517	
518			/* Error! Store it in the structure, and it'll be returned by the next function in the main thread
519			 * which can give an error response.*/
520			g_assert (klass->parse_error_response != NULL);
521			klass->parse_error_response (priv->service, GDATA_SERVICE_ERROR_WITH_UPLOAD, status, priv->message->reason_phrase,
522						     priv->message->response_body->data, priv->message->response_body->length, &(priv->response_error));
523		}
524
Comment 1 Richard Schwarting 2009-11-17 04:25:10 UTC
Did a little more debugging.

(gdb) print priv->message
$10 = (SoupMessage *) 0x0
(gdb) print status
$11 = 403
(gdb) print priv->service
$12 = (GDataService *) 0x0

Perhaps when I cancel early enough, message and service are never set?

I think it's prompted by me unref'ing the GFileOutputStream: 

Thread 11 (Thread 0xaf3ffb70 (LWP 9240))

  • #0 __kernel_vsyscall
  • #1 pthread_cond_wait
    at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S line 122
  • #2 gdata_upload_stream_close
    at gdata-upload-stream.c line 431
  • #3 IA__g_output_stream_close
    at goutputstream.c line 547
  • #4 g_output_stream_dispose
    at goutputstream.c line 118
  • #5 gdata_upload_stream_dispose
    at gdata-upload-stream.c line 226
  • #6 IA__g_object_unref
    at gobject.c line 2393
  • #7 gdata_picasaweb_service_upload_file
    at gdata-picasaweb-service.c line 413
  • #8 tmp_picasaweb_upload_async
    at eog-postasa-plugin.c line 391
  • #9 run_in_thread
    at gsimpleasyncresult.c line 656
  • #10 io_job_thread
    at gioscheduler.c line 179
  • #11 g_thread_pool_thread_proxy
    at gthreadpool.c line 265
  • #12 g_thread_create_proxy
    at gthread.c line 635
  • #13 start_thread
    at pthread_create.c line 297
  • #14 clone
    at ../sysdeps/unix/sysv/linux/i386/clone.S line 130

I'm going to try closing the GOutputStream before unrefing it, so I can provide it with our GCancellable. 

Ok, that seemed to work, but perhaps I just have bad luck with a race to dispose/versus cancel.  

Thoughts?
Comment 2 Richard Schwarting 2009-11-17 04:45:43 UTC
Created attachment 147949 [details] [review]
Patch to close output stream before unreffing it

This patch makes us close the output stream before unref'ing it. 

I'm not totally clear on how GCancellable works, but looking at it, I think this will fix the problem.  Testing it, it does seem to.
Comment 3 Philip Withnall 2009-11-17 12:49:20 UTC
Created attachment 147968 [details] [review]
Bug 602156 — GDataUploadStream should close GOutputStream on dispose

Close the GOutputStream before disposing private data for
GDataUploadStream which could be referenced by threaded code called when
the upload is cancelled. Closes: bgo#602156
Comment 4 Philip Withnall 2009-11-17 12:51:07 UTC
Does my patch work? As you say, I think this is being caused by the GOutputStream being closed too late. GDataUploadStream should conform to the behaviour established by GOutputStream in that unreffing the stream should close it *first*.
Comment 5 Richard Schwarting 2009-11-17 21:56:13 UTC
Ah.  That's a better place for it then :)  Your patch seems to fix the issue, too.
Comment 6 Philip Withnall 2009-11-21 20:22:53 UTC
commit 35a970c145c0390c6cbd663b7d04f515901cd2fc
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Tue Nov 17 12:46:39 2009 +0000

    Bug 602156 — GDataUploadStream should close GOutputStream on dispose
    
    Close the GOutputStream before disposing private data for
    GDataUploadStream which could be referenced by threaded code called when
    the upload is cancelled. Closes: bgo#602156

 gdata/gdata-upload-stream.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)