Undocumented Swift? “pause()” global function that break the app

Tested in Xcode 14 and Swift Playgrounds 4.

From any part of code we can call a “pause()” function and the app becomes unresponsive and sometimes (after some time) the Mac start heating and the Xcode crash.

Code examples:

Button("Test") {
    pause()
}

class Model {
    func test() {
        pause()
    }
}

func test() {
    pause()
}

Private API? Bug? Security flaw?

Undocumented

If a function happens to be visible to the compiler but is undocumented, then (1) why are you calling it?, and (2) what do you expect it to do?

Swift?

In this case, it’s not a function intended to be used from Swift programs, and especially not from SwiftUI. It’s actually an ancient C function in the underlying Darwin OS that happens to be available (maybe it could be useful to some types of program) but has no practical use. If you view the documentation (via man pause) then the manual page is dated 1993, and says the function first appeared in Version 6 AT&T UNIX which dates from 1975. Groovy!

And the description in the manual page shows that what this function does is definitely not what you would want.

Private API? Bug? Security flaw?

I’d vote “not really” to all of those, but one could probably engage in a very nerdy discussion around that.

I’m not calling it, don’t looked for it, just discovered it accidentally and asked why this “c function” that break the app can be called from Swift.

Undocumented Swift? “pause()” global function that break the app
 
 
Q