From: GitHub issues - opened <github@alsa-project.org>
To: alsa-devel@alsa-project.org
Subject: Unhandled asynchronous SIGIO
Date: Tue, 23 Apr 2024 21:29:16 +0200 (CEST) [thread overview]
Message-ID: <20240423192916.56CA5F80640@alsa1.perex.cz> (raw)
In-Reply-To: <1713900551544367313-webhooks-bot@alsa-project.org>
alsa-project/alsa-lib issue #394 was opened from jansenmd:
When using `libasound.so` on embedded systems, I've come across several instances where an unhandled `SIGIO` is detected. This can occur when closing a hardware microphone device that was set up to use asynchronous calls backs via `snd_async_add_pcm_handler`.
Example: when opening a hardware device with asynchronous callbacks:
* Sets up a signal handler for `SIGIO` via `sigaction`.
* Enable generation of signals from the `fd` by setting the `O_ASYNC` flag: `fcntl(fd, F_SETFL, flags | O_ASYNC)`
* Sets the signal to be generated: `fcntl(fd, F_SETSIG, (long)SIGIO)`
Now, when data is available to be read from the `fd`, `SIGIO` should be generated and handled by the signal handler set in `sigaction`. That appears to work fine.
The current teardown process looks like this:
* Clear/reset the signal handler via `sigaction`.
* Disable generation of signals from the `fd` by clearing the `O_ASYNC` flag: `fcntl(fd, F_SETFL, flags & ~O_ASYNC)`
* Close the `fd`.
This teardown process seems to set up a race condition where an unhandled `SIGIO` can be generated between unregistering the signal handler and actually stopping any more signals from occurring. Since the default action for `SIGIO` is termination, this can cause an application to unexpectedly terminate.
Issue URL : https://github.com/alsa-project/alsa-lib/issues/394
Repository URL: https://github.com/alsa-project/alsa-lib
parent reply other threads:[~2024-04-23 19:31 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1713900551544367313-webhooks-bot@alsa-project.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240423192916.56CA5F80640@alsa1.perex.cz \
--to=github@alsa-project.org \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).