Crash using OpenMP library in a sandboxed app

I'm trying to add a feature to my app which requires OpenMP as third party library. The first time an openMP API gets called makes the app crash.

The Xcode terminal reports this:

OMP: Error #179: Function Can't open TEMP failed: OMP: System error #1: Operation not permitted Assertion failure at kmp_runtime.cpp(6918): temp_reg_status_file_name. OMP: Error #13: Assertion failure at kmp_runtime.cpp(6918).

Console app reports this:

Sandbox: deny(1) ipc-posix-shm-write-create /__KMP_REGISTERED_LIB_31975

I cannot substitute or get rid of the OpenMP library as it is used by other third party libs needed by the feature I’m developeng. Hope there is a workaround to the sandbox security restrictions that allows to use the lib.

Thanks, Andrea

DTS does not, in general, support open source libraries. However, you’ve managed to gather enough info to suggest a path forward. You wrote:

The Xcode terminal reports this:

… Operation not permitted …

That’s EPERM, which is a clear indication that you’ve hit an App Sandbox limit. See On File System Permissions for more about that.

Console app reports this:

Sandbox: deny(1) ipc-posix-shm-write-create /__KMP_REGISTERED_LIB_31975

And that suggests that this is related to the use of Posix shared memory. Which makes sense because the App Sandbox has a general goal of preventing IPC between unrelated processes. A sandboxed app can only use IPC to communicate with the system and with other processes from the same team.

In the case of Posix shared memory, the sandbox restricts the name you pass to shm_open (if you’re not familiar with shm_open, see shm_open man page). That restricted is documented here. In short, the name must be of the form GGG/NNN, where GGG is an app group name and NNN is a name you choose.

IMPORTANT The name is limited to PSHMNAMLEN (31) UTF-8 characters, so choose short values for GGG and NNN.

If you’re familiar with app groups from iOS, be aware that they’re different on macOS. See App Groups: macOS vs iOS: Fight!. In my test I used the SKMME9E2Y8.grp app group and a shared memory name of SKMME9E2Y8.grp/shm, where SKMME9E2Y8 is my Team ID.

Now all you have to do is convince OpenMP to use that name for its shared memory (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Crash using OpenMP library in a sandboxed app
 
 
Q