Commit db04f7b
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 db04f7b
1 file changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
354 | 358 | | |
355 | 359 | | |
356 | 360 | | |
| |||
363 | 367 | | |
364 | 368 | | |
365 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
366 | 373 | | |
367 | 374 | | |
368 | 375 | | |
| |||
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
378 | 402 | | |
379 | 403 | | |
380 | 404 | | |
| |||
498 | 522 | | |
499 | 523 | | |
500 | 524 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | 525 | | |
509 | 526 | | |
510 | 527 | | |
| |||
0 commit comments