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

Segmentation Fault on M1 Mac when importing datetime #481

Open
Matthias-Thul opened this issue Mar 7, 2022 · 5 comments
Open

Segmentation Fault on M1 Mac when importing datetime #481

Matthias-Thul opened this issue Mar 7, 2022 · 5 comments

Comments

@Matthias-Thul
Copy link

Matthias-Thul commented Mar 7, 2022

Hi,

I am on an M1 Mac and am getting the following when import datetime.

$ DOTNET_ROOT=/usr/local/share/dotnet/x64 python
Python 3.10.0 (default, Nov 10 2021, 11:24:47) [Clang 12.0.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyjion
>>> pyjion.enable()
True
>>> import datetime as dt
[1]    9010 segmentation fault  DOTNET_ROOT=/usr/local/share/dotnet/x64 python

Starting python with -q -X faulthandler gives the following additional output

Fatal Python error: Segmentation fault

Current thread 0x0000000200ae3600 (most recent call first):
  File "/Users/user/opt/anaconda3/envs/python-3.10/lib/python3.10/datetime.py", line 495 in __new__
  File "/Users/user/opt/anaconda3/envs/python-3.10/lib/python3.10/datetime.py", line 758 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<stdin>", line 1 in <module>

Extension modules: pyjion._pyjion (total: 1)

Here is what LLDB shows

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xf010fb40)
    frame #0: 0x000000010e143ae0
->  0x10e143ae0: movsd  -0x1e033fa8(%rip), %xmm0  ; xmm0 = mem[0],zero
    0x10e143ae8: movsd  %xmm0, -0xe0(%rbp)
    0x10e143af0: movq   -0x40(%rbp), %rdi
    0x10e143af4: movq   %rdi, -0x70(%rbp)
Target 0: (python3.10) stopped.
(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xf010fb40)
  * frame #0: 0x000000010e143ae0
    frame #1: 0x000000010dfd0ac5 _pyjion.cpython-310-darwin.so`PyJit_ExecuteJittedFrame(void*, _frame*, _ts*, PyjionJittedCode*) + 165
    frame #2: 0x000000010dfd09a4 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 1300
    frame #3: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #4: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #5: 0x0000000104bc3c8d python3.10`_PyObject_FastCallDictTstate + 237
    frame #6: 0x0000000104c52363 python3.10`slot_tp_new + 211
    frame #7: 0x0000000104c4ad35 python3.10`type_call + 69
    frame #8: 0x0000000104bc3986 python3.10`_PyObject_MakeTpCall + 134
    frame #9: 0x0000000104d01ba9 python3.10`call_function + 361
    frame #10: 0x0000000104cf7463 python3.10`_PyEval_EvalFrameDefault + 20467
    frame #11: 0x000000010dfd0788 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 760
    frame #12: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #13: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #14: 0x0000000104ceaee9 python3.10`builtin_exec + 345
    frame #15: 0x0000000104c26bb5 python3.10`cfunction_vectorcall_FASTCALL + 85
    frame #16: 0x000000010df9ae0e _pyjion.cpython-310-darwin.so`PyJit_CallKwArgs(_object*, _object*, _object*) + 286
    frame #17: 0x000000010df6412e
    frame #18: 0x000000010dfd0ac5 _pyjion.cpython-310-darwin.so`PyJit_ExecuteJittedFrame(void*, _frame*, _ts*, PyjionJittedCode*) + 165
    frame #19: 0x000000010dfd09a4 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 1300
    frame #20: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #21: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #22: 0x0000000104d01aee python3.10`call_function + 174
    frame #23: 0x0000000104cf9345 python3.10`_PyEval_EvalFrameDefault + 28373
    frame #24: 0x000000010dfd0788 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 760
    frame #25: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #26: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #27: 0x0000000104d01aee python3.10`call_function + 174
    frame #28: 0x0000000104cf7f6e python3.10`_PyEval_EvalFrameDefault + 23294
    frame #29: 0x000000010dfd0788 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 760
    frame #30: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #31: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #32: 0x0000000104d01aee python3.10`call_function + 174
    frame #33: 0x0000000104cf73ae python3.10`_PyEval_EvalFrameDefault + 20286
    frame #34: 0x000000010dfd0788 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 760
    frame #35: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #36: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #37: 0x0000000104d01aee python3.10`call_function + 174
    frame #38: 0x0000000104cf73ae python3.10`_PyEval_EvalFrameDefault + 20286
    frame #39: 0x000000010dfd0788 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 760
    frame #40: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #41: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #42: 0x0000000104bc5c9b python3.10`object_vacall + 427
    frame #43: 0x0000000104bc5f49 python3.10`_PyObject_CallMethodIdObjArgs + 249
    frame #44: 0x0000000104d38c44 python3.10`PyImport_ImportModuleLevelObject + 3076
    frame #45: 0x0000000104ce98f3 python3.10`builtin___import__ + 147
    frame #46: 0x0000000104c263c4 python3.10`cfunction_call + 52
    frame #47: 0x0000000104bc3986 python3.10`_PyObject_MakeTpCall + 134
    frame #48: 0x000000010df9a70c _pyjion.cpython-310-darwin.so`PyJit_ImportName(_object*, _object*, _object*, _frame*) + 220
    frame #49: 0x000000010de9d074
    frame #50: 0x000000010dfd0ac5 _pyjion.cpython-310-darwin.so`PyJit_ExecuteJittedFrame(void*, _frame*, _ts*, PyjionJittedCode*) + 165
    frame #51: 0x000000010dfd09a4 _pyjion.cpython-310-darwin.so`PyJit_ExecuteAndCompileFrame(PyjionJittedCode*, _frame*, _ts*, PyjionCodeProfile*) + 1300
    frame #52: 0x000000010dfd0e35 _pyjion.cpython-310-darwin.so`PyJit_EvalFrame(_ts*, _frame*, int) + 149
    frame #53: 0x0000000104cf0a6e python3.10`_PyEval_Vector + 382
    frame #54: 0x0000000104d67ac9 python3.10`PyRun_InteractiveOneObjectEx + 1049
    frame #55: 0x0000000104d6672a python3.10`_PyRun_InteractiveLoopObject + 122
    frame #56: 0x0000000104d65fdf python3.10`_PyRun_AnyFileObject + 63
    frame #57: 0x0000000104d6a2d6 python3.10`PyRun_AnyFileExFlags + 118
    frame #58: 0x0000000104d90f3f python3.10`pymain_run_stdin + 175
    frame #59: 0x0000000104d9058d python3.10`pymain_run_python + 509
    frame #60: 0x0000000104d90345 python3.10`Py_RunMain + 37
    frame #61: 0x0000000104d91920 python3.10`pymain_main + 64
    frame #62: 0x0000000104b46a28 python3.10`main + 56
    frame #63: 0x000000020500e4fe dyld`start + 462

Importing other modules and running some simple test functions works just fine.

@Matthias-Thul
Copy link
Author

Matthias-Thul commented Mar 7, 2022

Interestingly things work when changing the optimization level to 0.

Python 3.10.0 (default, Nov 10 2021, 11:24:47) [Clang 12.0.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyjion
>>> pyjion.enable()
True
>>> pyjion.config(level=0)
{'clrjitpath': '/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App/6.0.1/libclrjit.dylib', 'pgc': True, 'graph': False, 'debug': 0, 'level': 0, 'threshold': 0}
>>> import datetime as dt
>>>

@tonybaloney
Copy link
Owner

Yikes. Which version of Pyjion is this?

@Matthias-Thul
Copy link
Author

This is 1.2.6.

@Matthias-Thul
Copy link
Author

Anything else I can provide to help investigating this?

@tonybaloney
Copy link
Owner

Please can you run Python in development mode (-X dev) to enable the crash handler and give a traceback to which function is crashing.

I can't reproduce on an Intel CPU

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

2 participants