[tim-janik/beast] BSE: driver-alsa.cc: fix crash in retrigger code (#127)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[tim-janik/beast] BSE: driver-alsa.cc: fix crash in retrigger code (#127)

Gnome - Beast mailing list

I was playing a bit with the new alsa driver, and I found that for my first hw device, it crashed like this:

stefan@quadcorn:~/src/3rd-tree/ghbeast (master *% u=)$ LANG=C beast
beast: unable to acquire soft realtime priority: Permission denied
beast-0.15.0: bse/bseengineutils.cc:632: bse_engine_const_zeros: assertion failed: smaller_than_BSE_STREAM_MAX_VALUES <= (1024 )
beast-0.15.0: pcm.c:1424: snd_pcm_writei: Assertion `size == 0 || buffer' failed.

The problem is that bseengineutils.cc imposes a limit on how big a const zeros float block can be, and on my device, the amount of zero data for the retrigger was larger than 1024 floats, so the driver ended up trying to write a null pointer.

I fixed this crash, and I think I also found another mistake here: n_channels was not taken into account by your original code (buffer_length / 2 would be wrong), so in the fixed version it uses n_channels * sizeof (int16) bytes per frame.


You can view, comment on, or merge this pull request online at:

  https://github.com/tim-janik/beast/pull/127

Commit Summary

  • BSE: driver-alsa.cc: fix crash in retrigger code

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XSSLPXRGJZ7QKBDK3LQKDU67A5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HL4DDFA", "url": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XSSLPXRGJZ7QKBDK3LQKDU67A5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HL4DDFA", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
_______________________________________________
beast mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/beast
Reply | Threaded
Open this post in threaded view
|

Re: [tim-janik/beast] BSE: driver-alsa.cc: fix crash in retrigger code (#127)

Gnome - Beast mailing list

@tim-janik requested changes on this pull request.


In bse/driver-alsa.cc:

> @@ -427,7 +427,8 @@ class AlsaPcmDriver : public PcmDriver {
     if (write_handle_)
       {
         int n, buffer_length = n_periods_ * period_size_; // buffer size chosen by ALSA based on latency request
-        const float *zeros = bse_engine_const_zeros (buffer_length / 2); // sizeof (int16) / sizeof (float)
+        const size_t frame_size = n_channels_ * sizeof (period_buffer_[0]);
+        const uint8  zeros[buffer_length * frame_size] = { 0, };

Clang doesn't support intiializing variable length arrays from non-const.
Generally, period_size_ should never be bigger than the engineblock size, actually the two should be same. It's probably most simple to call snd_pcm_writei for n_periods_ times.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XTOR64F7FQHPOCQSJTQKSTAHA5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCFCW6XQ#pullrequestreview-289763166", "url": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XTOR64F7FQHPOCQSJTQKSTAHA5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCFCW6XQ#pullrequestreview-289763166", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
_______________________________________________
beast mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/beast
Reply | Threaded
Open this post in threaded view
|

Re: [tim-janik/beast] BSE: driver-alsa.cc: fix crash in retrigger code (#127)

Gnome - Beast mailing list
In reply to this post by Gnome - Beast mailing list

Closed #127 via 644460e.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XWJWF7OZLQUAONPBTTQKTEBTA5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTX4AZBY#event-2650279047", "url": "https://github.com/tim-janik/beast/pull/127?email_source=notifications\u0026email_token=AIVS7XWJWF7OZLQUAONPBTTQKTEBTA5CNFSM4IXREM5KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTX4AZBY#event-2650279047", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
_______________________________________________
beast mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/beast