When can I run a synchronous code by executing DispatchQueue.main.sync { }?

I tried running the following code and it raises the following error every time:

DispatchQueue.main.sync { }

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I found this post on stackoverflow that says to never run synchronous code on the main queue:

DispatchQueue crashing with main.sync in Swift

I had assumed that because the sync { } method is there that means there is some context that it can be used. Is there absolutely no use for executing synchronous code on the main queue?

As explained in SO answer, context is to avoid deadlock. sync will block the main thread until it is completed, which may cause a deadlock.

Why do you want to use sync ?

When can I run a synchronous code by executing DispatchQueue.main.sync { }?
 
 
Q