smart-on-fhir / Swift-SMART

Swift SMART on FHIR framework for iOS and OS X
Other
134 stars 47 forks source link

EXC_BAD_ACCESS #21

Open wuttke opened 6 years ago

wuttke commented 6 years ago

Hi!

When using the SMART classes, I encounter a EXC_BAD_ACCESS.

bildschirmfoto 2018-05-10 um 14 13 12

This happens both in the Demo project (regardless of the data source) and with a small own test app:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let myEndpoint = "https://hapi.fhir.org/baseDstu3"
        //var myFhirUrl = myEndpoint + "/Observation?patient=3352608&category=laboratory"

        let smart = Client(
            baseURL: URL(string: myEndpoint)!,
            settings: [:
            ]
        )

        smart.authProperties.granularity = .tokenOnly

        smart.authorize() { patient, error in
            if nil != error { //} || nil == patient {
            }
            else {
                Observation.search(["patient": "3352608", "category": "laboratory"])
                    .perform(smart.server) { bundle, error in
                        if nil != error {
                        }
                        else {
                        }
                }
            }
        }
    }
}
wuttke commented 6 years ago

This gives the same exception:

        let server = FHIRMinimalServer(baseURL: URL(string: "https://hapi.fhir.org/baseDstu3/")!)
        Observation.search(["patient": "3352608", "category": "laboratory"])
            .perform(server) { bundle, error in
// ...
        }
p2 commented 6 years ago

Try enabling "Thread Sanitizer" in build settings.

wuttke commented 6 years ago

Thanks for the feedback. I've enabled the Thread Sanitizer for my Build scheme. This caused the exception to disappear. Should I use the Thread Sanitizer all the time?

https://developer.apple.com/documentation/code_diagnostics/thread_sanitizer/enabling_the_thread_sanitizer

p2 commented 6 years ago

We should fix the root issue, enabling the sanitizer is just a workaround. :)

wuttke commented 6 years ago

Makes sense :-) Can I help?

p2 commented 6 years ago

PRs are always welcome!!

raheelsayeed commented 6 years ago

I've seen this happen only on xcode9.3 simulators. No error on testing on Device (11.3) . (With thread sanitizer disabled)