trouble opening a URL with wxWidgets - url

I'm trying to read http://www.tiwwdty.com/v with wxWidgets and C++. Here's what I've got:
wxString urlname = "http://www.tiwwdty.com/v";
wxURL url(urlname);
if (url.GetError()) abort();
wxInputStream *in = url.GetInputStream();
cout << "in " << in << endl;
if (!in || !in->IsOk()) return;
wxStringOutputStream strout;
in->Read(strout);
string vstr = strout.GetString().ToStdString();
cout << "vstr " << vstr << endl;
And the code actually segfaults in url.GetInputStream() [!?] Can anyone tell me what I'm doing wrong? Here's the backtrace (wxWidgets 3.1.4):
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
* frame #0: 0x00007fff70cd75ad libsystem_pthread.dylib`pthread_mutex_lock
frame #1: 0x00007fff36acdd7d CoreFoundation`CFSocketDisableCallBacks + 79
frame #2: 0x00000001000456f3 nfl`wxSocketManagerMac::Uninstall_Callback(this=0x00000001005b42e8, socket_=0x0000000100f913a0, event=wxSOCKET_INPUT) at sockosx.cpp:274:5
frame #3: 0x0000000100044e71 nfl`wxSocketImplUnix::DoEnableEvents(this=0x0000000100f913a0, flags=3, enable=false) at sockunix.cpp:113:22
frame #4: 0x0000000100045d01 nfl`wxSocketImplUnix::UpdateBlockingState(this=0x0000000100f913a0) at sockunix.h:68:9
frame #5: 0x000000010003bb94 nfl`wxSocketBase::SetFlags(this=0x0000000101857d60, flags=28) at socket.cpp:1687:21
frame #6: 0x000000010004057b nfl`wxSocketWaitModeChanger::~wxSocketWaitModeChanger(this=0x00007ffeefbfe320) at socket.cpp:192:19
frame #7: 0x000000010003c905 nfl`wxSocketWaitModeChanger::~wxSocketWaitModeChanger(this=0x00007ffeefbfe320) at socket.cpp:191:5
frame #8: 0x000000010003c98d nfl`wxSocketBase::Peek(this=0x0000000101857d60, buffer=0x0000000101077000, nbytes=4095) at socket.cpp:1147:1
frame #9: 0x0000000100034770 nfl`wxProtocol::ReadLine(sock=0x0000000101857d60, result=0x00007ffeefbfe708) at protocol.cpp:130:15
frame #10: 0x00000001000316b4 nfl`wxHTTP::ParseHeaders(this=0x0000000101857d60) at http.cpp:261:23
frame #11: 0x0000000100032e29 nfl`wxHTTP::BuildRequest(this=0x0000000101857d60, path=0x00007ffeefbfeea0, method=0x00007ffeefbfed48) at http.cpp:428:17
frame #12: 0x00000001000331cd nfl`wxHTTP::GetInputStream(this=0x0000000101857d60, path=0x00007ffeefbfeea0) at http.cpp:516:10
frame #13: 0x0000000100042ab0 nfl`wxURL::GetInputStream(this=0x00007ffeefbff018) at url.cpp:348:47
frame #14: 0x00000001000058ee nfl`nfl_frame::check_version(this=<unavailable>) at nfl.cpp:384:27 [opt]
frame #15: 0x00000001000052f1 nfl`nfl_app::OnInit(this=<unavailable>) at nfl.cpp:165:10 [opt]
frame #16: 0x0000000100054cc1 nfl`wxApp::CallOnInit(this=0x0000000100f04750) at utils.mm:439:22
frame #17: 0x00000001003986d9 nfl`wxEntry(argc=0x00000001005cb508, argv=0x000000010191fcf0) at init.cpp:491:25
frame #18: 0x00000001003988fb nfl`wxEntry(argc=0x00007ffeefbff95c, argv=0x00007ffeefbff980) at init.cpp:519:12
frame #19: 0x0000000100004c44 nfl`main(argc=1, argv=<unavailable>) at nfl.cpp:138:1 [opt]
frame #20: 0x00007fff70ad7cc9 libdyld.dylib`start + 1
If it matters, the web address launches fine in a browser, but wget doesn't seem to like it. curl, however, is fine.
Thanks!

Related

AudioKit SynthOne crashes after returning from background

We're using a "skinless" version of AK SynthOne in our app (i.e., just the engine, with a collection of presets), and seeing a consistent crash when returning from background. In order to spare the user's battery when the sequence is not playing, if the user goes to background, we call AudioKit.stop(). This allows the CPU usage to fall to zero (happy customers!), but on returning we see a consistent crash when SynthOne tries to handle its first note:
void S1NoteState::startNoteHelper(int noteNumber, int velocity, float frequency) {
oscmorph1->freq = frequency; // <-- EXC_BAD_ACCESS here!
oscmorph2->freq = frequency;
subOsc->freq = frequency;
fmOsc->freq = frequency;
...
The backtrace:
* thread #13, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x0000000100fc5d78 Spliqs`S1NoteState::startNoteHelper(this=0x0000000108345500, noteNumber=56, velocity=54, frequency=207.652328) at S1NoteState.mm:105:21
frame #1: 0x0000000100fd6764 Spliqs`S1DSPKernel::turnOnKey(this=0x00000001088a3790, noteNumber=56, velocity=54, frequency=207.652328) at S1DSPKernel+toggleKeys.mm:85:14
frame #2: 0x0000000100fcabd0 Spliqs`S1DSPKernel::startNote(this=0x00000001088a3790, noteNumber=56, velocity=54, frequency=207.652328) at S1DSPKernel+startStopNotes.mm:45:9
frame #3: 0x0000000100fc1298 Spliqs`::-[S1AudioUnit startNote:velocity:frequency:](self=0x00000001088a3600, _cmd="startNote:velocity:frequency:", note='8', velocity='6', frequency=207.652328) at S1AudioUnit.mm:98:13
frame #4: 0x00000001014cf86c Spliqs`AKSynthOne.play(noteNumber=56, velocity=54, frequency=207.65233610331066, channel=0, self=0x0000000280de4a00) at AKSynthOne.swift:223:21
frame #5: 0x00000001016dbda4 Spliqs`AudioKit.AKPolyphonicNode.play(noteNumber: Swift.UInt8, velocity: Swift.UInt8, channel: Swift.UInt8) -> () + 328
frame #6: 0x000000010135a120 Spliqs`Conductor.handleMIDI(data1=146, data2=56, data3=54, self=0x000000010820efe0) at Conductor.swift:392:23
frame #7: 0x00000001013597a4 Spliqs`Conductor.handle(event=AudioKit.AKMIDIEvent # 0x000000016f488ba0, self=0x000000010820efe0) at Conductor.swift:374:26
frame #8: 0x0000000101358de4 Spliqs`closure #1 in Conductor.setUpMIDIHandler(packetList=0x000000016f489e98, _0=nil, self=0x000000010820efe0) at Conductor.swift:326:30
frame #9: 0x0000000101157f48 Spliqs`thunk for #escaping #callee_guaranteed (#unowned UnsafePointer<MIDIPacketList>, #unowned UnsafeMutableRawPointer?) -> () at <compiler-generated>:0
frame #10: 0x00000001d42467b8 CoreMIDI`LocalMIDIReceiverList::HandleMIDIIn(unsigned int, unsigned int, void*, MIDIPacketList const*) + 164
frame #11: 0x00000001d4246618 CoreMIDI`MIDIProcess::RunMIDIInThread() + 132
frame #12: 0x00000001d425d1e8 CoreMIDI`XThread::RunHelper(void*) + 28
frame #13: 0x00000001d4262624 CoreMIDI`CAPThread::Entry(CAPThread*) + 92
frame #14: 0x00000001c3eef908 libsystem_pthread.dylib`_pthread_body + 132
frame #15: 0x00000001c3eef864 libsystem_pthread.dylib`_pthread_start + 48
frame #16: 0x00000001c3ef7dcc libsystem_pthread.dylib`thread_start + 4
We've tried everything from just starting AudioKit, through to completely re-initializing SynthOne, but it's always the same.
We've been stuck on this one for a while, so any thoughts greatly appreciated.
UPDATE: Actually, I'm afraid I have to resuscitate this question. Although the .pause() approach in my answer below worked for going to/from background we also have a use-case where we move to offline render mode to export audio. That process definitely does require us to stop the engine (in order to switch modes), and we're getting the same SynthOne-related crash when handling the first event after AudioKit.start(). Does anybody understand why we'd hit an EXC_BAD_ACCESS when returning? I'm guessing that memory has been incorrectly reallocated/reclaimed(?) somehow, but how can I prevent it?
I suppose, more broadly, the question would be: how do I safely start/stop the AudioKit engine when using SynthOne.
Erm... yikes... how about .stopEngine() and .startEngine()...? an rtfm moment, for sure.
For anyone who might face a similar problem, these use AudioKit.engine.pause() and AudioKit.engine.start(), as opposed to using stop().

CoreData: Object being released in block "error: Mutating a managed object after it has been removed from its context"

This code relies on the CoreData setup from an older forked version of Robbie Hanson's XMPPFramework.
I am retrofitting a data structure to be backed by a managed object CoreData and basically keep a reference to the NSManagedObjectID inside the data structure in question and then have accessors to get/set the data structure properties with the backing data in Core Data.
I am intermittently getting the following error (similar to):
CoreData: error: Mutating a managed object 0xd00000000014000a <x-coredata://90C02501-4756-44F0-ABA6-B725192772A6/ZZXMPPOneToOneInboxItemCoreDataObject/p5> (0x1742971b0) after it has been removed from its context.
I am getting the error both when setting and getting. Obviously the "getting" error is not a "mutating a managed object" error but the stack trace is the same with the release as a culprit.
Here is an example setter:
- (void)setMamUUID:(NSString *)mamUUID
{
ZZXMPPInboxCoreDataStorage *storage = [ZZXMPPInboxCoreDataStorage sharedInstance];
[storage executeBlock:^{
ZZXMPPOneToOneInboxItemCoreDataObject *backingObject = (ZZXMPPOneToOneInboxItemCoreDataObject *)[storage inboxItemInsideBlockWithObjectID:self.itemCoreDataObjectID];
backingObject.mamUUID = mamUUID;
}];
}
and a getter:
- (NSString *)mamUUID
{
ZZXMPPInboxCoreDataStorage *storage = [ZZXMPPInboxCoreDataStorage sharedInstance];
__block NSString *_mamUUID;
[storage executeBlock:^{
ZZXMPPOneToOneInboxItemCoreDataObject *backingObject = (ZZXMPPOneToOneInboxItemCoreDataObject *)[storage inboxItemInsideBlockWithObjectID:self.itemCoreDataObjectID];
_mamUUID = [backingObject mamUUID];
}];
return _mamUUID;
}
The inboxItemInsideBlockWithObjectID: is a helper routine meant to run inside an executeBlock: and looks like this
- (ZZXMPPInboxBaseMemberCoreDataObject *)inboxItemInsideBlockWithObjectID:(NSManagedObjectID *)objectID
{
ZZXMPPInboxBaseMemberCoreDataObject *inboxItem = nil;
inboxItem = [[self managedObjectContext] objectWithID:objectID];
if (nil == inboxItem) {
NSLog(#"..Unable to retrieve an Inbox Item with objectID %#.", objectID);
}
return inboxItem;
}
The "storage" object referenced in both is the XMPPCoreDataStorage object from the XMPPFramework and it's executeBlock: has this as the main code:
dispatch_sync(storageQueue, ^{ #autoreleasepool {
block();
// Since this is a synchronous request, we want to return as quickly as possible.
// So we delay the maybeSave operation til later.
dispatch_async(storageQueue, ^{ #autoreleasepool {
[self maybeSave:OSAtomicDecrement32(&pendingRequests)];
}});
}});
The error is an objc_object::release() (backtrace to follow) and is showing in the debugger at the end of the block in the "setter" code above.
Here is the complete backtrace:
(lldb) bt
* thread #1, queue = 'ZZXMPPRoomHybrid', stop reason = EXC_BAD_ACCESS (code=1, address=0x3a8e9bec8)
frame #0: 0x0000000180459704 libobjc.A.dylib`objc_object::release() + 8
* frame #1: 0x000000010009c1f4 MyApp`__29-[ZZConversation setMamUUID:]_block_invoke((null)=0x000000016fda6838) at ZZConversation.m:280
frame #2: 0x00000001003da11c MyApp`__36-[XMPPCoreDataStorage executeBlock:]_block_invoke((null)=0x000000016fda67b0) at XMPPCoreDataStorage.m:1063
frame #3: 0x0000000103c55218 libdispatch.dylib`_dispatch_client_callout + 16
frame #4: 0x0000000103c61dc8 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 156
frame #5: 0x0000000103c65adc libdispatch.dylib`_dispatch_barrier_sync_f_slow + 452
frame #6: 0x00000001003da098 MyApp`-[XMPPCoreDataStorage executeBlock:](self=0x00000001702e5100, _cmd="executeBlock:", block=0x000000010009c148) at XMPPCoreDataStorage.m:1061
frame #7: 0x000000010009c0d8 MyApp`-[ZZConversation setMamUUID:](self=0x0000000174223d60, _cmd="setMamUUID:", mamUUID=#"50a35939-f48c-4011-8cfe-b5edf3641e20") at ZZConversation.m:276
frame #8: 0x00000001000a3c80 MyApp`-[ZZConversation mamRequestWasSentWithUUID:](self=0x0000000174223d60, _cmd="mamRequestWasSentWithUUID:", uuid=#"50a35939-f48c-4011-8cfe-b5edf3641e20") at ZZConversation.m:886
frame #9: 0x00000001000af894 MyApp`__58-[ZZXMPPMAMCoreDataStorage requestMessageArchiveWithUser:]_block_invoke((null)=0x00000001742567a0) at ZZXMPPMAMCoreDataStorage.m:73
frame #10: 0x0000000103c55218 libdispatch.dylib`_dispatch_client_callout + 16
frame #11: 0x0000000103c61334 libdispatch.dylib`_dispatch_continuation_pop + 708
frame #12: 0x0000000103c6ff94 libdispatch.dylib`_dispatch_source_latch_and_call + 204
frame #13: 0x0000000103c57300 libdispatch.dylib`_dispatch_source_invoke + 836
frame #14: 0x0000000103c5a05c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 652
frame #15: 0x00000001819b6810 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #16: 0x00000001819b43fc CoreFoundation`__CFRunLoopRun + 1660
frame #17: 0x00000001818e22b8 CoreFoundation`CFRunLoopRunSpecific + 444
frame #18: 0x0000000183396198 GraphicsServices`GSEventRunModal + 180
frame #19: 0x00000001879297fc UIKit`-[UIApplication _run] + 684
frame #20: 0x0000000187924534 UIKit`UIApplicationMain + 208
frame #21: 0x000000010006a688 MyApp`main(argc=5, argv=0x000000016fda7a60) at main.m:16
frame #22: 0x00000001808c55b8 libdyld.dylib`start + 4
(lldb)
I am not sure why the managed object would be released mid-block. The #autoreleasepool surrounds the block and should not release anything while the "sync" block is running.
This happens intermittently and I can run the app several times before it will surface again. Usually, it appears on a "getter" and not a "setter", but since it happens on both and the code for both is similar I don't think that matters.
Why would this managed object instance be released at this point?

Passing string causing crash sometimes in swift

I run into strange thing I'm getting a crash it this function:
func addQuestion(text:String!)
{
if let txt=text
{
let question=PFObject(className: "questions")
question["text"]=txt
question["userAdding"]=PFUser.currentUser()
question["answeredCount"]=0
question.setObject([], forKey: "answers")
question.setObject(NSDate(), forKey: "dateAdded")
question.setObject(Int(arc4random()) % 10, forKey: "random")
if debug
{question.saveInBackgroundWithBlock(nil)}
else
{question.saveEventually()}
}
}
I'm getting a crash in "if let txt=text"
here is a back trace:
thread #1: tid = 0x241c0c, 0x00063470 pytajnik`pytajnik.ApiClient.addQuestion (text=Some, self=(ObjectiveC.NSObject = {}, debug = true))(Swift.ImplicitlyUnwrappedOptional<Swift.String>) -> () + 10796 at ApiClient.swift:32, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)
frame #0: 0x00063470 pytajnik`pytajnik.ApiClient.addQuestion (text=Some, self=(ObjectiveC.NSObject = {}, debug = true))(Swift.ImplicitlyUnwrappedOptional<Swift.String>) -> () + 10796 at ApiClient.swift:32
frame #1: 0x00035428 pytajnik`pytajnik.AddQuestionViewController.addQuestion (sender=AnyObject at 0x006ca054, self=0x17ef85d0)(Swift.AnyObject) -> () + 796 at AddQuestionViewController.swift:17
frame #2: 0x00035a6c pytajnik`#objc pytajnik.AddQuestionViewController.addQuestion (pytajnik.AddQuestionViewController)(Swift.AnyObject) -> () + 100 at AddQuestionViewController.swift:0
frame #3: 0x2a5fdc2a UIKit`-[UIApplication sendAction:to:from:forEvent:] + 70
frame #4: 0x2a5fdbd0 UIKit`-[UIControl sendAction:to:forEvent:] + 44
...
The thing is, the app is not crashing always. Sometime it works sometime it doesn't. And I could't find a pattern.
Could somebody help me understand what is wrong?
UPDATE
thread #1: tid = 0x243f69, 0x0005d478 pytajnik`pytajnik.ApiClient.addQuestion (text=Some, self=(ObjectiveC.NSObject = {}, debug = true))(Swift.Optional<Swift.String>) -> () + 9820 at ApiClient.swift:35, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)
frame #0: 0x0005d478 pytajnik`pytajnik.ApiClient.addQuestion (text=Some, self=(ObjectiveC.NSObject = {}, debug = true))(Swift.Optional<Swift.String>) -> () + 9820 at ApiClient.swift:35
frame #1: 0x0002f80c pytajnik`pytajnik.AddQuestionViewController.addQuestion (sender=AnyObject at 0x006c4054, self=0x166a5560)(Swift.AnyObject) -> () + 1760 at AddQuestionViewController.swift:17
frame #2: 0x0002fe40 pytajnik`#objc pytajnik.AddQuestionViewController.addQuestion (pytajnik.AddQuestionViewController)(Swift.AnyObject) -> () + 100 at AddQuestionViewController.swift:0
frame #3: 0x2a5fdc2a UIKit`-[UIApplication sendAction:to:from:forEvent:] + 70
frame #4: 0x2a5fdbd0 UIKit`-[UIControl sendAction:to:forEvent:] + 44
frame #5: 0x2a5e8862 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 582
frame #6: 0x2a5fd63c UIKit`-[UIControl touchesEnded:withEvent:] + 588
frame #7: 0x2a5fd316 UIKit`-[UIWindow _sendTouchesForEvent:] + 522
frame #8: 0x2a5f6be0 UIKit`-[UIWindow sendEvent:] + 544
You declared the function parameter as implicitly unwrapped optional !, meaning you are sure it will never be nil.
If its possible that this parameter can be nil declare it as optional:
func addQuestion(text: String?) {
if let txt = text {
...
}
}
You have declared the text parameter as an implicitly unwrapped optional, which causes the app to crash if text is nil, and this is what's happening in your case.
Unless you have a specific reason to use an implicitly unwrapped optional, it's always better to use an optional String?, or a non optional String if the parameter can never be nil.
So to fix the problem just change your function signature to this:
func addQuestion(text:String?)
Suggested reading: Implicitly Unwrapped Optionals

<Error>: CGImageCreate: invalid image size: 0 x 0

Before give duplicate mark read my whole question:
I know might be there is many question related to my title but issue is different.
I am using Mac OS X 10.9.3 and Xcode 5.1.1.
In my app I just want to share image, URL link and some description on Facebook and Twitter so I used SLComposeViewController and my code is below.
-(void)btnShareTapped:(UIButton *)sender
{
if(sender.tag == 100)
[self shareProductContentOnTwitterORFB:#"Facebook"];
else
[self shareProductContentOnTwitterORFB:#"Twitter"];
}
Method body:
-(void) shareProductContentOnTwitterORFB:(NSString *) shareON
{
SLComposeViewController *shareKit = nil; // also tried with [[SLComposeViewController alloc] init];
if([shareON isEqualToString:#"Twitter"])
shareKit = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
else
shareKit = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[shareKit setInitialText:#"My Description Text."];
[shareKit addImage:[UIImage imageNamed:#"boston-shopping.jpg"]]; // I also tried with .png image
[shareKit addURL:[NSURL URLWithString:#"www.google.com"]];
//[self.view.window.rootViewController presentViewController:shareKit animated:YES completion:nil];
[self presentViewController:shareKit animated:YES completion:nil]; /// I also tried with above comment.
}
After execute above code, SLComposeViewController will be open and in my console
<Error>: CGImageCreate: invalid image size: 0 x 0.
display only with Facebook and get exactly same problem Look at this question.
I am sure my image is not nil, I was checked it.
Above question said -
This bug seems to be fixed in new version of iOS (6.0.1) At least I have all working well since my last updgrade.
But I am testing on iOS 6.1 still I am getting same issue and in iOS 7.0 and 7.1 the error message in console (<Error>: CGImageCreate: invalid image size: 0 x 0.) Not display but I cam not able to go to on setting App in both Facebook and Twitter.
What is problem ? where I am wrong? Is this apple Bug ??
Please give your suggestion.
Take a look at this stack trace after I called [self presentViewController:shareKit animated:YES completion:nil]; :
* thread #1: tid = 0x199f3, 0x0026a871 CoreGraphics`CGPostError, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x0026a871 CoreGraphics`CGPostError
frame #1: 0x0021bfc0 CoreGraphics`CGImageCreate + 296
frame #2: 0x00458ea5 UIKit`_UICreateCGImageFromCARenderServerBuffer + 201
frame #3: 0x007e7b0e UIKit`-[UISnapshotView captureSnapshotRect:fromView:withSnapshotType:] + 1712
frame #4: 0x008fdfa7 UIKit`-[_UIRemoteViewController _snapshotAndRemoveTextEffectsRemoteView] + 337
frame #5: 0x008fe064 UIKit`-[_UIRemoteViewController _applicationWillResignActive:] + 33
frame #6: 0x00f9a4f9 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 40
frame #7: 0x014e50c5 CoreFoundation`___CFXNotificationPost_block_invoke_0 + 85
frame #8: 0x0143fefa CoreFoundation`_CFXNotificationPost + 2122
frame #9: 0x00ecebb2 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 98
frame #10: 0x0041abb1 UIKit`-[UIApplication _deactivateForReason:notify:] + 381
frame #11: 0x0041ac3d UIKit`-[UIApplication _deactivateForReason:] + 48
frame #12: 0x0041cfd4 UIKit`_alertItemStateChanged + 73
frame #13: 0x014e52e3 CoreFoundation`__CFNotificationCenterAddObserver_block_invoke_0 + 163
frame #14: 0x014e53a0 CoreFoundation`____CFXNotificationPostToken_block_invoke_0 + 176
frame #15: 0x0144a920 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
frame #16: 0x0140dd31 CoreFoundation`__CFRunLoopDoBlocks + 257
frame #17: 0x01431c51 CoreFoundation`__CFRunLoopRun + 2273
frame #18: 0x01430f44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #19: 0x01430e1b CoreFoundation`CFRunLoopRunInMode + 123
frame #20: 0x01dcb7e3 GraphicsServices`GSEventRunModal + 88
frame #21: 0x01dcb668 GraphicsServices`GSEventRun + 104
frame #22: 0x0041dffc UIKit`UIApplicationMain + 1211
frame #23: 0x00002f3d iostest`main(argc=1, argv=0xbffff0d0) + 141 at main.m:16
I tried to run your code in my sample project and I found these :
The error message was printed after [self presentViewController:shareKit animated:YES completion:nil]; and before the modal shareKit view appeared.
The error message was printed from CGPostError in CoreGraphics.
I think this error occurred because of -[UISnapshotView captureSnapshotRect:fromView:withSnapshotType:].
I tried to comment out this line of yours, [shareKit addImage:[UIImage imageNamed:#"boston-shopping.jpg"]];, and I still got the error message. So, the error was not because of your code.
In my opinion, I think the error message you got was because of UISnapshotView was trying to take a snapshot of the current screen, but there was nothing there or there was some bugs in the method. So, it passed the wrong width = 0 & height = 0 arguments to CGImageCreate that caused the error.
So, rest assured, this is not your bug. Just ignore it.
Try and create the CGImageRef object yourself. You can replace the line:
[shareKit addImage:[UIImage imageNamed:#"boston-shopping.jpg"]];
with this:
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"boston-shopping" ofType:#"jpg"];
CGDataProviderRef source = CGDataProviderCreateWithFilename([filePath cStringUsingEncoding:NSUTF8StringEncoding]);
CGImageRef imageRef = CGImageCreateWithJPEGDataProvider(source,
NULL,
true,
kCGRenderingIntentDefault);
[shareKit addImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);

Cocos2d Game crashes when trying to replace scene

I am trying to switch between different scenes in my game. I switched from my GameLayer to a Config scene first, then switch back using the following code, but the game crashes:
-(void) backToGame
{
[[CCDirector sharedDirector] replaceScene:[GameLayer scene]];
}
And the log I received:
thread #1: tid = 0x1c03, 0x350ebf78 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0xe0000008)
frame #0: 0x350ebf78 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x373352e6 CoreFoundation`CFRelease + 94
frame #2: 0x373b1b36 CoreFoundation`__CFDictionaryStandardReleaseValue + 70
frame #3: 0x374053bc CoreFoundation`__CFBasicHashDrain + 264
frame #4: 0x3733539a CoreFoundation`CFRelease + 274
frame #5: 0x350eee56 libobjc.A.dylib`objc_release + 38
(lldb)
I am sorry that I cannot attach any more codes from my project because I really don't know where it comes from.
Thanks for your help.
Try this lines of code.
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameLayer scene] withColor:ccWHITE]];

Resources