From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] [PATCH v2 4/4] POSIX: Do not auto-shadow main with dlopen enabled
Date: Tue, 17 Feb 2009 18:04:19 +0100 [thread overview]
Message-ID: <20090217170419.1425.5174.stgit@domain.hid> (raw)
In-Reply-To: <20090217170418.1425.56126.stgit@domain.hid>
Don't perform auto-shadowing in POSIX skin if we might be loaded via
dlopen. Otherwise the wrong thread, the undefined dlopen caller, may be
(re-)shadowed, assigning wrong scheduling settings.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
src/skins/posix/init.c | 43 ++++++++++++++++++++++++++++---------------
1 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
index 8fc5a92..b04dbf0 100644
--- a/src/skins/posix/init.c
+++ b/src/skins/posix/init.c
@@ -47,7 +47,6 @@ void pse51_clock_init(int);
static __attribute__ ((constructor))
void __init_posix_interface(void)
{
- struct sched_param parm;
int muxid, err;
muxid =
@@ -67,28 +66,42 @@ void __init_posix_interface(void)
__rtdm_fdcount);
}
- /* Shadow the main thread. mlock the whole memory for the time of the
- syscall, in order to avoid the SIGXCPU signal. */
+#ifdef CONFIG_XENO_LIBS_DLOPEN
+ /* Don't use auto-shadowing if we are likely invoked from dlopen, but
+ take care of auto-mlockall. */
+#ifdef CONFIG_XENO_POSIX_AUTO_MLOCKALL
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
perror("Xenomai Posix skin init: mlockall");
exit(EXIT_FAILURE);
}
+#endif /* CONFIG_XENO_POSIX_AUTO_MLOCKALL */
+#else /* !CONFIG_XENO_LIBS_DLOPEN */
+ {
+ struct sched_param parm = { .sched_priority = 0 };
+
+ /* Shadow the main thread. mlock the whole memory for the time
+ of the syscall, in order to avoid the SIGXCPU signal. */
+ if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
+ perror("Xenomai Posix skin init: mlockall");
+ exit(EXIT_FAILURE);
+ }
- parm.sched_priority = 0;
- err = __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
- &parm);
- if (err) {
- fprintf(stderr, "Xenomai Posix skin init: "
- "pthread_setschedparam: %s\n", strerror(err));
- exit(EXIT_FAILURE);
- }
+ err = __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
+ &parm);
+ if (err) {
+ fprintf(stderr, "Xenomai Posix skin init: "
+ "pthread_setschedparam: %s\n", strerror(err));
+ exit(EXIT_FAILURE);
+ }
#ifndef CONFIG_XENO_POSIX_AUTO_MLOCKALL
- if (munlockall()) {
- perror("Xenomai Posix skin init: munlockall");
- exit(EXIT_FAILURE);
- }
+ if (munlockall()) {
+ perror("Xenomai Posix skin init: munlockall");
+ exit(EXIT_FAILURE);
+ }
#endif /* !CONFIG_XENO_POSIX_AUTO_MLOCKALL */
+ }
+#endif /* !CONFIG_XENO_LIBS_DLOPEN */
if (!fork_handler_registered) {
err = pthread_atfork(NULL, NULL, &__init_posix_interface);
next prev parent reply other threads:[~2009-02-17 17:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 17:04 [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 2/4] Mark libs nodlopen on initial-exec TLS Jan Kiszka
2009-02-17 17:04 ` Jan Kiszka [this message]
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 1/4] POSIX: Fix SCHED_RR thread creation Jan Kiszka
2009-02-17 17:15 ` Gilles Chanteperdrix
2009-02-17 17:28 ` Jan Kiszka
2009-02-17 17:37 ` Gilles Chanteperdrix
2009-02-17 17:47 ` Jan Kiszka
2009-02-17 17:50 ` Gilles Chanteperdrix
2009-02-17 17:57 ` Jan Kiszka
2009-02-17 18:17 ` Gilles Chanteperdrix
2009-02-17 18:19 ` Jan Kiszka
2009-02-17 18:21 ` Gilles Chanteperdrix
2009-02-17 18:41 ` Jan Kiszka
2009-02-17 23:48 ` Jan Kiszka
2009-02-18 7:51 ` Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 3/4] Add --enable-dlopen-skins configure switch Jan Kiszka
2009-02-25 10:04 ` [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-25 11:19 ` Philippe Gerum
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=20090217170419.1425.5174.stgit@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.