Commit 9b295c5
committed
DolphinLibretro: defer Auto Load State until the EmuThread is live
RetroArch's Auto Load State calls retro_unserialize between
retro_load_game and the first retro_run. In the libretro fork the
EmuThread is launched lazily from inside retro_run, so at auto-load
time the core's HW, Memory, PowerPC, FIFO and video subsystems are
uninitialised. RunOnCPUThread falls back to inline execution when the
core state is not Running, so State::DoState runs on the frontend
thread against null/garbage pointers and segfaults.
Buffer any savestate delivered before the EmuThread is live in a new
Libretro::g_pending_load_state, and drain it from retro_run inside
the existing one-shot launch block, after the IsRunningOrStarting
wait and the memory-map registration. At that point the execution
environment matches a manual Load State.
Also guard retro_serialize and retro_serialize_size against the same
uninitialised state with an early return.
Closes #322.1 parent 0cd3bb8 commit 9b295c5
3 files changed
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
274 | 290 | | |
275 | 291 | | |
276 | 292 | | |
| |||
462 | 478 | | |
463 | 479 | | |
464 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
465 | 484 | | |
466 | 485 | | |
467 | 486 | | |
| |||
483 | 502 | | |
484 | 503 | | |
485 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
486 | 508 | | |
487 | 509 | | |
488 | 510 | | |
| |||
502 | 524 | | |
503 | 525 | | |
504 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
505 | 534 | | |
506 | 535 | | |
507 | 536 | | |
| |||
0 commit comments