-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Segfault on OSX with 3.6.1 #74570
Comments
This script, using requests and multiprocessing, will segfault on MacOS 16.4.0 with python 3.6.1. In 3.6.0 it runs fine. The program is reduced from a much larger program, some weird things need to be present to trigger the crash. For instance the unused tornado imports on the top. Crash log: Process: Python [1510] Date/Time: 2017-05-17 14:23:47.307 +0200 Sleep/Wake UUID: 03D0B108-E764-4834-A88D-7919CAF9B786 Time Awake Since Boot: 630 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.os.log Exception Type: EXC_BAD_ACCESS (SIGSEGV) Termination Signal: Segmentation fault: 11 VM Regions Near 0x10b692832: Application Specific Information: Thread 0 Crashed:: Dispatch queue: com.apple.os.log Thread 0 crashed with X86 Thread State (64-bit): Logical CPU: 1 Binary Images: External Modification Summary: VM Region Summary:
REGION TYPE SIZE COUNT (non-coalesced) Model: MacBookPro12,1, BootROM MBP121.0167.B21, 2 processors, Intel Core i5, 2,9 GHz, 16 GB, SMC 2.28f7 |
I am unable to reduce it to a small(ish) test-case like for 3.6.1, but I can also get 2.7.1 to seg fault in my original program, and the stack trace is similar: Process: Python [4023] Date/Time: 2017-05-17 15:04:48.824 +0200 Sleep/Wake UUID: 03D0B108-E764-4834-A88D-7919CAF9B786 Time Awake Since Boot: 3000 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.os.log Exception Type: EXC_BAD_ACCESS (SIGSEGV) Termination Signal: Segmentation fault: 11 VM Regions Near 0x10617c832: Application Specific Information: Thread 0 Crashed:: Dispatch queue: com.apple.os.log Thread 0 crashed with X86 Thread State (64-bit): Logical CPU: 3 Binary Images: External Modification Summary: VM Region Summary:
REGION TYPE SIZE COUNT (non-coalesced) Model: MacBookPro12,1, BootROM MBP121.0167.B21, 2 processors, Intel Core i5, 2,9 GHz, 16 GB, SMC 2.28f7 |
I am currently (occasionally) running into the same problem, using Python 3.6.0 on OSX 10.12.3. I cannot reproduce this segmentation fault reliably, it happens after running for a while in production. This appears to be similar to bpo-13829. python traceback (trimmed): Fatal Python error: Segmentation fault Current thread 0x00007000065fb000 (most recent call first): crash dump traceback (trimmed):
|
Unfortunately, his is a long standing problem when using Python applications that fork on macOS and that end up calling certain system frameworks that under the covers use the system libdispatch which is not fork safe. In this case, it is most likely due to a call to s urllib function that results in a call to Python's helper module _scproxy to query the macOS system configuration for network proxies. If your application and system are not using a proxy, the simplest workaround is to disable network proxy lookups by defining the environment variable 'no_proxy' with value '*' in the Python process, for example: env no_proxy='*' python3.6 ... Otherwise, restructuring your code to ensure network initialization occurs in the main thread before any forking *might* also prevent the segfault. |
Adding env no_proxy='*' does indeed fix it! Thanks a lot! I guess it's pretty hard to fix. Or even to detect, so that one could log a warning before dying :( |
A pythonic way to do it is |
thanks for the info. previous comment shows why double quotes should not be used as string delimiters. paste that line in a python script and see what happens. here's the proper form: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: