Skip to content

EXC_BAD_ACCESS in BfTask.m #1327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
greensmartdev opened this issue Aug 4, 2018 · 29 comments
Closed

EXC_BAD_ACCESS in BfTask.m #1327

greensmartdev opened this issue Aug 4, 2018 · 29 comments

Comments

@greensmartdev
Copy link

greensmartdev commented Aug 4, 2018

This error occurs while running a project incorporating Parse, ParseUI and Bolts frameworks compiled with bitcode on Xcode 9.4.1. The project is being run on device and the launch screen of the app even comes up, and then it crashes with the error in the title.

This is the relevant code snippet

BOOL completed; @synchronized(self.lock) { completed = self.completed; if (!completed) { [self.callbacks addObject:[^{ [executor execute:executionBlock]; } copy]]; } } if (completed) { [executor execute:executionBlock]; }

the exception is being thrown by the line:

[executor execute:executionBlock];

@flovilmart
Copy link
Contributor

If the issue is in BFTask, you should open it in the Bolts repository most probably.

@greensmartdev
Copy link
Author

Ok. Thanks. I will close this.

@flovilmart
Copy link
Contributor

Can you also post The stacktrace here?

@flovilmart flovilmart reopened this Aug 4, 2018
@greensmartdev
Copy link
Author

Sure. The stack trace is:

MyProject was compiled with optimization - stepping may behave oddly; variables may not be available.

thread #5, queue = 'com.parse.asynctaskqueue.sync', stop reason = EXC_BAD_ACCESS (code=2, address=0x117ea8640)
frame #0: 0x0000000117ea8640
frame #1: 0x0000000100c012c8 MyProject-[BFTask continueWithExecutor:block:cancellationToken:](self=0x0000000117ea9690, _cmd=, executor=0x0000000117ea8df0, block=0x0000000100bd9a74, cancellationToken=) at BFTask.m:368 [opt] frame #2: 0x0000000100b8d1b8 MyProject__28-[PFAsyncTaskQueue enqueue:]_block_invoke(.block_descriptor=0x000000011990b920) at PFAsyncTaskQueue.m:50 [opt]
frame #3: 0x0000000101ff11dc libdispatch.dylib_dispatch_call_block_and_release + 24 frame #4: 0x0000000101ff119c libdispatch.dylib_dispatch_client_callout + 16
frame #5: 0x0000000101fffdfc libdispatch.dylib_dispatch_queue_serial_drain + 768 frame #6: 0x0000000101ff46ac libdispatch.dylib_dispatch_queue_invoke + 328
frame #7: 0x0000000102000d54 libdispatch.dylib_dispatch_root_queue_drain_deferred_wlh + 352 frame #8: 0x0000000102007e38 libdispatch.dylib_dispatch_workloop_worker_thread + 676
frame #9: 0x0000000182ef7e70 libsystem_pthread.dylib_pthread_wqthread + 860 frame #10: 0x0000000182ef7b08 libsystem_pthread.dylibstart_wqthread + 4

@greensmartdev
Copy link
Author

The formatting is not the best. Hope you can decipher that

@flovilmart
Copy link
Contributor

Are you able to share the project somehow?

@greensmartdev
Copy link
Author

I am not able to share the entire project yet, but if you need something like build settings or other such things, I can post them here.

@flovilmart
Copy link
Contributor

Or the same project but without the code, just the app delegate?

@greensmartdev
Copy link
Author

You mean the appdelegate.swift file?

@flovilmart
Copy link
Contributor

Yeah, if that’s waht causing the issue. That would really help reproducing

@greensmartdev
Copy link
Author

the relevant lines in the AppDelegate.swift file are:

let configuration = ParseClientConfiguration { $0.applicationId = "$$$$$$$$$$$$$" $0.server = "$$$$$$$$$$$$" } Parse.initialize(with: configuration)

$$$$$$$$$$$$$ of course replaced with real values.

@flovilmart
Copy link
Contributor

Do you have an idea if it's a crash that occur without any call to parse or if you can pinpoint a place in your code that makes it crash?

@greensmartdev
Copy link
Author

I just commented out those lines in the AppDelegate.swift file and the code runs successfully.

@greensmartdev
Copy link
Author

So obviously the error is initiated with the call to

Parse.initialize(with: configuration)

The app now runs successfully after commenting out that line, but of course I am not able to use Parse in the app anymore.

@flovilmart
Copy link
Contributor

And without optimizations it’s all good?

@greensmartdev
Copy link
Author

greensmartdev commented Aug 4, 2018

Without optimizations (meaning without setting the "Other C flags" equal to "-fembed-bitcode" when building the Bolts framework) the project runs OK on the device.

@flovilmart
Copy link
Contributor

How are you importing the parse SDK? Cocoapods m, Carthage or?

@greensmartdev
Copy link
Author

greensmartdev commented Aug 4, 2018

I downloaded the Parse-SDK-iOS-OSX.zip file from here, then I went to the parse directory, ran the git submodule command to pull in all dependencies, then went to

Parse.xcodeproj file, opened it in Xcode, set "Other C flags" equal to "-fembed-bitcode" in Build Settings, built the project, then went to the Products folder and located the "Parse.framework" file.

I dragged the "Parse.framework" file into my project.

I did the same for the ParseUI.xcodeproj and Bolts.xcodeproj. The end result is that I dragged three frameworks compiled with bitcode into my project:

Parse.framework
ParseUI.framework
Bolts.framework

@flovilmart
Copy link
Contributor

That’s probably the issue as the sdk’s Are not built with bitcode, therefore there may be some issues when trying to use them this way.

@greensmartdev
Copy link
Author

I had absolutely no problems running my project until I tried to archive it with Xcode, then I got the "invalid bitcode signature" error. I have been trying to solve that problem for weeks.

That was what caused me to try to build the frameworks with bitcode, so that I could archive my project.

How can I archive my project when the SDKs are not built with bitcode, because even when setting "Enable Bitcode" to NO in my project build settings, cleaning, deleting derived data folder, restarting Xcode etc, I still get the "invalid bitcode signature". Extremely frustrating.

@flovilmart
Copy link
Contributor

I had absolutely no problems running my project until I tried to archive it with Xcode

You told me that removing the embed bitcode flag fixed the crash.

One thing for sure, the distributed SDK’s don’t have bitcode.

I’m not sure how your project should be configured but on thing is sure, if you want to use bitcode, you should build the SDK’s yourself.

I’ll leave it open in case another user has another idea.

Otherwise, I can’t help more without a demo project.

@flovilmart flovilmart reopened this Aug 4, 2018
@greensmartdev
Copy link
Author

You told me that removing the embed bitcode flag fixed the crash.

Yes, fixed it for running on device, but not for archiving. I want to submit the app to the app store and this has been holding me back from doing that for almost 4 weeks now.

@greensmartdev
Copy link
Author

greensmartdev commented Aug 4, 2018

if you want to use bitcode, you should build the SDK’s yourself.

I thought that was what I was doing by doing this

went to Parse.xcodeproj file, opened it in Xcode, set "Other C flags" equal to "-fembed-bitcode" in Build Settings, built the project, then went to the Products folder and located the "Parse.framework" file.

How else can I build the Parse, ParseUI and Bolts frameworks from source?

@flovilmart
Copy link
Contributor

flovilmart commented Aug 4, 2018

Ok so you build it yourself.

then went to the Products folder and located the "Parse.framework" file.

It's likely that the built framework is missing all the required architectures for the appstore

What is the output of:

lipo -info PATH_TO_PROJECT/Parse.framework/Parse

@greensmartdev
Copy link
Author

The output of the command is:

input file MyProject/Parse.framework/Parse is not a fat file
Non-fat file: Myproject/Parse.framework/Parse is architecture: arm64

@flovilmart
Copy link
Contributor

flovilmart commented Aug 4, 2018

That’s likely the issue, your binary is not compiled for armv7 nor armv7s.

You should

  • Drag the parse project into yours
  • Add Parse, Bolts etc... as a target dependency (picking either the dynamic or static target (your choicee))
  • At project level, set ENABLE_BITCODE = YES and / or set the other c flags if you want bitcode.

OTHERWISE:

  • use the provided downloadable SDK
  • disable bitcode in your project

@greensmartdev
Copy link
Author

That is strange, because "valid architectures" for the Parse, ParseUI and Bolts build is set to all three (arm64, armv7 and armv7s).

Also the error I am getting when trying to archive is "invalid bitcode signature". Can you get that kind of error message from missing architectures in a build?

@flovilmart
Copy link
Contributor

It’s not because valid architectures is set to that value means that all architectures are gonna be built.

Can you try doing what I suggested, one way or another?

Otherwise please come up with a demo project that reproduces the issue.

It’s clear that your problem is related to iOS build system and not the SDK

@greensmartdev
Copy link
Author

I followed your second suggestion and everything worked perfectly.

use the provided downloadable SDK, disable bitcode in your project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants