Hello,
I am getting an EXC_BREAKPOINT and trying figure out how to debug this crash.
Some background on func getDecodeResults(noOfDecodes: ) which the crashlog is pointing to:
I believe this crash might be related to the unsafe pointers I'm using for communication between our C code and Swift. Below are the relevant implementation details:
I create an UnsafeMutablePointer for a struct type DECODE_RESULTS, defined internally.
The Swift code allocates fixed memory for this pointer, which is then passed to a C library for initialization and modification.
In the getDecodeResults function (where the crash log points), the first step is converting a C array starting at the UnsafeMutablePointer into a Swift array.
Here’s a snippet for context:
// In class initialization:
private var decodeResults: UnsafeMutablePointer<DECODE_RESULTS>
decodeResults = UnsafeMutablePointer<DECODE_RESULTS>.allocate(capacity: maxNumberOfBarcodes)
// Initialize decodeResults in the C library
// In getDecodeResults function:
let results = Array(UnsafeBufferPointer(start: decodeResults, count: Int(noOfDecodes)))
Crash Log:
Thread 6 name: Dispatch queue: com.padlocdocks.padlocscan.PLSBarcodeScanner._scanQueue
Thread 6 Crashed:
0 AilaDecoder 0x101d995a8 DecoderManager.getDecodeResults(noOfDecodes:) (in AilaDecoder) (DecoderManager.swift:0) + 38312
I'm unsure if (DecoderManager.swift:0) indicates the root cause or if it’s an erroneous reference.
01 AilaDemo-2025-01-17-041022_symbolicated.txt