Skip to content

[BUG] Malloc error on macOS when initializing the MiniAudioEngine with sample rate of 16000 #67

@earlwilson

Description

@earlwilson

Operating System & Version

MacOS 13.7.4

Architecture

ARM64 (M1)

.NET Runtime & Version

.NET 9

Audio Backend Used (if known)

MiniAudioEngine

Specific Hardware (if relevant)

M1 Macbook Air. Default built in speakers and microphone.

2. Description of the Issue

When I initialize an instance of MiniAudioEngine with the following settings

Engine = new MiniAudioEngine(
    sampleRate: 16000, 
    capability: Capability.Mixed,
    sampleFormat: SampleFormat.F32,
    channels: 1 
);

I get an intermittent error in the output which occurs right as the MiniAudioEngine is initialized.

(62520,0x16e453000) malloc: Incorrect checksum for freed object 0x104019a00: probably modified after being freed.
Corrupt value: 0xb726a590b71f9512
(62520,0x16e453000) malloc: *** set a breakpoint in malloc_error_break to debug

Interestingly it does not crash If i change the sample rate to either 8000, 22050, 44100, 48000 or if I set the capability to Capability.Record

3. Does it work correctly on other platforms?

Yes

Which platforms work correctly? (If "Yes" above)

It works with out error on my Raspberry Pi 5 running Debian 6.6.

4. Steps to Reproduce (on the affected platform)

  1. Initialize an instance of MiniAudioEngine on a Mac with the settings I listed.
  2. Run the application
  3. You will see that there are malloc errors.

5. Expected Behavior (on the affected platform)

It is expected that the application can setup the MiniAudioEngine without crashing

6. Current Behavior (on the affected platform)

It currently crashes immediately when initializing the MiniAudioEngine.

7. Minimal Reproducible Example (MRE)

public void Initialize()
        {
            Engine = new MiniAudioEngine(
                sampleRate: 16000, 
                capability: Capability.Mixed,
                sampleFormat: SampleFormat.F32,
                channels: 1 
            );
            // Error happens above ^

            StartCapture();
        }

8. Error Messages and Stack Trace (if applicable, from the affected platform)

(69172,0x1ea4ce140) malloc: Incorrect checksum for freed object 0x12482ae00: probably modified after being freed.
Corrupt value: 0x388f638438ac7370
(69172,0x1ea4ce140) malloc: *** set a breakpoint in malloc_error_break to debug

9. SoundFlow Version

1.1.1

10. Additional Context

I can get it to run properly maybe 1 out of every 10 attempts. I have attempted this with a variety of Dispose / Clean up strategies to see if it was related to that.

Lastly, I gave my best effort at debugging the issue, I see the crash happens in the InitializeDeviceInternal function at the result = Native.DeviceStart(_device); line in MiniAudioEngine.cs

Requirements Checklist

  • I have searched the existing issues to ensure this platform-specific issue has not already been reported.
  • I have clearly specified the affected platform(s) and environment details.
  • I have provided detailed steps to reproduce the issue on the affected platform.
  • I have indicated if the issue is confirmed to work correctly on other platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin-progressThis issue is actively being worked on; development is currently in progress.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions