From: "Krzysztof Błaszkowski" <kb@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] xenomai 2.5.3/native, kernel 2.6.31.8 and fork()
Date: Tue, 17 Aug 2010 14:25:38 +0200 [thread overview]
Message-ID: <1282047938.5255.89.camel@domain.hid> (raw)
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
Hello,
I found recently that large application uses to segfault before fork()
leaves its glibc wrapper.
I included here a test suite which can be easily used to verify what
goes wrong. It may be necessary to adjust makefile to compile the code.
So, the console is missing output from line #89. We can see instead a
message that getpid couldn't be linked which is 1st sign of memory
corruption.
i used to think that this issue could be related to not unbinding heap
before fork() but it turned out that it is enough to link userspace with
xenomai libraries.
I wonder if this is known issue and if there is any fix, does 2.5.4 work
same ? or maybe there is something wrong with the kernel i use (or adeos
patch)
Another question is why rt_task_create() is marked deprecated in native
skin. Does it mean that native skin is going to be removed from source
tree ?
Regards,
--
Krzysztof Blaszkowski
[-- Attachment #2: .try.sh --]
[-- Type: application/x-shellscript, Size: 114 bytes --]
[-- Attachment #3: console.log --]
[-- Type: text/x-log, Size: 368 bytes --]
atest:~/xeno-test # ./.try.sh
main:78 heap 0x401be000
/root/xeno-test
main:88
./xeno-shmem-fork: relocation error: ./xeno-shmem-fork: symbol getpid, version GLIBC_2.0 not defined in file libc.so.6 with link time reference
main:95 [2234] pid 2236
main:98 [2234] pid 2236, status 00007f00
main:99 [2234] pid 2236, WIFSIGNALED 0, WIFEXITED 1, rc 127
4
atest:~/xeno-test #
[-- Attachment #4: Makefile --]
[-- Type: text/x-makefile, Size: 690 bytes --]
export KERNELDIR ?= $(shell pwd)/../kernel
XENODIR = $(KERNELDIR)/INSTALL/xeno/usr/xenomai
obj-m = xeno_shmem_test.o
xeno_shmem_test-objs = xeno-shmem-fork.o
EXTRA_CFLAGS = -I$(XENODIR)/include
U_LDFLAGS = -lnative -lxenomai -L$(XENODIR)/lib -D_XENO_SHMEM_
all: xmodule userland
xmodule: xeno-shmem-fork.c
$(MAKE) -C $(KERNELDIR) SUBDIRS=`pwd` V=0 -o $(KERNELDIR)/Module.symvers modules
userland: xeno-shmem-fork.c
gcc xeno-shmem-fork.c $(EXTRA_CFLAGS) $(U_LDFLAGS) -o xeno-shmem-fork
# gcc xeno-shmem-fork.c $(EXTRA_CFLAGS) -o xeno-shmem-fork
give-a-try:
insmod ./xeno_shmem_test.ko
sleep .1
LD_LIBRARY_PATH=`pwd` ./xeno-shmem-fork
sleep .1
rmmod xeno_shmem_test
[-- Attachment #5: xeno-shmem-fork.c --]
[-- Type: text/x-csrc, Size: 2362 bytes --]
/* xenomai/native - fork() regression test
Systemy mikroprocesorowe 2010
*/
#include <native/heap.h>
#define TEST_HEAP "0x12345"
#ifdef __KERNEL__
#include <linux/module.h>
MODULE_LICENSE("GPL");
#define HEAP_SIZE (16*1024)
RT_HEAP heap_desc;
void *ptr;
int init(void)
{
int err;
err = rt_heap_create(&heap_desc, TEST_HEAP , HEAP_SIZE, H_SHARED);
if (!err) {
err = rt_heap_alloc(&heap_desc, 0, TM_NONBLOCK, &ptr);
}
printk("%s:%d heap %p, rc %d\n", __FUNCTION__, __LINE__, ptr, err);
return err;
}
void exit(void)
{
printk("%s:%d heap %p\n", __FUNCTION__, __LINE__, ptr);
rt_heap_delete(&heap_desc);
}
module_init(init);
module_exit(exit);
#else
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
RT_HEAP heap_desc;
void *shared_mem; /* Start address of the shared memory segment */
/* A shared memory segment with Xenomai is implemented as a mappable
real-time heap object managed as a single memory block. In this
mode, the allocation routine always returns the start address of
the heap memory to all callers, and the free routine always leads
to a no-op. */
#define EXIT_RC 11
int main (int argc, char *argv[])
{
int err;
int pid;
#ifdef _XENO_SHMEM_
err = rt_heap_bind(&heap_desc, TEST_HEAP ,TM_NONBLOCK);
if (err)
return 1;
if (rt_heap_alloc(&heap_desc,0,TM_NONBLOCK,&shared_mem))
return 2;
#endif
printf("%s:%d heap %p\n", __FUNCTION__, __LINE__, shared_mem);
system("pwd");
pid = fork();
if (pid < 0) {
printf("%s:%d errno %d\n", __FUNCTION__, __LINE__, errno);
return 3;
}
if (pid == 0) {
printf("%s:%d\n", __FUNCTION__, __LINE__);
printf("%s:%d [%d] pid %d\n", __FUNCTION__, __LINE__, getpid(), pid);
sleep(1);
exit(EXIT_RC);
} else {
int s;
printf("%s:%d [%d] pid %d\n", __FUNCTION__, __LINE__, getpid(), pid);
waitpid(pid, &s, 0);
printf("%s:%d [%d] pid %d, status %08x\n", __FUNCTION__, __LINE__, getpid(), pid, s);
printf("%s:%d [%d] pid %d, WIFSIGNALED %u, WIFEXITED %u, rc %u\n", __FUNCTION__, __LINE__, getpid(), pid,
WIFSIGNALED(s), WIFEXITED(s), WEXITSTATUS(s));
err = (!WIFSIGNALED(s) && WIFEXITED(s) && (WEXITSTATUS(s) == EXIT_RC)) ? 0 : 4;
}
#ifdef _XENO_SHMEM_
rt_heap_unbind(&heap_desc);
#endif
printf("%d\n", err);
return err;
}
#endif
next reply other threads:[~2010-08-17 12:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-17 12:25 Krzysztof Błaszkowski [this message]
2010-08-17 12:33 ` [Xenomai-core] xenomai 2.5.3/native, kernel 2.6.31.8 and fork() Gilles Chanteperdrix
2010-08-17 12:34 ` Krzysztof Błaszkowski
2010-08-17 12:40 ` Gilles Chanteperdrix
2010-08-17 12:54 ` Krzysztof Błaszkowski
2010-08-17 13:06 ` Gilles Chanteperdrix
2010-08-17 13:19 ` Krzysztof Błaszkowski
2010-08-17 13:27 ` Gilles Chanteperdrix
2010-08-17 13:57 ` Krzysztof Błaszkowski
2010-08-17 14:08 ` Gilles Chanteperdrix
2010-08-17 14:12 ` Krzysztof Błaszkowski
2010-08-17 14:17 ` Gilles Chanteperdrix
2010-08-17 16:07 ` Krzysztof Błaszkowski
2010-08-17 12:35 ` Krzysztof Błaszkowski
2010-08-17 12:40 ` Gilles Chanteperdrix
2010-08-17 14:41 ` Philippe Gerum
2010-08-17 16:09 ` Krzysztof Błaszkowski
2010-08-17 22:59 ` Gilles Chanteperdrix
2010-08-18 10:22 ` Krzysztof Błaszkowski
2010-08-18 11:00 ` Gilles Chanteperdrix
2010-08-18 11:40 ` Krzysztof Błaszkowski
2010-08-18 12:00 ` Gilles Chanteperdrix
2010-08-18 12:17 ` Krzysztof Błaszkowski
2010-08-18 12:37 ` Gilles Chanteperdrix
2010-08-18 12:55 ` Krzysztof Błaszkowski
2010-08-18 13:39 ` Gilles Chanteperdrix
2010-08-18 14:04 ` Krzysztof Błaszkowski
2010-08-18 14:10 ` Gilles Chanteperdrix
2010-08-18 14:25 ` Krzysztof Błaszkowski
2010-08-18 14:30 ` Gilles Chanteperdrix
2010-08-18 15:09 ` Krzysztof Błaszkowski
2010-08-18 15:13 ` Gilles Chanteperdrix
2010-08-18 15:16 ` Krzysztof Błaszkowski
2010-08-18 15:43 ` Gilles Chanteperdrix
2010-08-18 16:30 ` Krzysztof Błaszkowski
2010-08-18 16:51 ` Krzysztof Błaszkowski
2010-08-18 17:17 ` Krzysztof Błaszkowski
2010-08-20 9:47 ` Krzysztof Błaszkowski
2010-08-20 9:54 ` Gilles Chanteperdrix
2010-08-20 15:50 ` Krzysztof Błaszkowski
2010-08-21 17:06 ` Gilles Chanteperdrix
2010-08-21 17:36 ` Gilles Chanteperdrix
2010-08-22 15:13 ` Philippe Gerum
2010-08-22 23:34 ` Gilles Chanteperdrix
2010-08-18 15:13 ` Krzysztof Błaszkowski
2010-08-18 11:05 ` Gilles Chanteperdrix
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=1282047938.5255.89.camel@domain.hid \
--to=kb@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.