Open sledgeh4w opened 1 week ago
Yes, exactly. You are nesting uc_emu_start, which could potentially leads to this crash. Temporary workaround is not calling uc_emu_start in any callbacks.
Thanks, I understand. Do you have any plans to solve this problem in the future?
Additionally, there may be problem with the dylib provided in the wheel, as it cannot even run the most basic samples in my environment.
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Python [34106]
Path: /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 3.10.11 (3.10.11)
Code Type: ARM-64 (Native)
Parent Process: zsh [27245]
Responsible: Terminal [661]
User ID: 502
Date/Time: 2024-10-17 13:04:44.7661 +0800
OS Version: macOS 14.2 (23C64)
Report Version: 12
Anonymous UUID: 3C136E55-0B58-2F1D-FB15-5C5259FAED20
Sleep/Wake UUID: BCA95C49-7928-4E46-AB51-4FD28416BD82
Time Awake Since Boot: 84000 seconds
Time Since Wake: 495 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000280000000
Exception Codes: 0x0000000000000002, 0x0000000280000000
Termination Reason: Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process: exc handler [34106]
VM Region Info: 0x280000000 is in 0x280000000-0x2c0000000; bytes after start: 0 bytes before end: 1073741823
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
unused __TEXT 27b6a4000-27b6a8000 [ 16K] r--/r-- SM=COW ...ed lib __TEXT
GAP OF 0x4958000 BYTES
---> VM_ALLOCATE 280000000-2c0000000 [ 1.0G] rwx/rwx SM=PRV
GAP OF 0xd00000000 BYTES
commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libunicorn.2.dylib 0x105d9c654 tcg_prologue_init_aarch64 + 88
1 libunicorn.2.dylib 0x105dcc6a0 tcg_exec_init_aarch64 + 324
2 libunicorn.2.dylib 0x105c1d6ec machine_initialize + 88
3 libunicorn.2.dylib 0x105c19354 uc_init_engine + 164
4 libunicorn.2.dylib 0x105c1a95c uc_mem_map + 548
5 libffi.dylib 0x19a546050 ffi_call_SYSV + 80
6 libffi.dylib 0x19a54eadc ffi_call_int + 1208
7 _ctypes.cpython-310-darwin.so 0x1031bc2a8 _ctypes_callproc + 1396
8 _ctypes.cpython-310-darwin.so 0x1031b6338 PyCFuncPtr_call + 208
9 Python 0x103ad4cf8 _PyObject_MakeTpCall + 136
10 Python 0x103c0b238 call_function + 380
11 Python 0x103c03470 _PyEval_EvalFrameDefault + 23772
12 Python 0x103bfbf28 _PyEval_Vector + 360
13 Python 0x103c0b140 call_function + 132
14 Python 0x103c0247c _PyEval_EvalFrameDefault + 19688
15 Python 0x103bfbf28 _PyEval_Vector + 360
16 Python 0x103c0b140 call_function + 132
17 Python 0x103c0247c _PyEval_EvalFrameDefault + 19688
18 Python 0x103bfbf28 _PyEval_Vector + 360
19 Python 0x103c0b140 call_function + 132
20 Python 0x103c0247c _PyEval_EvalFrameDefault + 19688
21 Python 0x103bfbf28 _PyEval_Vector + 360
22 Python 0x103ad5020 _PyObject_FastCallDictTstate + 208
23 Python 0x103b696e0 slot_tp_init + 196
24 Python 0x103b604e0 type_call + 312
25 Python 0x103ad4cf8 _PyObject_MakeTpCall + 136
26 Python 0x103c0b238 call_function + 380
27 Python 0x103c01be0 _PyEval_EvalFrameDefault + 17484
28 Python 0x103bfbf28 _PyEval_Vector + 360
29 Python 0x103ad5020 _PyObject_FastCallDictTstate + 208
30 Python 0x103b696e0 slot_tp_init + 196
31 Python 0x103b604e0 type_call + 312
32 Python 0x103ad4cf8 _PyObject_MakeTpCall + 136
33 Python 0x103c0b238 call_function + 380
34 Python 0x103c01be0 _PyEval_EvalFrameDefault + 17484
35 Python 0x103bfbf28 _PyEval_Vector + 360
36 Python 0x103c0b140 call_function + 132
37 Python 0x103c01b5c _PyEval_EvalFrameDefault + 17352
38 Python 0x103bfbf28 _PyEval_Vector + 360
39 Python 0x103c66c54 pyrun_file + 308
40 Python 0x103c66398 _PyRun_SimpleFileObject + 336
41 Python 0x103c659e4 _PyRun_AnyFileObject + 216
42 Python 0x103c91dd0 pymain_run_file_obj + 180
43 Python 0x103c91470 pymain_run_file + 72
44 Python 0x103c90a58 pymain_run_python + 300
45 Python 0x103c908ec Py_RunMain + 24
46 Python 0x103c91f78 pymain_main + 56
47 Python 0x103c9223c Py_BytesMain + 40
48 dyld 0x1896510e0 start + 2360
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x00000001080c0000 x1: 0x0000000040000000 x2: 0x00000000ffffffff x3: 0x0000000000041802
x4: 0x00000000ffffffff x5: 0x0000000000000000 x6: 0x0000000000000021 x7: 0x0000000000000002
x8: 0x000000010670f000 x9: 0x00000002c0000000 x10: 0x0000000000002026 x11: 0x0000000005ffa000
x12: 0x000000000000d49d x13: 0x0000000000000009 x14: 0x00000000000007fb x15: 0x000000009dc88ffb
x16: 0x0000000189992254 x17: 0x000000000000d187 x18: 0x0000000000000000 x19: 0x00000001080c0000
x20: 0x0000000280000000 x21: 0x0000000280000000 x22: 0x0000000040000000 x23: 0x000000016d149050
x24: 0x0000000000000000 x25: 0x0000000000000000 x26: 0x0000000000000004 x27: 0x0000000000000004
x28: 0x000000016d149008 fp: 0x000000016d148da0 lr: 0x0000000105dcc6a0
sp: 0x000000016d148d80 pc: 0x0000000105d9c654 cpsr: 0x20001000
far: 0x0000000280000000 esr: 0x9200004f (Data Abort) byte write Permission fault
Binary Images:
0x1039f0000 - 0x1039f3fff _uuid.cpython-310-darwin.so (*) <5406893a-16a9-3917-a57c-a18c30673b38> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_uuid.cpython-310-darwin.so
0x103a1c000 - 0x103a2ffff _datetime.cpython-310-darwin.so (*) <2f82bafe-ae6c-3ba1-b5eb-6e28f8c0dd9a> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_datetime.cpython-310-darwin.so
0x103310000 - 0x103313fff _queue.cpython-310-darwin.so (*) <421c1fa3-f6da-33d4-a43e-3e744dbe86d8> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_queue.cpython-310-darwin.so
0x103234000 - 0x103237fff _heapq.cpython-310-darwin.so (*) <46bf4b96-5b44-3371-92d8-bdaf78687925> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_heapq.cpython-310-darwin.so
0x10396c000 - 0x103983fff _pickle.cpython-310-darwin.so (*) <a9a32f5b-90ee-322a-95ef-0e49ca3071bc> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_pickle.cpython-310-darwin.so
0x1039a8000 - 0x1039b3fff array.cpython-310-darwin.so (*) <502fda2b-73c2-3caa-a980-e4f282becc61> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/array.cpython-310-darwin.so
0x103210000 - 0x10321ffff _socket.cpython-310-darwin.so (*) <7422f970-d83c-3060-8807-dd28ffe7fb58> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_socket.cpython-310-darwin.so
0x1032fc000 - 0x1032fffff resource.cpython-310-darwin.so (*) <db02e1a1-4927-3447-aad4-fa49616d354d> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/resource.cpython-310-darwin.so
0x104cd4000 - 0x105157fff _lief.so (*) <4c4c4441-5555-3144-a1f8-7f67f50e3728> /Users/USER/*/_lief.so
0x105c14000 - 0x106773fff libunicorn.2.dylib (*) <3fa35811-2cad-303d-8488-f547f880d8bb> /Users/USER/*/libunicorn.2.dylib
0x1045e4000 - 0x104b57fff libcapstone.dylib (*) <21a25ccd-589f-36eb-b38c-b159f4a70161> /Users/USER/*/libcapstone.dylib
0x1032e4000 - 0x1032ebfff binascii.cpython-310-darwin.so (*) <f619bcc2-4d06-34f7-ae65-8001170d28a7> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/binascii.cpython-310-darwin.so
0x1032d0000 - 0x1032d3fff _sha512.cpython-310-darwin.so (*) <b8911246-bb80-3ad9-8ecb-d17357ac6122> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_sha512.cpython-310-darwin.so
0x1032bc000 - 0x1032bffff _random.cpython-310-darwin.so (*) <b0e2bf49-f1db-3ea8-b7b9-99823e9c84ec> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_random.cpython-310-darwin.so
0x1032a8000 - 0x1032abfff _bisect.cpython-310-darwin.so (*) <a37eb635-fe7a-3d44-b1ba-3bb7dc7b0e14> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bisect.cpython-310-darwin.so
0x103294000 - 0x103297fff _opcode.cpython-310-darwin.so (*) <6aabe736-53ef-3a3d-9492-e0edaf02007b> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_opcode.cpython-310-darwin.so
0x103324000 - 0x103353fff _lzma.cpython-310-darwin.so (*) <13cfe756-b593-353d-bfcf-a74de53f6135> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_lzma.cpython-310-darwin.so
0x103280000 - 0x103283fff _bz2.cpython-310-darwin.so (*) <3d88ed77-d0ef-329d-9f57-4c94ae0b28e4> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bz2.cpython-310-darwin.so
0x103264000 - 0x10326bfff zlib.cpython-310-darwin.so (*) <2ef52731-249d-3f3d-ade2-f68b45332f10> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/zlib.cpython-310-darwin.so
0x103248000 - 0x10324ffff _struct.cpython-310-darwin.so (*) <133bfe87-3bd9-3bd6-9afe-c0b504af5b78> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_struct.cpython-310-darwin.so
0x1031b0000 - 0x1031c3fff _ctypes.cpython-310-darwin.so (*) <8710ee5e-53a1-3c8e-a6be-35fba5383f42> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_ctypes.cpython-310-darwin.so
0x1031f0000 - 0x1031fbfff math.cpython-310-darwin.so (*) <44e05e35-d5f1-37c1-bd86-cc43e0de1bbf> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so
0x103160000 - 0x103167fff select.cpython-310-darwin.so (*) <06443efd-a639-3015-833c-f473f172608c> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/select.cpython-310-darwin.so
0x10319c000 - 0x10319ffff _posixsubprocess.cpython-310-darwin.so (*) <d28f8d29-7210-37d1-964f-a77a83f76c3f> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so
0x103188000 - 0x10318bfff fcntl.cpython-310-darwin.so (*) <f8cce0d7-6b5e-3da9-a207-fb714939b81c> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/fcntl.cpython-310-darwin.so
0x103a58000 - 0x103db7fff org.python.python (3.10.11, (c) 2001-2023 Python Software Foundation.) <3fe90b0d-d091-3b4e-ac7c-15d5cf743818> /Library/Frameworks/Python.framework/Versions/3.10/Python
0x102cb4000 - 0x102cb7fff org.python.python (3.10.11) <ef677878-e7fb-329d-bb8b-0f651210d52b> /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
0x19a53e000 - 0x19a54f64f libffi.dylib (*) <3d2c1bb7-e1c9-3831-976a-c1acd53e7ab7> /usr/lib/libffi.dylib
0x18964b000 - 0x1896df347 dyld (*) <324e4ad9-e01f-3183-b09f-3e20b326643a> /usr/lib/dyld
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
0x189990000 - 0x1899cafff libsystem_kernel.dylib (*) <ca94fc21-bc40-3b43-b65d-b87ece9e1d48> /usr/lib/system/libsystem_kernel.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=1.0G resident=0K(0%) swapped_out_or_unallocated=1.0G(100%)
Writable regions: Total=2.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=2.1G(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Kernel Alloc Once 32K 1
MALLOC 1.1G 25
MALLOC guard page 96K 6
STACK GUARD 16K 1
Stack 16.0M 1
VM_ALLOCATE 1.0G 14
__AUTH 339K 65
__AUTH_CONST 4056K 147
__DATA 3343K 168
__DATA_CONST 6929K 175
__DATA_DIRTY 365K 59
__LINKEDIT 896.2M 28
__OBJC_RO 71.1M 1
__OBJC_RW 2168K 1
__TEXT 145.5M 182
dyld private memory 272K 2
shared memory 32K 2
=========== ======= =======
TOTAL 3.2G 878
Thanks, I understand. Do you have any plans to solve this problem in the future?
This is easy to solve if you could provide a smaller reproduction. Usually just we forget to save/restore JIT status before entering JIT regions.
Additionally, there may be problem with the dylib provided in the wheel, as it cannot even run the most basic samples in my environment.
I have no idea about this. The building environment should be the same or there might be Github Action bugs. Again, we need a reproduction to locate this issue.
But we will soon test the shipped wheel before distribution in #2026
I will find a way to simply reproduce it.
I have no idea about this. The building environment should be the same or there might be Github Action bugs. Again, we need a reproduction to locate this issue.
The second issue will occur to mu.mem_map(ADDRESS, 2 * 1024 * 1024)
in sample_arm64.
I have no idea about this. The building environment should be the same or there might be Github Action bugs. Again, we need a reproduction to locate this issue.
The second issue will occur to
mu.mem_map(ADDRESS, 2 * 1024 * 1024)
in sample_arm64.
Full script?
I have no idea about this. The building environment should be the same or there might be Github Action bugs. Again, we need a reproduction to locate this issue.
The second issue will occur to
mu.mem_map(ADDRESS, 2 * 1024 * 1024)
in sample_arm64.Full script?
That works on my mbp. Are you on dev branch and what error do you get?
I just installed unicorn using pip in a project that only has sample_arm64.
(.venv) yanglizhi@U-143GQMLJ-2215 pythonProject1 % pip install unicorn
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting unicorn
Using cached https://mirrors.aliyun.com/pypi/packages/08/a7/c109d5d76ed42ea8c620e4de91e8f1003424d10fd3c908649d19af2b9a3f/unicorn-2.1.1-py2.py3-none-macosx_11_0_arm64.whl (12.0 MB)
Installing collected packages: unicorn
Successfully installed unicorn-2.1.1
[notice] A new release of pip is available: 23.2.1 -> 24.2
[notice] To update, run: pip install --upgrade pip
(.venv) yanglizhi@U-143GQMLJ-2215 pythonProject1 % python3 sample_arm64.py
Emulate ARM64 code
zsh: bus error python3 sample_arm64.py
(.venv) yanglizhi@U-143GQMLJ-2215 pythonProject1 %
The crash log is:
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Python [56382]
Path: /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 3.10.11 (3.10.11)
Code Type: ARM-64 (Native)
Parent Process: zsh [55787]
Responsible: pycharm [678]
User ID: 502
Date/Time: 2024-10-17 17:02:36.2347 +0800
OS Version: macOS 14.2 (23C64)
Report Version: 12
Anonymous UUID: 3C136E55-0B58-2F1D-FB15-5C5259FAED20
Sleep/Wake UUID: 966CA212-6777-475D-B076-3B60FE5E45ED
Time Awake Since Boot: 97000 seconds
Time Since Wake: 8673 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000280000000
Exception Codes: 0x0000000000000002, 0x0000000280000000
Termination Reason: Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process: exc handler [56382]
VM Region Info: 0x280000000 is in 0x280000000-0x2c0000000; bytes after start: 0 bytes before end: 1073741823
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
unused __TEXT 27b6a4000-27b6a8000 [ 16K] r--/r-- SM=COW ...ed lib __TEXT
GAP OF 0x4958000 BYTES
---> VM_ALLOCATE 280000000-2c0000000 [ 1.0G] rwx/rwx SM=PRV
GAP OF 0xd00000000 BYTES
commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libunicorn.2.dylib 0x11a8c8654 tcg_prologue_init_aarch64 + 88
1 libunicorn.2.dylib 0x11a8f86a0 tcg_exec_init_aarch64 + 324
2 libunicorn.2.dylib 0x11a7496ec machine_initialize + 88
3 libunicorn.2.dylib 0x11a745354 uc_init_engine + 164
4 libunicorn.2.dylib 0x11a74695c uc_mem_map + 548
5 libffi.dylib 0x19a546050 ffi_call_SYSV + 80
6 libffi.dylib 0x19a54eadc ffi_call_int + 1208
7 _ctypes.cpython-310-darwin.so 0x104e002a8 _ctypes_callproc + 1396
8 _ctypes.cpython-310-darwin.so 0x104dfa338 PyCFuncPtr_call + 208
9 Python 0x105708cf8 _PyObject_MakeTpCall + 136
10 Python 0x10583f238 call_function + 380
11 Python 0x105837470 _PyEval_EvalFrameDefault + 23772
12 Python 0x10582ff28 _PyEval_Vector + 360
13 Python 0x10583f140 call_function + 132
14 Python 0x10583647c _PyEval_EvalFrameDefault + 19688
15 Python 0x10582ff28 _PyEval_Vector + 360
16 Python 0x10583f140 call_function + 132
17 Python 0x105835b5c _PyEval_EvalFrameDefault + 17352
18 Python 0x10582ff28 _PyEval_Vector + 360
19 Python 0x10589ac54 pyrun_file + 308
20 Python 0x10589a398 _PyRun_SimpleFileObject + 336
21 Python 0x1058999e4 _PyRun_AnyFileObject + 216
22 Python 0x1058c5dd0 pymain_run_file_obj + 180
23 Python 0x1058c5470 pymain_run_file + 72
24 Python 0x1058c4a58 pymain_run_python + 300
25 Python 0x1058c48ec Py_RunMain + 24
26 Python 0x1058c5f78 pymain_main + 56
27 Python 0x1058c623c Py_BytesMain + 40
28 dyld 0x1896510e0 start + 2360
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000108018000 x1: 0x0000000040000000 x2: 0x00000000ffffffff x3: 0x0000000000041802
x4: 0x00000000ffffffff x5: 0x0000000000000000 x6: 0x000000000000000a x7: 0x0000000000000000
x8: 0x000000011b23b000 x9: 0x00000002c0000000 x10: 0x0000000000002026 x11: 0x0000000005ffa000
x12: 0x00000000000009fc x13: 0x0000000000000009 x14: 0x00000000000007fb x15: 0x0000000080eff7fb
x16: 0x0000000189992254 x17: 0x000000000000d187 x18: 0x0000000000000000 x19: 0x0000000108018000
x20: 0x0000000280000000 x21: 0x0000000280000000 x22: 0x0000000040000000 x23: 0x000000016b516340
x24: 0x0000000000000000 x25: 0x0000000000000000 x26: 0x0000000000000004 x27: 0x0000000000000004
x28: 0x000000016b5162f8 fp: 0x000000016b516090 lr: 0x000000011a8f86a0
sp: 0x000000016b516070 pc: 0x000000011a8c8654 cpsr: 0x20001000
far: 0x0000000280000000 esr: 0x9200004f (Data Abort) byte write Permission fault
Binary Images:
0x11a740000 - 0x11b29ffff libunicorn.2.dylib (*) <3fa35811-2cad-303d-8488-f547f880d8bb> /Users/USER/*/libunicorn.2.dylib
0x1050d4000 - 0x1050dbfff binascii.cpython-310-darwin.so (*) <f619bcc2-4d06-34f7-ae65-8001170d28a7> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/binascii.cpython-310-darwin.so
0x105068000 - 0x10506bfff _sha512.cpython-310-darwin.so (*) <b8911246-bb80-3ad9-8ecb-d17357ac6122> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_sha512.cpython-310-darwin.so
0x105090000 - 0x105093fff _random.cpython-310-darwin.so (*) <b0e2bf49-f1db-3ea8-b7b9-99823e9c84ec> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_random.cpython-310-darwin.so
0x104db4000 - 0x104db7fff _bisect.cpython-310-darwin.so (*) <a37eb635-fe7a-3d44-b1ba-3bb7dc7b0e14> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bisect.cpython-310-darwin.so
0x104d94000 - 0x104d9ffff math.cpython-310-darwin.so (*) <44e05e35-d5f1-37c1-bd86-cc43e0de1bbf> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so
0x105200000 - 0x10522ffff _lzma.cpython-310-darwin.so (*) <13cfe756-b593-353d-bfcf-a74de53f6135> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_lzma.cpython-310-darwin.so
0x105054000 - 0x105057fff _bz2.cpython-310-darwin.so (*) <3d88ed77-d0ef-329d-9f57-4c94ae0b28e4> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bz2.cpython-310-darwin.so
0x105038000 - 0x10503ffff zlib.cpython-310-darwin.so (*) <2ef52731-249d-3f3d-ade2-f68b45332f10> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/zlib.cpython-310-darwin.so
0x104f24000 - 0x104f27fff _opcode.cpython-310-darwin.so (*) <6aabe736-53ef-3a3d-9492-e0edaf02007b> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_opcode.cpython-310-darwin.so
0x104dcc000 - 0x104dd3fff _struct.cpython-310-darwin.so (*) <133bfe87-3bd9-3bd6-9afe-c0b504af5b78> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_struct.cpython-310-darwin.so
0x104df4000 - 0x104e07fff _ctypes.cpython-310-darwin.so (*) <8710ee5e-53a1-3c8e-a6be-35fba5383f42> /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_ctypes.cpython-310-darwin.so
0x10568c000 - 0x1059ebfff org.python.python (3.10.11, (c) 2001-2023 Python Software Foundation.) <3fe90b0d-d091-3b4e-ac7c-15d5cf743818> /Library/Frameworks/Python.framework/Versions/3.10/Python
0x1048e8000 - 0x1048ebfff org.python.python (3.10.11) <ef677878-e7fb-329d-bb8b-0f651210d52b> /Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
0x19a53e000 - 0x19a54f64f libffi.dylib (*) <3d2c1bb7-e1c9-3831-976a-c1acd53e7ab7> /usr/lib/libffi.dylib
0x18964b000 - 0x1896df347 dyld (*) <324e4ad9-e01f-3183-b09f-3e20b326643a> /usr/lib/dyld
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
0x189990000 - 0x1899cafff libsystem_kernel.dylib (*) <ca94fc21-bc40-3b43-b65d-b87ece9e1d48> /usr/lib/system/libsystem_kernel.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=1.0G resident=0K(0%) swapped_out_or_unallocated=1.0G(100%)
Writable regions: Total=2.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=2.1G(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Kernel Alloc Once 32K 1
MALLOC 1.1G 29
MALLOC guard page 96K 6
STACK GUARD 16K 1
Stack 16.0M 1
VM_ALLOCATE 1.0G 6
__AUTH 339K 65
__AUTH_CONST 4056K 147
__DATA 3135K 155
__DATA_CONST 5201K 162
__DATA_DIRTY 365K 59
__LINKEDIT 895.4M 15
__OBJC_RO 71.1M 1
__OBJC_RW 2168K 1
__TEXT 135.1M 169
dyld private memory 272K 2
shared memory 32K 2
=========== ======= =======
TOTAL 3.2G 822
If I use locally compiled dylib, this problem would not occur.
If I use locally compiled dylib, this problem would not occur.
I have no idea why the built dynamic libraries by Github Action is failed but #2026 will surely address this by testing the wheels before uploading to pypi. This will be shipped along with 2.1.2, probably before the end of this month.
Locally testing shows that probably the JIT state is not switched but no idea why.
I have found a solution to the first problem, remove a judgment condition in cpu_tb_exec
.
if (cpu->uc->nested_level == 1) {
// Only unlock (allow writing to JIT area) if we are the outmost uc_emu_start
tb_exec_unlock(cpu->uc);
}
=>
tb_exec_unlock(cpu->uc);
After this, my program can work normally.
Meanwhile, I noticed that this judgment condition was specifically added by you in the commit.
This would fail other cases. I remember I added corresponding cases and you can run ctest to check.
Generally, the root cause is that we allow users to re-entry the JIT area and the area is shared all together. It’s hard to determine the correct state given current design.
ctest all passed.
yanglizhi@U-143GQMLJ-2215 build % ctest
Test project /Users/yanglizhi/Projects/unicorn/build
Start 1: test_x86
1/12 Test #1: test_x86 ......................... Passed 1.95 sec
Start 2: test_arm
2/12 Test #2: test_arm ......................... Passed 0.32 sec
Start 3: test_arm64
3/12 Test #3: test_arm64 ....................... Passed 0.29 sec
Start 4: test_m68k
4/12 Test #4: test_m68k ........................ Passed 0.28 sec
Start 5: test_mips
5/12 Test #5: test_mips ........................ Passed 0.27 sec
Start 6: test_sparc
6/12 Test #6: test_sparc ....................... Passed 0.27 sec
Start 7: test_ppc
7/12 Test #7: test_ppc ......................... Passed 0.27 sec
Start 8: test_riscv
8/12 Test #8: test_riscv ....................... Passed 0.29 sec
Start 9: test_s390x
9/12 Test #9: test_s390x ....................... Passed 0.27 sec
Start 10: test_tricore
10/12 Test #10: test_tricore ..................... Passed 0.26 sec
Start 11: test_mem
11/12 Test #11: test_mem ......................... Passed 0.27 sec
Start 12: test_ctl
12/12 Test #12: test_ctl ......................... Passed 0.29 sec
100% tests passed, 0 tests failed out of 12
Total Test time (real) = 5.05 sec
There are two judgment conditions in your commit, removing the condition in cpu_exec_common.c
will cause the test to fail, but removing the condition in cpu_exec.c
will not.
I can't remember the exact context of this commit and I will have a check.
By the way, could have a try with the wheel from here: https://github.com/unicorn-engine/unicorn/actions/runs/11385747394 (note artifacts below)
By the way, could have a try with the wheel from here: https://github.com/unicorn-engine/unicorn/actions/runs/11385747394 (note artifacts below)
Still crashing. Is my system version or CPU is too new (14.2 + M3 Pro) ?
By the way, could have a try with the wheel from here: https://github.com/unicorn-engine/unicorn/actions/runs/11385747394 (note artifacts below)
Still crashing. Is my system version or CPU is too new (14.2 + M3 Pro) ?
That's weird, these wheels pass all simple tests (including the sample you mentioned)
I use Unicorn to emulate iOS executable file. It works normally on Windows, Linux, and macOS x86, but crashes on Apple Silicon (Not all scenes will crash, but they can be stably reproduced).
The environment I am using is macOS 14.2 with M3 pro.
The error message is:
The crash log is:
I noticed this crash log is similar to stackoverflow, so I guess it may also be due to the same reason.
Reproduce this issue: