Crash on DispatchQueue only on Distribution

Hi!

The first thing, to say that all this works correctly debugging with XCode (Swift 4.2), the problem comes when uploading it to the AppStore that gives an error in the DispatchQueue, but I don't know how to see at what point it happens, seeing the log I can only see what happens in the DispatchQueue. This is what the log says, but they are all directions that I do not know how to interpret:


Thread 2 name: Dispatch queue: firmwareQueue

Thread 2 Crashed: .....

0 myapp 0x00..........

1 libdispatch.dylib 0x00..........

2 libdispatch.dylib 0x00..........

3 libswiftCore.dylib 0x00..........

4 myapp 0x00..........

5 myapp 0x00..........

...


In my program:

.....

let appDelegate = UIApplication.shared.delegate as! AppDelegate

let progress = ProgressDialog(delegate: appDelegate.viewControllerActive!)

progress.Show(animate: true, message: "Updating…") // NOT SHOWING

let firmwareQueue = DispatchQueue(label:"firmwareQueue");

firmwareQueue.async {

self.update_firmware(progress: progress) {

.....

}

}

.....


In the function 'update_firmware' it connects via BT with a device and once the connection is established a series of messages are exchanged. In this exchange of messages, a counter is kept to see what is missing from the process and is shown to the user through a progress screen. Progress should be displayed in the ProgressDialog, this is the code inside the update_firmware function to show it:

.....

DispatchQueue.main.async {

self.progress!.SetText(message: "Updating device…")

self.progress!.SetProgressTotal(progress: Float(totalBlockCount))

self.progress!.SetShowProgressbar(show: true);

}

....


Although the progress dialog is not displayed before starting to communicate with the device, it does communicate with it and exchange some messages (I see it on the device before the program crashes).


Does anyone have any idea how I can see the point where it happens? Or if something similar has happened to someone?


Thanks

If your app uses many asynchronous operations or queues, you may have some threading issue.

An app containing such threading issues might seemingly work in simulator but cause crash in actual device.


I cannot be sure if your app has such threading problem or not seeing just fragments of code.

Is it real code ?


What is

progress.Show(animate: true, message: "Updating…")    // NOT SHOWING

supposed to do ?


Is it a func you defined ?

- if so, please show the code

- otherwise, there is probably a mistake, as func names do begin with lowercase


Where is ProgressDialog defined ?

It is a form that I have created to show a progress bar. I think the problem is not there, because I have tried the process without the screen and the same thing happens. Also, I use that same form in another process in the same application and in that case it works fine.

Thanks!

Can you post the full crash report? The snippet in your first post is not enough to even tell how it’s crashing, and that informs how to debug this. For example, you’d take very different steps to investigate Swift trap as compared to a memory access exception.

Using the

<>
icon to format your crash report as a code block.

Also, if thread is involved you should definitely run your program with TSan. It’s great at threading bugs that are hard to reproduce normally.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I forgot to put the type of exception


Exception Type: EXC_BREAKPOINT (SIGTRAP)

Exception Codes: 0x0000000000000001, 0x0000000100ec32a0

Termination Signal: Trace/BPT trap: 5

Termination Reason: Namespace SIGNAL, Code 0x5

Terminating Process: exc handler [0]

Triggered by Thread: 2


I have managed not to get the error and it works correctly, there was a problem communicating with the device over BT. It seems to be what was causing the error, although I will check with TSan that everything is ok.


Thank you all!

An

EXC_BREAKPOINT
machine exception like this is usually caused by hitting a Swift trap, for example, force unwrapping an optional that’s nil, or accessing an array out of bounds. From the backtrace in your first post it looks like the trap occurred in your own code. You need to symbolicate that crash report to learn more.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Crash on DispatchQueue only on Distribution
 
 
Q