jbclements / RSound

A cross-platform sound library for DrRacket
http://www.brinckerhoff.org/clements
Other
45 stars 11 forks source link

Assertion #<procedure:negative?> failed on 0.0 #47

Open pmatos opened 2 years ago

pmatos commented 2 years ago

At least in Racket CS 8.x I am getting the following right after requiring rsound:

racket -i -l errortrace            
Welcome to Racket v8.3.0.8 [cs].
> (require rsound)
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
; Assertion #<procedure:negative?> failed on 0.0 [,bt for context]
> ,bt
; Assertion #<procedure:negative?> failed on 0.0
;   errortrace...:
;   context...:
;    body of "/home/pmatos/.local/share/racket/8.3.0.8/pkgs/math-lib/math/private/flonum/flonum-constants.rkt"
;    body of top-level
;    /home/pmatos/.local/share/racket/8.3.0.8/pkgs/xrepl-lib/xrepl/xrepl.rkt:1573:0
;    /home/pmatos/installs/racket-8.3dev/share/racket/collects/racket/repl.rkt:11:26
> ^D

And unfortunately even the backtrace sucks. :(

jbclements commented 2 years ago

Indeed. I think the next step would be to try running the files required by rsound/main, one at a time. You could also begin at the other end, by requiring portaudio/portaudio; if that fails, there would be no need to look at rsound.

pmatos commented 2 years ago

thanks fort

Indeed. I think the next step would be to try running the files required by rsound/main, one at a time. You could also begin at the other end, by requiring portaudio/portaudio; if that fails, there would be no need to look at rsound.

Thanks for the tips - i will look into that.

pmatos commented 2 years ago

Interesting - requiring utils.rkt is enough to trigger this.

Welcome to Racket v8.3.0.8 [cs].
> (require "rsound/util.rkt")
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_
lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
; Assertion #<procedure:negative?> failed on 0.0 [,bt for context]
> 

Will have to investigate this file further.

pmatos commented 2 years ago

ah, you won't even believe this:

> (require (only-in math/base power-of-two?))
Assertion #<procedure:negative?> failed on 0.0
soegaard commented 2 years ago

FWIW - is it a Linux only problem?

At least I can't see the problem on macOS.

/Jens Axel

pmatos commented 2 years ago

FWIW - is it a Linux only problem? At least I can't see the problem on macOS. /Jens Axel

Yeah - it's interesting and confusing at the same time. I am not being able to reproduce it reliably when just doing the require line, but it sure fails reliably when required through rsound, so unfortunately this seems to be a tricky one to repro. I will add more information as I find out about it.

pmatos commented 2 years ago

This is a hell of a bug...

If I start drracket and run (excerpt from util.rkt.

(require ;"rsound.rkt"
         (only-in math/base power-of-two?)
         )

It works! So I uncomment the first line.

(require "rsound.rkt"
         (only-in math/base power-of-two?)
         )

to get: Assertion #<procedure:negative?> failed on 0.0

From here on out. Simply requiring (only-in math/base... is enough to cause the assertion.

Assertion #<procedure:negative?> failed on 0.0
  context...:
   body of "/home/pmatos/installs/racket-8.3/share/pkgs/math-lib/math/private/flonum/flonum-constants.rkt"

However, requiring only rsound.rkt is not enough to cause the issue.

jbclements commented 2 years ago

Well, rsound (or, more specifically, portaudio) does use ffi/unsafe, so there's a definite window open for this to be my fault. Ugh. I wish I could reproduce it! Also, it appears to me that for Ken Shan, at least, rsound does not show this bug. Also, I can't reproduce it on my vps. Oog.

pmatos commented 2 years ago

If you wish to repro it, I can see if I can get it reproduced inside a container. Although it might depend exactly on my alsa config.

On 3 December 2021 17:29:26 CET, John Clements @.***> wrote:

Well, rsound (or, more specifically, portaudio) does use ffi/unsafe, so there's a definite window open for this to be my fault. Ugh. I wish I could reproduce it! Also, it appears to me that for Ken Shan, at least, rsound does not show this bug. Also, I can't reproduce it on my vps. Oog.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jbclements/RSound/issues/47#issuecomment-985657307

jbclements commented 2 years ago

Well, if I can see the bug, I’m certainly much more likely to try to narrow it down than if I don’t. I agree that if it depends on having alsa set up, it could be quite painful.

Best,

John

On Dec 3, 2021, at 12:38, Paulo Matos @.***> wrote:

If you wish to repro it, I can see if I can get it reproduced inside a container. Although it might depend exactly on my alsa config.

On 3 December 2021 17:29:26 CET, John Clements @.***> wrote:

Well, rsound (or, more specifically, portaudio) does use ffi/unsafe, so there's a definite window open for this to be my fault. Ugh. I wish I could reproduce it! Also, it appears to me that for Ken Shan, at least, rsound does not show this bug. Also, I can't reproduce it on my vps. Oog.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jbclements/RSound/issues/47#issuecomment-985657307 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

pmatos commented 2 years ago

Well, if I can see the bug, I’m certainly much more likely to try to narrow it down than if I don’t. I agree that if it depends on having alsa set up, it could be quite painful. Best, John

Sounds like finding a way to reproduce it might take as long and myself digging into the code and trying to fix it tbh. I tried in all pcs I have around and it only fails on my work PC. :(

This means that it is probably related to some alsa setup. At least I have something to go on... I will try to understand what's happening on the interface with the FFI and the warning messages I get on the console from ALSA lib.

Will keep you up-to-date.