Swift-SMART icon indicating copy to clipboard operation
Swift-SMART copied to clipboard

EXC_BAD_ACCESS

Open wuttke opened this issue 6 years ago • 7 comments

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 avatar May 10 '18 12:05 wuttke

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
// ...
        }

wuttke avatar May 10 '18 13:05 wuttke

Try enabling "Thread Sanitizer" in build settings.

p2 avatar May 11 '18 04:05 p2

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

wuttke avatar May 11 '18 16:05 wuttke

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

p2 avatar May 11 '18 16:05 p2

Makes sense :-) Can I help?

wuttke avatar May 11 '18 16:05 wuttke

PRs are always welcome!!

p2 avatar May 11 '18 16:05 p2

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

raheelsayeed avatar May 11 '18 21:05 raheelsayeed