Documentation
¶
Overview ¶
escaping-tap-regression demonstrates the original use-after-free that motivated applegen's escaping-block classifier (appledocs c09228c541).
AVAudioNode.InstallTapOnBusBufferSizeFormatBlock is the raw generated wrapper for installTapOnBus:bufferSize:format:block:. The audio engine holds the tap block past the call's return and invokes it on the audio I/O thread, so the pre-fix generator's `defer _block.Release()` was a use-after-free. AVAudioEngine does not synchronously [block copy] — release-before-copy meant the audio thread later saw a freed Go closure wrapper and crashed with EXC_BAD_ACCESS / SIGTRAP.
The safe public API is the avfaudio.InstallTapOnBus helper, which manages the block lifetime explicitly via a release token. This example uses the raw method on purpose, to exercise the previously-buggy generator path.
Run:
go run .
Requires microphone permission. Build into a code-signed .app bundle (e.g. with tmc/macgo) or grant Terminal mic access in System Settings > Privacy & Security > Microphone. Exits 0 once at least one tap callback fires.