Skip to content

Stack overflow with HE-AAC (AAC+) streams - AUDIO_STACK_SIZE may be too small #1232

@DIYLAB-DE

Description

@DIYLAB-DE

Hi,

first of all, thank you for this great library!

I encountered a crash (stack overflow) when playing certain AAC+ streams with low bitrate. The ESP32 immediately reboots with this error:

Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (PeriodicTask)

Stream that causes the crash

http://frontend.streamonkey.net/rhh-1036?aggregator=linkradiohamburgde

This is Radio Hamburg, streaming HE-AAC (AAC+ with SBR) at 64 kbit/s.

Root cause

The AUDIO_STACK_SIZE in Audio.cpp (line 37) was set to 3300 words (13.2 KB) in version 3.4.3. This is not enough for HE-AAC streams that use SBR (Spectral Band Replication).

I noticed that you increased it to 3500 in version 3.4.4 - this might still be insufficient for some HE-AAC streams, but I haven't tested that version yet.

Solution

Increasing AUDIO_STACK_SIZE to 5000 fixes the issue in my tests:

// Audio.cpp
constexpr size_t AUDIO_STACK_SIZE = 5000;  // was: 3300

Suggestion

Maybe this value could be made configurable via a preprocessor define like:

#ifndef AUDIO_STACK_SIZE
    constexpr size_t AUDIO_STACK_SIZE = 5000;
#endif

This would allow users to override the value in platformio.ini if needed:

build_flags = -DAUDIO_STACK_SIZE=5000

Environment

  • ESP32-S3
  • Arduino Core 3.x
  • Library version: 3.4.3

Best
Bruno

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions