Sreevijitha / gdata-objectivec-client

Automatically exported from code.google.com/p/gdata-objectivec-client
Other
0 stars 0 forks source link

Objective-C memory error when canceling upload (with GC) #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Add a cancel upload action to the YouTubeSample project and connect it to a 
button. For 
example:

   - (IBAction)cancelUpload:(id)sender {
    [ticket cancelTicket];
   }

2. Build and Run, Start an upload and then Cancel (it should work properly)

3. Now set the target's "Objective-C Garbage Collection" build setting to 
"Required" in XCode.

4. Build and Run, Start an upload and then Cancel (works then crashes the 
application)

What is the expected output? What do you see instead?

There should be no error... After canceling the upload, the application usually 
has a EXC_BAD_ACCESS memory error with the following backtrace:

#0  0x91b44ed7 in objc_msgSend ()
#1  0x0128c968 in ?? ()
#2  0x939fe3e1 in spoolingClose ()
#3  0x96b100cf in _CFStreamClose ()
#4  0x9454a675 in HTTPNetStreamInfo::closeAndReleasePayload ()
#5  0x94551d47 in HTTPNetStreamInfo::~HTTPNetStreamInfo ()
#6  0x96bf70ad in -[__NSCFType finalize] ()
#7  0x91b4b74d in finalizeOneObject ()
#8  0x96d9c512 in Auto::foreach_block_do ()
#9  0x91b4b3ce in batchFinalize ()
#10 0x91b4b452 in batchFinalizeOnTwoThreads ()
#11 0x96d95d79 in Auto::Zone::invalidate_garbage ()
#12 0x96d86b25 in auto_collect_internal ()
#13 0x96d873cf in auto_collection_work ()
#14 0x926a9828 in _dispatch_call_block_and_release ()
#15 0x9269c1f4 in _dispatch_queue_drain ()
#16 0x9269bc52 in _dispatch_queue_invoke ()
#17 0x9269ba68 in _dispatch_worker_thread2 ()
#18 0x9269b4f1 in _pthread_wqthread ()
#19 0x9269b336 in start_wqthread ()

It appears to me that at least one of the HTTP streams is not shutting down 
properly when GC is 
being used. Perhaps there is some code in a dealloc method somewhere that 
shouldn't be 
(though I haven't been able to find it yet).

Note: this bug makes it impossible to cancel an upload if the application is 
using GC!

Thanks for your attention!

Original issue reported on code.google.com by a...@beedocuments.com on 29 Dec 2009 at 7:09

GoogleCodeExporter commented 9 years ago
Appears to be a crash calling method completedSpoolToFile in 
_NSHTTPBodyStreamWrapper

Original comment by gregrobbins on 29 Dec 2009 at 10:26

GoogleCodeExporter commented 9 years ago
I suspect this is a bug in NSURLConnection when it uploads from an NSStream 
under garbage collection. I'll 
investigate further later.

I can provide an ugly but functional workaround for now that avoids using a 
stream when uploading; send me 
mail directly if you need it.

Original comment by gregrobbins on 29 Dec 2009 at 10:56

GoogleCodeExporter commented 9 years ago
Repro'd on 10.6.2 and reported to Apple. Radar 7719344.

Original comment by gregrobbins on 5 Mar 2010 at 12:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The system crash on canceling stream upload connections with garbage collection 
enabled appears to be fixed in Mac OS X 10.7.2

Original comment by grobb...@google.com on 8 Nov 2011 at 1:07