From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: "Landau, Bracha" <BLandau@domain.hid>, xenomai@xenomai.org
Subject: Re: [Xenomai-help] kernel oops using mq_open after fork
Date: Wed, 19 Jul 2006 14:59:05 +0200 [thread overview]
Message-ID: <17598.11417.970717.5621@domain.hid> (raw)
In-Reply-To: <17598.7383.550897.877061@domain.hid>
[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 897 bytes --]
Gilles Chanteperdrix wrote:
> Landau, Bracha wrote:
> > I'm using xenomai 2.2 rc3 on a MPC8247, on linux 2.6.14.
> >
> > I have a problem using mq_open. Please see the attached code.
> > If I fork before the mq_open the kernel, I get a kernel oops.
> >
> > Why this behaviour?
>
> The child process has not "bound" the interface, so, it has no
> per-process data. If this is the cause of the oops, the solution is to
> add a pthread_atfork call in xeno_user_skin_init in order for the
> process children to also call xeno_user_skin_init.
Actually, this issue is specific to skins using the per-process data
feature, i.e. only the posix skin now. So, here is a fix that only fixes
the posix skin initialization. If it solve your issue I will commit it.
You only have to rebuild the user-space support, kernel-space support is
unchanged.
--
Gilles Chanteperdrix.
[-- Attachment #2: xeno-posix-fork-handler.diff --]
[-- Type: text/plain, Size: 5285 bytes --]
Index: src/skins/posix/init.c
===================================================================
--- src/skins/posix/init.c (revision 1357)
+++ src/skins/posix/init.c (working copy)
@@ -30,6 +30,7 @@
int __pse51_muxid = -1;
int __rtdm_muxid = -1;
int __rtdm_fd_start = INT_MAX;
+static int fork_handler_registered;
int __wrap_pthread_setschedparam(pthread_t, int, const struct sched_param *);
@@ -58,9 +59,9 @@
}
parm.sched_priority = 0;
- if ((err =
- __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
- &parm))) {
+ 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);
@@ -70,4 +71,14 @@
perror("Xenomai Posix skin init: munlockall");
exit(EXIT_FAILURE);
}
+
+ if (!fork_handler_registered) {
+ err = pthread_atfork(NULL, NULL, &__init_posix_interface);
+ if (err) {
+ fprintf(stderr, "Xenomai Posix skin init: "
+ "pthread_atfork: %s\n", strerror(err));
+ exit(EXIT_FAILURE);
+ }
+ fork_handler_registered = 1;
+ }
}
Index: src/testsuite/switchtest/Makefile.am
===================================================================
--- src/testsuite/switchtest/Makefile.am (revision 1357)
+++ src/testsuite/switchtest/Makefile.am (working copy)
@@ -9,8 +9,7 @@
switch_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
switch_LDADD = \
- -lpthread -lrt \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(testdir)
Index: src/testsuite/switchtest/Makefile.in
===================================================================
--- src/testsuite/switchtest/Makefile.in (revision 1357)
+++ src/testsuite/switchtest/Makefile.in (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
@SET_MAKE@
+SOURCES = $(switch_SOURCES)
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@@ -229,8 +231,7 @@
switch_CPPFLAGS = -I$(top_srcdir)/include/posix $(XENO_USER_CFLAGS) -g -I$(top_srcdir)/include
switch_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
switch_LDADD = \
- -lpthread -lrt \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
EXTRA_DIST = runinfo
all: all-am
Index: src/testsuite/cyclic/Makefile.am
===================================================================
--- src/testsuite/cyclic/Makefile.am (revision 1357)
+++ src/testsuite/cyclic/Makefile.am (working copy)
@@ -9,8 +9,7 @@
cyclictest_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
cyclictest_LDADD = \
- -lpthread -lrt \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(testdir)
Index: src/testsuite/cyclic/Makefile.in
===================================================================
--- src/testsuite/cyclic/Makefile.in (revision 1357)
+++ src/testsuite/cyclic/Makefile.in (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
@SET_MAKE@
+SOURCES = $(cyclictest_SOURCES)
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@@ -229,8 +231,7 @@
cyclictest_CPPFLAGS = -I$(top_srcdir)/include/posix $(XENO_USER_CFLAGS) -DIPIPE_TRACE=1 -I$(top_srcdir)/include
cyclictest_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
cyclictest_LDADD = \
- -lpthread -lrt \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
EXTRA_DIST = runinfo
all: all-am
Index: src/testsuite/irqbench/Makefile.am
===================================================================
--- src/testsuite/irqbench/Makefile.am (revision 1357)
+++ src/testsuite/irqbench/Makefile.am (working copy)
@@ -19,8 +19,7 @@
$(XENO_USER_LDFLAGS)
irqloop_LDADD = \
- -lpthread \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread
irqbench_SOURCES = irqbench.c
Index: src/testsuite/irqbench/Makefile.in
===================================================================
--- src/testsuite/irqbench/Makefile.in (revision 1357)
+++ src/testsuite/irqbench/Makefile.in (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
@SET_MAKE@
+SOURCES = $(irqbench_SOURCES) $(irqloop_SOURCES)
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
@@ -241,8 +243,7 @@
$(XENO_USER_LDFLAGS)
irqloop_LDADD = \
- -lpthread \
- ../../skins/posix/.libs/libpthread_rt.a
+ ../../skins/posix/.libs/libpthread_rt.a -lpthread
irqbench_SOURCES = irqbench.c
irqbench_CPPFLAGS = \
prev parent reply other threads:[~2006-07-19 12:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200607111736.k6BHaCme029123@domain.hid>
2006-07-19 10:47 ` [Xenomai-help] kernel oops using mq_open after fork Landau, Bracha
2006-07-19 11:51 ` Gilles Chanteperdrix
2006-07-19 12:10 ` Philippe Gerum
2006-07-19 12:59 ` Gilles Chanteperdrix [this message]
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=17598.11417.970717.5621@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=BLandau@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.