Skip to contentSkip to conversation

Warning when compiling trunk.

Xenomai-core Gilles Chanteperdrix 3 participants 20 messages Oct 20, 2008 – Oct 21, 2008

lore
Share & tools
lore
#0 lore raw

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Signature · 1 line
					    Gilles.
#2 lore raw
Quoted 7 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Quoted 5 lines

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

Signature · 1 line
					    Gilles.
#3 lore raw
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

Quoted 7 lines
Quoted 3 lines

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Signature · 1 line
					    Gilles.
#4 lore raw
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Jan

#5 lore raw
Quoted 14 lines · Jan Kiszka
Quoted 13 lines · Gilles Chanteperdrix
Quoted 12 lines · Gilles Chanteperdrix
Quoted 11 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Signature · 1 line
					    Gilles.
#6 lore raw
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gilles Chanteperdrix
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Quoted 8 lines
Quoted 5 lines

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Quoted 7 lines
Quoted 2 lines

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

However, another problem, should not the __thread variables be given the weak attribute too? If a native thread tries to use a pthread mutex, I want pthread_mutex_lock to obtain the current xnhandle_t set by the native skin, not an inexistant one that should have been set by the posix skin but obviously has not.

Signature · 1 line
					    Gilles.
#7 lore raw
Quoted 21 lines · Gilles Chanteperdrix
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gilles Chanteperdrix
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Quoted 8 lines
Quoted 5 lines

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

What did you change? Can you explain the why to me?

Quoted 7 lines

However, another problem, should not the __thread variables be given the weak attribute too? If a native thread tries to use a pthread mutex, I want pthread_mutex_lock to obtain the current xnhandle_t set by the native skin, not an inexistant one that should have been set by the posix skin but obviously has not.

Yes, true. Please commit a fix as you are already patching.

Jan

#8 lore raw
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Gilles Chanteperdrix
Quoted 22 lines · Gilles Chanteperdrix
Quoted 21 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

What did you change? Can you explain the why to me?

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Signature · 1 line
					    Gilles.
#9 lore raw
Quoted 29 lines · Gilles Chanteperdrix
Quoted 28 lines · Jan Kiszka
Quoted 27 lines · Gilles Chanteperdrix
Quoted 26 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Gilles Chanteperdrix
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Yes, that was the problem.

What did you change? Can you explain the why to me?

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Sorry, makes no sense to me: *iargs is on the stack of the rt_task_create caller, and that one is not expected to proceed until we issue __xn_sys_barrier.

Jan

#10 lore raw
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 18 lines · Gilles Chanteperdrix
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Gilles Chanteperdrix
Quoted 15 lines · Gilles Chanteperdrix
Quoted 11 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

What did you change? Can you explain the why to me?

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Sorry, makes no sense to me: *iargs is on the stack of the rt_task_create caller, and that one is not expected to proceed until we issue __xn_sys_barrier.

Well I am busy with the ARM FCSE now. Do you want my test case ?

Signature · 1 line
					    Gilles.
#11 lore raw
Quoted 33 lines · Gilles Chanteperdrix
Quoted 32 lines · Jan Kiszka
Quoted 31 lines · Gilles Chanteperdrix
Quoted 30 lines · Jan Kiszka
Quoted 21 lines · Gilles Chanteperdrix
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gilles Chanteperdrix
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Quoted 8 lines
Quoted 5 lines

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

What did you change? Can you explain the why to me?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Sorry, makes no sense to me: *iargs is on the stack of the rt_task_create caller, and that one is not expected to proceed until we issue __xn_sys_barrier.

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

Jan

#12 lore raw
Quoted 4 lines · Jan Kiszka
Quoted 1 line · Gilles Chanteperdrix

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

Signature · 1 line
					    Gilles.

#include <stdio.h>

#include <sys/mman.h>
#include <pthread.h>

#include <native/task.h>

void relaxed_thread(void *cookie)

{
	rt_task_set_mode(T_PRIMARY, 0, NULL);
	for (;;)
		;
}

int main(void)

{
	struct sched_param p;
	RT_TASK tid;

	mlockall(MCL_CURRENT | MCL_FUTURE);
	
	p.sched_priority = 99;
	pthread_setschedparam(pthread_self(), SCHED_FIFO, &p);

	rt_task_spawn(&tid, "relax", 65536, 12, 0, relaxed_thread, NULL);
	sleep(1);

	rt_task_suspend(&tid);
	sleep(1);

	exit(EXIT_SUCCESS);
}
#13 lore raw
Quoted 5 lines · Gilles Chanteperdrix
Quoted 3 lines · Jan Kiszka
Quoted 1 line · Gilles Chanteperdrix

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

It doesn't trigger. Can you reproduce on x86?

Jan

#14 lore raw
Quoted 7 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix
Quoted 3 lines · Jan Kiszka
Quoted 1 line · Gilles Chanteperdrix

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

It doesn't trigger. Can you reproduce on x86?

I think it will trigger more easily on UP. Did you try on UP ?

Signature · 1 line
					    Gilles.
#15 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix
Quoted 3 lines · Jan Kiszka
Quoted 1 line · Gilles Chanteperdrix

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

It doesn't trigger. Can you reproduce on x86?

Beware, I just noticed that I commited my fix. I thought I had commited only files where I made changes for SIGWINCH, but it happens that I had also made changes for SIGWINCH in src/skins/native/task.c

Signature · 1 line
					    Gilles.
#16 lore raw
Quoted 11 lines · Gilles Chanteperdrix
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Gilles Chanteperdrix
Quoted 3 lines · Jan Kiszka
Quoted 1 line · Gilles Chanteperdrix

Well I am busy with the ARM FCSE now. Do you want my test case ?

Yes, hoping that it triggers on x86 as well. And is toolchain independent.

It doesn't trigger. Can you reproduce on x86?

Beware, I just noticed that I commited my fix. I thought I had commited only files where I made changes for SIGWINCH, but it happens that I had also made changes for SIGWINCH in src/skins/native/task.c

I ran my local version of yesterday afternoon, and I used UP - no segfaults. This issue remains fishy. Even if there is a race, we need to understand it first. And I'm still failing to see what races.

Jan

#17 lore raw
In reply to Jan Kiszka
Quoted 31 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Gilles Chanteperdrix
Quoted 18 lines · Gilles Chanteperdrix
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Gilles Chanteperdrix
Quoted 15 lines · Gilles Chanteperdrix
Quoted 11 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Yes, that was the problem.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

What did you change? Can you explain the why to me?

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Sorry, makes no sense to me: *iargs is on the stack of the rt_task_create caller, and that one is not expected to proceed until we issue __xn_sys_barrier.

Gilles is right, the caller may vanish before your thread variable is assigned. __sys_barrier is there to synchronize with rt_task_start(), not internally with the task creator.

parent: rt_task_create

	-> child: rt_task_trampoline
		-> xnshadow_map
			-> wakeup_process(parent)
<parent stack unwinding>
	-> child: assignment from automatic data, oops.

You may want to track how the completion block is used.

Quoted 10 lines

Jan

------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.
#18 lore raw
Quoted 45 lines · Philippe Gerum
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Gilles Chanteperdrix
Quoted 28 lines · Jan Kiszka
Quoted 27 lines · Gilles Chanteperdrix
Quoted 26 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Quoted 12 lines · Gilles Chanteperdrix
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Yes, that was the problem.

What did you change? Can you explain the why to me?

Because I guess iargs is no longer valid at this point. So, I saved the task pointer and reused it.

Sorry, makes no sense to me: *iargs is on the stack of the rt_task_create caller, and that one is not expected to proceed until we issue __xn_sys_barrier.

Gilles is right, the caller may vanish before your thread variable is assigned. __sys_barrier is there to synchronize with rt_task_start(), not internally with the task creator.

Quoted 8 lines

parent: rt_task_create

	-> child: rt_task_trampoline
		-> xnshadow_map
			-> wakeup_process(parent)
<parent stack unwinding>
	-> child: assignment from automatic data, oops.

You may want to track how the completion block is used.

Damn, signal_completion is already invoked by xnshadow_map - OK, now this makes a lot of sense.

Just checked the rest, and I introduced the same issue to vxworks. Will fix.

Jan

#19 lore raw
In reply to Gilles Chanteperdrix
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gilles Chanteperdrix
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix

I get this warning when compiling trunk:

checking for __thread... rm: cannot remove `conftest1.dir': Is a directory yes

Quoted 8 lines
Quoted 5 lines

That simple, it's a typo in this line:

http://www.rts.uni-hannover.de/xenomai/lxr/source/configure.in?v=SVN-trunk#394

Also, that rm should be done outside the if block to play safe.

Ok. But once this is fixed, I get a segmentation fault with __thread on ARM in rt_task_trampoline. I am currently testing the SIGWINCH thing, and if __thread is disabled, there is no segfault.

If a #ifdef 0 xeno_set_current, there is no segfault.

Quoted 7 lines
Quoted 2 lines

Interesting. What about removing the initial-exec attributes? Is __thread otherwise know to work on your platform?

Yes. This is a race condition, the real bug is, IMHO:

	__native_self = *iargs->task;

When the segfault happens iargs->task is NULL. I suspect you are not supposed to use iargs after the __native_task_create syscall.

Don't see the race yet. iargs is provided by the trampoline creator, and with that one we synchronize with the barrier AFTER this access - or does the compiler some fancy reordering here?

Jan