Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appnope crashes with segfault from subrocess #4

Closed
impact27 opened this issue Sep 23, 2019 · 6 comments
Closed

appnope crashes with segfault from subrocess #4

impact27 opened this issue Sep 23, 2019 · 6 comments

Comments

@impact27
Copy link

Steps:

  1. Add this code in a file:
from multiprocessing import Pool
import appnope

def f(x):
    appnope.nope()

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1]))
  1. Run with ipython crash.py
  2. Crash with a segfault and prints:
objc[2560]: +[NSString initialize] may have been in progress in another thread when fork() was called.
objc[2560]: +[NSString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
@impact27
Copy link
Author

Interestingly, using python instead of ipython doesn't trigger the crash.

@impact27
Copy link
Author

Also printing the PIDs:

Main Process PID: 2688
Subprocess PID: 2691
objc[2691]: +[NSString initialize] may have been in progress in another thread when fork() was called.
objc[2691]: +[NSString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

@impact27
Copy link
Author

https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr:
This solves it:
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
ipython crash.py

@impact27
Copy link
Author

@impact27
Copy link
Author

I think this is the relevant issue https://bugs.python.org/issue33725

@impact27
Copy link
Author

I am closing this as this is a python bug and not appnope related. I suspect that any objc code called in a subprocess will create the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant