xiph / xiph/opus

decode fails on long stream when compiled with NONTHREADSAFE_PSEUDOSTACK

Open
#194 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

Hi - My platform (https://github.com/sle118/squeezelite-esp32) is an esp32 CPU and I've compiled opus & opusfile for that target. It works fine when using VAR_ARRAYS but this is a fair bit of stack consumption which is a scarce resource on this chipset (it mostly needs to be in internal memory - although there are ways around). The best solution is to use NONTHREADSAFE_PSEUDOSTACK and use heap. Unfortunately, what happens on most long playback is a failure after 10~30 mins.

op_read returns -136 and the issue is that there seems to be some corruption in the pseudo-stack

  • op_get_packet_duration has a nsamples >> 120*48
  • a general OPUS_INVALID_PACKET that can happen at many places (I've not been able to track them precisely yet)

I've compiled with O3 (same result with any O level) and for fixed point only. I've tried different values of the stack "pool", from 32 to 120k, no change.

I understand my description is too vague for allowing any analysis, but what I'm asking is that if others have seen issues when compiled with PSEUDOSTACK. I don't think there is a memory corruption somewhere else on my system as it's a very stable and runs mp3,flac,aac,alac,pcm,vorbis without issue for hours. Of course I cannot rule that out, but it only & systematically happens with opus.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing long playback on the ESP32 build using NONTHREADSAFE_PSEUDOSTACK, then compare it with VAR_ARRAYS. Investigate failures reported by op_read, including invalid results from op_get_packet_duration and OPUS_INVALID_PACKET; done means identifying the pseudo-stack corruption and providing a fix verified during extended playback.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.