Apple silicon: loading a save state crashes with SIGBUS in state_read (write to a read-only page)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp, macos
- Lĩnh vực
- backend, mobile-dev
Hướng nghiên cứu
Start by reading libretro-common/faulthandler/faulthandler.c, cpu_thread_entry, state_read, and VMManager::Internal::ClearCPUExecutionCaches(); the report identifies these paths but does not name tests. Reproduce on Apple silicon by saving and loading a state after the game has run, then trace which protected page SaveState_FreezeMem writes. Done means state loading no longer crashes with SIGBUS on the frontend thread.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Loading a save state on Apple silicon crashes the whole process with SIGBUS once the game has been running. It happens in RetroArch and in a personal libretro frontend of mine, with the same stack inside the core.
Setup
- MacBook Pro, M1 Pro, macOS 27.2
- Core: buildbot
apple/osx/arm64nightly dated 2026-11-03, reports v2.0.0-da5b07e - RetroArch 1.22.2,
video_driver = "metal", run-ahead off pcsx2_renderer = "Software (SW)",pcsx2_sw_renderer_threads = "4"(the only renderer I tested)- Kingdom Hearts (USA), SLUS-20370, as an ISO; BIOS USA v01.60
Steps
- Start the game and let it run for about 45 seconds.
- Save a state. I sent
SAVE_STATEthrough RetroArch's network commands. - A few seconds later, load it with
LOAD_STATE.
Result
The process dies on the frontend's main thread:
EXC_BAD_ACCESS (SIGBUS) KERN_PROTECTION_FAILURE at 0x0000000138234000
Data Abort: byte write Permission fault
0 libsystem_platform.dylib _platform_memmove + 88
1 pcsx2_libretro.dylib state_read(void const*, unsigned long, bool) + 1300
2 pcsx2_libretro.dylib retro_unserialize + 388
3 RetroArch content_deserialize_state + 540
4 RetroArch content_load_state_cb + 388
I got the same top three frames in my own frontend, also at a write to a read-only page, with the frontend calling retro_unserialize on its emulation thread. In that frontend's report the faulting page is one 16 KB page marked r--/rw- inside a shared memory region, between rw- pages, which looks like a page the recompiler protected.
What I think is happening (from reading the source, not from a debugger)
fault_filter in libretro-common/faulthandler/faulthandler.c only services threads registered with the fault handler, and chains to the old handler otherwise. In normal play, the only registration I could find is FaultThreadScope in cpu_thread_entry. retro_unserialize runs on the frontend's thread, so if state_read writes to a write-protected page there, nothing rescues it. I don't know why VMManager::Internal::ClearCPUExecutionCaches() hasn't already made the page writable at that point, and I haven't confirmed which SaveState_FreezeMem call is the one faulting.
What works
- Closing the core, opening it again, running one
retro_run, then callingretro_unserialize. This loaded the same state repeatedly with no crash in my frontend, and it's what I'm using as a workaround. - In RetroArch,
RESETsurvived all four times I tried it: after about 45, 60, 75 and 90 seconds, the 60-second one after aSAVE_STATE.
Possibly related
retro_reset crashed once in my frontend, with the same kind of write fault, on a call made right after a retro_serialize with no retro_run in between:
0 libsystem_platform.dylib __bzero + 64
1 pcsx2_libretro.dylib sys_memory_reset + 80
2 pcsx2_libretro.dylib cpuReset() + 20
3 pcsx2_libretro.dylib VMManager::Reset() + 244
4 pcsx2_libretro.dylib retro_reset + 132
I only saw this once and couldn't reproduce it in RetroArch, so treat it as a lead. #69 also describes state loads crashing RetroArch, but it's closed and I haven't compared the two.
Thanks for the arm64 port: apart from this, the game runs at full speed on this Mac.
This report was prepared with an AI assistant (Claude Code), which ran the tests above. The stacks are from real macOS crash reports. Happy to test a build or send a full crash report.
- Ngôn ngữ chính
- C
- Star
- 90
- Fork
- 34
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của libretro/parallel-ps2
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 12/100
libretro/parallel-ps2#195 · 8 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
libretro/parallel-ps2#192 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
libretro/parallel-ps2#185 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
add pcsx2-reliquary changes?Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
libretro/parallel-ps2#184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
libretro/parallel-ps2#173 · 10 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của libretro/parallel-ps2
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
libretro/parallel-n64#858 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Mbed-TLS/TF-PSA-Crypto#984 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
tursodatabase/libsql#2320 ·
Maintainer thường phản hồi trong vòng 11 ngày