EXC_BAD_ACCESS running iOS app
luciamaj opened this issue · 6 comments
Hi, great library.
I'm trying to run the swift example in a iOS project, the decoding is successful however the app immediately crashes after the decoding with a EXC_BAD_ACCESS error immediately after printing in the console the result. Any ideas?
Thank you.
Hi, thanks for the feedback.
What happens when you run the provided examples tests:
Do they also crash?
No, the examples run as expected, the code keeps executing when the decoding is done.
I was able to reproduce this issue on my iOS 14.4.1 device. Looks like it has something to do with the use of withUnsafeMutableBytes
.
I was able to successfully encode/decode whilst avoiding this crash with the following changes:
let payload = "test"
let n = ggwave_encode(instance, payload, 4, GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 50, nil, 1)
var ret: Int32 = 0
let payloadPointer = UnsafePointer<Int8>((payload as NSString).utf8String)
var decoded = Array<Int8>(repeating: 0, count: 256)
var waveform = Array<Int8>(repeating: 0, count: Int(n))
ret = ggwave_encode(instance, payloadPointer, 4, GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 50, &waveform, 0)
assert(ret > 0)
ret = ggwave_decode(instance, &waveform, Int32(2*ret), &decoded)
@r-ba Thanks so much for this. When I wrote this Swift example, I was just basically doing Stack Overflow - based programming (i.e. copy/pasting random snippets until it works)
When I reached the string comparison part at the end, I just gave up :)
I'm just happy to have been able to contribute something (albeit small) to such a cool project.
I assume this has been resolved