Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~10 sec. sound delay #388

Closed
beta-tester opened this issue Sep 29, 2013 · 16 comments
Closed

~10 sec. sound delay #388

beta-tester opened this issue Sep 29, 2013 · 16 comments

Comments

@beta-tester
Copy link

i hope this is the correct place to report issues, related to Raspbian SD card images.

"2013-02-09-wheezy-raspbian.img" was the last working rapbian image, where stella (3.7.2-1) sound is/was working well.
(Stella is an Atari 2600 emulator).

from "2013-05-25-wheezy-raspbian.img" up to the most recent "2013-09-25-wheezy-raspbian.img", when using stella, the sound is delayed round about ~10 seconds.

you can find the full thread of this issue here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=78&t=52387&hilit=Stella

@popcornmix
Copy link
Collaborator

It's hard to imagine a 10 second audio delay coming from alsa driver, but it should be possible to confirm this.
The thread suggests the problem didn't occur with 2013-05-25-wheezy-raspbian but does with newer versions.

Can you try reverting your firmware to an older version.

If you look here:
https://github.com/Hexxeh/rpi-firmware/commits/master

you see a list of commits. You can revert to an older commit with:
sudo rpi-update <git-hash>

e.g. you could revert to 24th May (which should match the older raspbian image) with:
sudo rpi-update 001a8517f67182c278e1eff33f1fc2aac0bb22cc

@beta-tester
Copy link
Author

2013-05-25-wheezy-raspbian.img is already the first image that shows up that issue...

how i installed Raspbian / Stella til now:

  1. installed virgin most recent Raspbian SD image to a blank SD card.
  2. setup/update raspbian to most recent state
    2.1. sudo apt-get raspi-config
    2.2. (optional) sudo apt-get dist-upgrade
    2.3. (optional) sudo rip-update
    2.4. (optional) sudo reboot
  3. sudo apt-get update
  4. sudo apt-get install stella

thank you, i will try to "downgrade" rpi-firmware to (Feb 07, 2013 )
sudo rpi-update 1b2fee4c748b4a05f0492dcc708d81f739e6b8ca

@popcornmix
Copy link
Collaborator

Sure, if you can find any older version that works better, then we can try to identify the commit that caused the problem. The alsa driver hasn't changed since:
bad49c2
so that is a possibility.

@beta-tester
Copy link
Author

i didn't know that "downgrade" possibility.
i try out to find the transition between working and non-working commit, and let you know - will take a while...

@beta-tester
Copy link
Author

ok, i figured out the last working and the first non-working commit:

Mar 18, 2013: Hexxeh/rpi-firmware@aea9d8e - good
Mar 24, 2013: Hexxeh/rpi-firmware@61f7aa5 - (bricks sd image)
Mar 29, 2013: Hexxeh/rpi-firmware@b68696f - bad

i tested with different images as base and applied the upgrade/downgrade:
2013-02-09-wheezy-raspbian.img - upgraded
2013-09-25-wheezy-raspbian.img - downgraded

on commit "Mar 24, 2013: Hexxeh/rpi-firmware@61f7aa5" there is a comment about "Firmware: new alsa scheme should fix hangs with libretro" - maybe that is the cause of this issue.

PS.: using "sudo rpi-update ..." in raspbian on a NOOBS 1.3 sd card with OpenELEC and Raspbian may brick your installation!

PPS.: :oops: is it possible, that i just lost my warranty for my new RPi? because my config.txt contained legal "medium" overclocking options before i downgraded, but i think older rpi-firmware will detect these newer legal overclocking parameters as illegal ones and setted the "voided warranty" flag. :/

@popcornmix
Copy link
Collaborator

Thanks for digging.
Looks like a firmware issue (start.elf) rather than a kernel one. Occurred on March 24:
"Add additional queue that alsa buffers get stored in before being submitted to audioplus.
Avoid the pwm post process operation by converting in mixing buffer."

Unfortunately that was quite a big change - I'll need to do some debugging.
If you explain exactly how to reproduce the issue that would help.

@beta-tester
Copy link
Author

  1. download a rom that plays sound, just when you start the rom or any other where you can see and hear if the sound is delayed or not (for example a free legal homebrew rom: latest 'stable' release of "flapping.bin" from http://alienbill.com/2600/flapping/)
    wget http://alienbill.com/2600/flapping/flapping.bin
  2. put the rom to a place, where you will find it easily (e.g. to your ~/.)
  3. install stella with:
    sudo apt-get -y install stella
  4. start stella with:
    stella
  5. at first initial start, stella ask you for the roms path... hit [OK] and choose that path where you put the rom to (you will not see the rom yet). [QUIT] stella.
  6. start stella again and select the rom and hit [ENTER]-key, to start the rom.
  7. when everything is ok, you will hear immediately sound with seeing the screen. if not, and you hear the sound with a big delay of many seconds (and the sound also keeps playing for a moment after you hit [ESC]-key to cancel the rom and go to menu), then the sound issue/bug is present.
  8. quit stella
  9. change the compilation/debugging or what ever you can do to fix the sound delay issue.
    ... redo steps beginning from step 6.

PS.: do not run stella from startx - just start it from the standard login console - but not SSH session ;)
PPS.: when you follow these steps (6. ... 9.), the sound is not delayed ~10sec. it is lesser, but still very noticeable.
specially when the sound still plays after hit [ESC] or at in-game play.
you can start the in-game play by hitting [SPACE] after starting the rom. you will hear a short beep exactly when the ball disappears from the screen.

hopefully you will find an easy solution - thanks in advance...

@popcornmix
Copy link
Collaborator

Okay, I can run stella and get the delay. Step 1...

@popcornmix
Copy link
Collaborator

Some notes:
Running "stella flapper.dat" doesn't have the (big) delay
The stella file browser screen is outputting (silent) audio.
The sample rate is 31,400. 2 channel. 8 bits.
In the first second, stella wrote 120KB of data which is roughly double what I'd expect.
So either stella has a bug, or we are confusing it.
Due to more data being written than is being consumed, the audio latency increases until our buffers fill (10 seconds).

I think the problem is that internally we convert the 8 bit data to 16 bit.
We incorrectly tell stella we have consumed the size of the 16 bit data, rather than the 8 bit data.
stella therefore submits more data than we can cope with.

I've committed a fix and rebuild firmware. Can you rpi-update and test?

@beta-tester
Copy link
Author

hey, you fixed it! and so quick :D
it works like charm again... thank your so much!!!

PS.: i say thank you, in the name of many others form other forums... "Please send kudos to the appropriate folks"... done

@popcornmix
Copy link
Collaborator

No problems - thanks for providing the information required to fix it.

asb pushed a commit to asb/firmware that referenced this issue Dec 11, 2013
@yusufk
Copy link

yusufk commented Jan 16, 2014

Hello, as a user, how does one get rid of the problem?

I just ran:
sudo rpi-update
sudo reboot

and the problem is still there.

@popcornmix
Copy link
Collaborator

What does "vcgencmd version" report?
What are you running to see the delay?

@yusufk
Copy link

yusufk commented Jan 16, 2014

Jan 10 2014 16:58:06
Copyright (c) 2012 Broadcom
version efa116b5c8859c352322cb27e13baccbea583ef7 (clean) (release)

I am trying to get espeak to work on my Raspberry Pi

@popcornmix
Copy link
Collaborator

@yusufk
I think your problem is an instance of #304.
I'll ping @martinezjavier who was going to investigate this.

@yusufk
Copy link

yusufk commented Jan 16, 2014

Ok, thanks for the reply
On 16 Jan 2014 5:34 PM, "popcornmix" [email protected] wrote:

@yusufk https://github.com/yusufk
I think your problem is and instance of #304#304
.
I'll ping @martinezjavier https://github.com/martinezjavier who was
going to investigate this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/388#issuecomment-32479002
.

neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this issue Feb 27, 2017
popcornmix pushed a commit that referenced this issue Jul 20, 2020
[ Upstream commit d005fbb ]

__nf_conntrack_update() might refresh the conntrack object that is
attached to the skbuff. Otherwise, this triggers UAF.

[  633.200434] ==================================================================
[  633.200472] BUG: KASAN: use-after-free in nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200478] Read of size 1 at addr ffff888370804c00 by task nfqnl_test/6769

[  633.200487] CPU: 1 PID: 6769 Comm: nfqnl_test Not tainted 5.8.0-rc2+ #388
[  633.200490] Hardware name: LENOVO 23259H1/23259H1, BIOS G2ET32WW (1.12 ) 05/30/2012
[  633.200491] Call Trace:
[  633.200499]  dump_stack+0x7c/0xb0
[  633.200526]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200532]  print_address_description.constprop.6+0x1a/0x200
[  633.200539]  ? _raw_write_lock_irqsave+0xc0/0xc0
[  633.200568]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200594]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200598]  kasan_report.cold.9+0x1f/0x42
[  633.200604]  ? call_rcu+0x2c0/0x390
[  633.200633]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200659]  nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200687]  ? nf_conntrack_find_get+0x30/0x30 [nf_conntrack]

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1436
Fixes: ee04805 ("netfilter: conntrack: make conntrack userspace helpers work again")
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
nathanchance pushed a commit to nathanchance/pi-kernel that referenced this issue Jul 20, 2020
[ Upstream commit d005fbb ]

__nf_conntrack_update() might refresh the conntrack object that is
attached to the skbuff. Otherwise, this triggers UAF.

[  633.200434] ==================================================================
[  633.200472] BUG: KASAN: use-after-free in nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200478] Read of size 1 at addr ffff888370804c00 by task nfqnl_test/6769

[  633.200487] CPU: 1 PID: 6769 Comm: nfqnl_test Not tainted 5.8.0-rc2+ raspberrypi#388
[  633.200490] Hardware name: LENOVO 23259H1/23259H1, BIOS G2ET32WW (1.12 ) 05/30/2012
[  633.200491] Call Trace:
[  633.200499]  dump_stack+0x7c/0xb0
[  633.200526]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200532]  print_address_description.constprop.6+0x1a/0x200
[  633.200539]  ? _raw_write_lock_irqsave+0xc0/0xc0
[  633.200568]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200594]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200598]  kasan_report.cold.9+0x1f/0x42
[  633.200604]  ? call_rcu+0x2c0/0x390
[  633.200633]  ? nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200659]  nf_conntrack_update+0x34e/0x770 [nf_conntrack]
[  633.200687]  ? nf_conntrack_find_get+0x30/0x30 [nf_conntrack]

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1436
Fixes: ee04805 ("netfilter: conntrack: make conntrack userspace helpers work again")
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants