Commit 9e601b3
coreaudio: unregister interruption observer unconditionally on close
update_audio_session()'s existing close-path observer teardown lived at
the bottom of the function, after two [AVAudioSession setCategory:] and
one [setActive:] calls that early-return on failure. When setCategory
fails during close (phone call, Siri, CarPlay / AirPlay handoff, or a
session owned by another app), the early-return skipped the unregister
and the SDLInterruptionListener stayed subscribed to NSNotificationCenter
with a stale device pointer. The next UIApplicationWillEnterForeground
or UIApplicationDidBecomeActive notification then dispatched into
interruption_end() on freed memory, crashing with EXC_BAD_ACCESS.
Move the close-path unregister to the top of the function so it runs
unconditionally, before any early-return. Also add self.device == NULL
guards in both listener callbacks as defense in depth so that any future
cleanup-flow edit can't silently reintroduce the crash.
The sibling setActive:YES leak on last-device close was fixed in 2018
(issue #2900). This closes the setCategory: leak that has remained
since. The same root cause is reported in SDL3 as #12660.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c8ebb14 commit 9e601b3
1 file changed
Lines changed: 32 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
354 | 361 | | |
355 | 362 | | |
356 | 363 | | |
| |||
363 | 370 | | |
364 | 371 | | |
365 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
| |||
375 | 385 | | |
376 | 386 | | |
377 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
378 | 407 | | |
379 | 408 | | |
380 | 409 | | |
| |||
498 | 527 | | |
499 | 528 | | |
500 | 529 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
509 | 534 | | |
510 | 535 | | |
511 | 536 | | |
| |||
0 commit comments