Skip to contentSkip to conversation

Shell command segfault occurrence phenomenon when xenomai task switching running

DISCUSSION 박경훈(Kyunghoon Park) 수석 두산로보틱스 2 participants 11 messages Sep 26, 2023 – Nov 9, 2023 4 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive

Hello !

I am having difficulty developing a xenomai applications in the linux system.

The xenomai application is implemented to create multiple RT tasks and perform their respective functions by switching between them.

However, a phenomenon was discovered where the linux shell command crashed with a segfault when the xenomai application running (error message in the /var/log/kern.log : ps[1493445]: segfault at 28 ip 00007f18fb955304 sp 00007ffe6a76fb50 error 6 in ld-2.31.so[7f18fb952000+23000])

It occurs in several shell commands(ps, sleep, awk, grep ...) and the symptoms of segfaults are all the same. (occurrence location, occurrence library: ld-2.31.so)

If this xenomai application doesn't run, it won't happen at all

When I checked with GDB, it occurred at "THREAD_SET_STACK_GUARD (stack_chk_guard)" in the glibc's security_init() function(elf/rtld.c)

I tested with the xenomai demo program(/usr/xenomai/demo/altency) instead of the xenomai application, but the same symptoms occurred.

I don't know what the problem is(xenomai porting, xenomai and linux kernel version conflict, ....)

I really need your help.

## Note (enviroment)
xenomai : xenomai-stable.3.1.x
kernel : 5.4.208
gcc : 9.4.0

Thank you

#4 lore raw
Quoted 20 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello !

I am having difficulty developing a xenomai applications in the linux system.

The xenomai application is implemented to create multiple RT tasks and perform their respective functions by switching between them.

However, a phenomenon was discovered where the linux shell command crashed with a segfault when the xenomai application running (error message in the /var/log/kern.log : ps[1493445]: segfault at 28 ip 00007f18fb955304 sp 00007ffe6a76fb50 error 6 in ld-2.31.so[7f18fb952000+23000])

It occurs in several shell commands(ps, sleep, awk, grep ...) and the symptoms of segfaults are all the same. (occurrence location, occurrence library: ld-2.31.so)

If this xenomai application doesn't run, it won't happen at all

When I checked with GDB, it occurred at "THREAD_SET_STACK_GUARD (stack_chk_guard)" in the glibc's security_init() function(elf/rtld.c)

I tested with the xenomai demo program(/usr/xenomai/demo/altency) instead of the xenomai application, but the same symptoms occurred.

Quoted 8 lines

I don't know what the problem is(xenomai porting, xenomai and linux kernel version conflict, ....)

I really need your help.

## Note (enviroment)
xenomai : xenomai-stable.3.1.x
kernel : 5.4.208

You want to update, specifically to include ipipe-core-5.4.255-x86-15 because of [1].

Jan

[1]
https://source.denx.de/Xenomai/ipipe-x86/-/commit/2c7a52ca04566c6a27dd99bb9ea81107b986c49e

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#6 lore raw
In reply to a message not in the archive

[please use "reply-to-all" so that the list is kept in CC]

Quoted 4 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello

Thank you for your support.

Quoted 8 lines

I downloaded and checked the "ipipe-core-5.4.255-x86-15" as you mentioned

This is a kernel source not ipipe patch file

Is this source ipipe patched ?

The patch file for version 5.4.255 could not be found in /pub/xenomai/ipipe/v5.x/x86/

We are no longer generating regular patches, only distributing the full git trees. You can easily generate a patch yourself if you need to, just run

git diff v5.4.255..ipipe-core-5.4.255-x86-15

Jan

Quoted 60 lines

Thank you

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, September 26, 2023 4:07 PM
To: 박경훈(Kyunghoon Park) 수석 두산로보틱스 <[email protected]>; [email protected]
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

Quoted 26 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello !

I am having difficulty developing a xenomai applications in the linux system.

The xenomai application is implemented to create multiple RT tasks and perform their respective functions by switching between them.

However, a phenomenon was discovered where the linux shell command crashed with a segfault when the xenomai application running (error message in the /var/log/kern.log : ps[1493445]: segfault at 28 ip 00007f18fb955304 sp 00007ffe6a76fb50 error 6 in ld-2.31.so[7f18fb952000+23000])

It occurs in several shell commands(ps, sleep, awk, grep ...) and the symptoms of segfaults are all the same. (occurrence location, occurrence library: ld-2.31.so)

If this xenomai application doesn't run, it won't happen at all

When I checked with GDB, it occurred at "THREAD_SET_STACK_GUARD (stack_chk_guard)" in the glibc's security_init() function(elf/rtld.c)

I tested with the xenomai demo program(/usr/xenomai/demo/altency) instead of the xenomai application, but the same symptoms occurred.

I don't know what the problem is(xenomai porting, xenomai and linux kernel version conflict, ....)

Quoted 6 lines

I really need your help.

## Note (enviroment)
xenomai : xenomai-stable.3.1.x
kernel : 5.4.208

You want to update, specifically to include ipipe-core-5.4.255-x86-15 because of [1].

Jan

[1]
https://secure-web.cisco.com/1AImpxM50snQmZ8YzZQz2XlV4We1ONudRWQ9PoQa7X_aG4dRhXh00HDDBJApjd-CvaAmmaxrlK4wslrAtS_Du9_ONxGfPkEiTwkOvOR2oZKFdtHJMOJuWRIBsQBKAK127NOmEhbF4wIhCT43mm0jWvQFQheN9At7DwZCHtV-O2t_S9OjzwKM8OBtWGBaCratvRBu4zahBi3beyu_PVregH6GTjvkCjYP24jCW_NbtT_zIwyEtUypadbi7sPblnuzt94q07-150QLh5U5BPNCwinsyy7X8lVyPMVHvGUEeoGxx3GDN2QGpJppX8zyOhuGx990UdC2ckofPm8MFPP9rmg/https%3A%2F%2Fsource.denx.de%2FXenomai%2Fipipe-x86%2F-%2Fcommit%2F2c7a52ca04566c6a27dd99bb9ea81107b986c49e

--
Siemens AG, Technology
Linux Expert Center

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#7 lore raw

I met a build error as below

arch/x86/kernel/tsc.c: In function ‘tsc_refine_calibration_work’:
arch/x86/kernel/tsc.c:1373:2: error: implicit declaration of function ‘__ipipe_report_clockf req_update’; did you mean ‘__ipipe_report_cleanup’? [-Werror=implicit-function-declaratio ]
1373 | __ipipe_report_clockfreq_update(ipipe_freq);

The macro "__ipipe_report_clockfreq_update" is defined linux/ipipe.h

CONFIG_X86_TSC is enabled.

What's problem ?

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, September 26, 2023 4:49 PM
To: 박경훈(Kyunghoon Park) 수석 두산로보틱스 <[email protected]>
Cc: Xenomai <[email protected]>
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

[please use "reply-to-all" so that the list is kept in CC]

Quoted 7 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello

Thank you for your support.

I downloaded and checked the "ipipe-core-5.4.255-x86-15" as you mentioned

Quoted 7 lines

This is a kernel source not ipipe patch file

Is this source ipipe patched ?

The patch file for version 5.4.255 could not be found in /pub/xenomai/ipipe/v5.x/x86/

We are no longer generating regular patches, only distributing the full git trees. You can easily generate a patch yourself if you need to, just run

git diff v5.4.255..ipipe-core-5.4.255-x86-15

Jan

Quoted 64 lines

Thank you

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, September 26, 2023 4:07 PM
To: 박경훈(Kyunghoon Park) 수석 두산로보틱스 <[email protected]>; [email protected]
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

Quoted 27 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello !

I am having difficulty developing a xenomai applications in the linux system.

The xenomai application is implemented to create multiple RT tasks and perform their respective functions by switching between them.

However, a phenomenon was discovered where the linux shell command crashed with a segfault when the xenomai application running (error message in the /var/log/kern.log : ps[1493445]: segfault at 28 ip 00007f18fb955304 sp 00007ffe6a76fb50 error 6 in ld-2.31.so[7f18fb952000+23000])

It occurs in several shell commands(ps, sleep, awk, grep ...) and the symptoms of segfaults are all the same. (occurrence location, occurrence library: ld-2.31.so)

If this xenomai application doesn't run, it won't happen at all

When I checked with GDB, it occurred at "THREAD_SET_STACK_GUARD (stack_chk_guard)" in the glibc's security_init() function(elf/rtld.c)

I tested with the xenomai demo program(/usr/xenomai/demo/altency) instead of the xenomai application, but the same symptoms occurred.

I don't know what the problem is(xenomai porting, xenomai and linux kernel version conflict, ....)

Quoted 6 lines

I really need your help.

## Note (enviroment)
xenomai : xenomai-stable.3.1.x
kernel : 5.4.208

You want to update, specifically to include ipipe-core-5.4.255-x86-15 because of [1].

Jan

[1]
https://secure-web.cisco.com/1AImpxM50snQmZ8YzZQz2XlV4We1ONudRWQ9PoQa7
X_aG4dRhXh00HDDBJApjd-CvaAmmaxrlK4wslrAtS_Du9_ONxGfPkEiTwkOvOR2oZKFdtH JMOJuWRIBsQBKAK127NOmEhbF4wIhCT43mm0jWvQFQheN9At7DwZCHtV-O2t_S9OjzwKM8 OBtWGBaCratvRBu4zahBi3beyu_PVregH6GTjvkCjYP24jCW_NbtT_zIwyEtUypadbi7sP blnuzt94q07-150QLh5U5BPNCwinsyy7X8lVyPMVHvGUEeoGxx3GDN2QGpJppX8zyOhuGx 990UdC2ckofPm8MFPP9rmg/https%3A%2F%2Fsource.denx.de%2FXenomai%2Fipipe- x86%2F-%2Fcommit%2F2c7a52ca04566c6a27dd99bb9ea81107b986c49e

Quoted 5 lines

--
Siemens AG, Technology
Linux Expert Center

--
Siemens AG, Technology
Linux Expert Center

#8 lore raw
Quoted 8 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

I met a build error as below

arch/x86/kernel/tsc.c: In function ‘tsc_refine_calibration_work’:
arch/x86/kernel/tsc.c:1373:2: error: implicit declaration of function ‘__ipipe_report_clockf req_update’; did you mean ‘__ipipe_report_cleanup’? [-Werror=implicit-function-declaratio ]
1373 | __ipipe_report_clockfreq_update(ipipe_freq);

Quoted 5 lines

The macro "__ipipe_report_clockfreq_update" is defined linux/ipipe.h

CONFIG_X86_TSC is enabled.

What's problem ?

There are two

- you are building with CONFIG_IPIPE disabled
- our patch does not handle that case

We will address the latter in the next I-pipe update, but you should look again into how you configured your kernel build.

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#9 lore raw

Thank you, but there is no detailed manual It's so different from before that it's confusing

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, September 26, 2023 7:01 PM
To: 박경훈(Kyunghoon Park) 수석 두산로보틱스 <[email protected]>
Cc: Xenomai <[email protected]>
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

Quoted 8 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

I met a build error as below

arch/x86/kernel/tsc.c: In function ‘tsc_refine_calibration_work’:
arch/x86/kernel/tsc.c:1373:2: error: implicit declaration of function ‘__ipipe_report_clockf req_update’; did you mean ‘__ipipe_report_cleanup’? [-Werror=implicit-function-declaratio ]
1373 | __ipipe_report_clockfreq_update(ipipe_freq);

Quoted 5 lines

The macro "__ipipe_report_clockfreq_update" is defined linux/ipipe.h

CONFIG_X86_TSC is enabled.

What's problem ?

There are two

- you are building with CONFIG_IPIPE disabled
- our patch does not handle that case

We will address the latter in the next I-pipe update, but you should look again into how you configured your kernel build.

Jan

--
Siemens AG, Technology
Linux Expert Center

#10 lore raw
Quoted 3 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Thank you, but there is no detailed manual
It's so different from before that it's confusing

https://v3.xenomai.org/installation/

Happy to take suggestions how to improve it.

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#11 lore raw
In reply to Jan Kiszka

Hello

I solved segfault issue with your help

As you said, I ported xenomai-stable 3.1.x to ipipe-core-5.4.255-x86-15 and no segfault occurred when executing the shell command

But I met a new problem that xenomai task was killed by xenomai watchdog. This issued occurred about 20 hours running after.

I changed watchdog times(4sec -> 9sec)in the kernel configuration(xenomai debug menu) and re-tested it. But the same phenomenon occurred.

Have there been any reports of a similar phenomenon?

Please advise to me

Thank you

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, September 26, 2023 4:07 PM
To: 박경훈(Kyunghoon Park) 수석 두산로보틱스 <[email protected]>; [email protected]
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

Quoted 26 lines · 박경훈(Kyunghoon Park) 수석 두산로보틱스

Hello !

I am having difficulty developing a xenomai applications in the linux system.

The xenomai application is implemented to create multiple RT tasks and perform their respective functions by switching between them.

However, a phenomenon was discovered where the linux shell command crashed with a segfault when the xenomai application running (error message in the /var/log/kern.log : ps[1493445]: segfault at 28 ip 00007f18fb955304 sp 00007ffe6a76fb50 error 6 in ld-2.31.so[7f18fb952000+23000])

It occurs in several shell commands(ps, sleep, awk, grep ...) and the symptoms of segfaults are all the same. (occurrence location, occurrence library: ld-2.31.so)

If this xenomai application doesn't run, it won't happen at all

When I checked with GDB, it occurred at "THREAD_SET_STACK_GUARD (stack_chk_guard)" in the glibc's security_init() function(elf/rtld.c)

I tested with the xenomai demo program(/usr/xenomai/demo/altency) instead of the xenomai application, but the same symptoms occurred.

I don't know what the problem is(xenomai porting, xenomai and linux kernel version conflict, ....)

Quoted 6 lines

I really need your help.

## Note (enviroment)
xenomai : xenomai-stable.3.1.x
kernel : 5.4.208

You want to update, specifically to include ipipe-core-5.4.255-x86-15 because of [1].

Jan

[1]
https://secure-web.cisco.com/1AImpxM50snQmZ8YzZQz2XlV4We1ONudRWQ9PoQa7X_aG4dRhXh00HDDBJApjd-CvaAmmaxrlK4wslrAtS_Du9_ONxGfPkEiTwkOvOR2oZKFdtHJMOJuWRIBsQBKAK127NOmEhbF4wIhCT43mm0jWvQFQheN9At7DwZCHtV-O2t_S9OjzwKM8OBtWGBaCratvRBu4zahBi3beyu_PVregH6GTjvkCjYP24jCW_NbtT_zIwyEtUypadbi7sPblnuzt94q07-150QLh5U5BPNCwinsyy7X8lVyPMVHvGUEeoGxx3GDN2QGpJppX8zyOhuGx990UdC2ckofPm8MFPP9rmg/https%3A%2F%2Fsource.denx.de%2FXenomai%2Fipipe-x86%2F-%2Fcommit%2F2c7a52ca04566c6a27dd99bb9ea81107b986c49e

--
Siemens AG, Technology
Linux Expert Center

#12 lore raw
Quoted 7 lines · 박경훈(Kyunghoon Park) 팀장 두산로보틱스

Hello

I solved segfault issue with your help

As you said, I ported xenomai-stable 3.1.x to ipipe-core-5.4.255-x86-15 and no segfault occurred when executing the shell command

Quoted 7 lines

But I met a new problem that xenomai task was killed by xenomai watchdog. This issued occurred about 20 hours running after.

I changed watchdog times(4sec -> 9sec)in the kernel configuration(xenomai debug menu) and re-tested it. But the same phenomenon occurred.

Have there been any reports of a similar phenomenon?

Sure, this is a frequent problem of applications that do not leave Linux some time to "breath". Make sure you have no infinitely running RT threads in yours. They should throttle their work every few hundred of milliseconds at least. Maybe there is even a more fundamental issue in your code that causes run-aways threads.

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#13 lore raw

Hello

I am contacting you because the xenomai watchdog issue has not yet been resolved.

When a task is killed by the xenomai watchdog, a dump file is created using GDB.

When I checked the stack frame, I found that the task was always terminated in the gettimeofday() function.

gettimeofday() is called from the python thread, and the python thread was changed to an rt thread using rt_task_shadow().

The xenomai version is 3.1.4 and the linux kernel version is 5.4.255

I know that a system call is used inside gettimeofday(). Will this have any impact?


Thank you

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Friday, October 6, 2023 4:53 PM
To: 박경훈(Kyunghoon Park) 팀장 두산로보틱스 <[email protected]>
Cc: [email protected]
Subject: Re: Shell command segfault occurrence phenomenon when xenomai task switching running

주의: 이 메일은 외부에서 발송 되었습니다. 링크 혹은 첨부파일 열람 시 주의하시기 바랍니다.

CAUTION: This email is sent by an external account. Please take extra caution when clicking the link or opening the attachment.

Quoted 8 lines · 박경훈(Kyunghoon Park) 팀장 두산로보틱스

Hello

I solved segfault issue with your help

As you said, I ported xenomai-stable 3.1.x to ipipe-core-5.4.255-x86-15 and no segfault occurred when executing the shell command

Quoted 7 lines

But I met a new problem that xenomai task was killed by xenomai watchdog. This issued occurred about 20 hours running after.

I changed watchdog times(4sec -> 9sec)in the kernel configuration(xenomai debug menu) and re-tested it. But the same phenomenon occurred.

Have there been any reports of a similar phenomenon?

Sure, this is a frequent problem of applications that do not leave Linux some time to "breath". Make sure you have no infinitely running RT threads in yours. They should throttle their work every few hundred of milliseconds at least. Maybe there is even a more fundamental issue in your code that causes run-aways threads.

Jan

--
Siemens AG, Technology
Linux Expert Center

#14 lore raw
Quoted 6 lines · 박경훈(Kyunghoon Park) 팀장 두산로보틱스

Hello

I am contacting you because the xenomai watchdog issue has not yet been resolved.

When a task is killed by the xenomai watchdog, a dump file is created using GDB.

Quoted 8 lines

When I checked the stack frame, I found that the task was always terminated in the gettimeofday() function.

gettimeofday() is called from the python thread, and the python thread was changed to an rt thread using rt_task_shadow().

The xenomai version is 3.1.4 and the linux kernel version is 5.4.255

I know that a system call is used inside gettimeofday(). Will this have any impact?

Yes, live-lock over I-pipe kernels due to inappropriate glibc library use from RT: Kernel Linux mode tries was interrupted by Xenomai thread while updating the clock parameters in vdso, and the Xenomai thread spins over reading those as the kernel never completes the update.

This is solved by wrapping calls from your application to libc services properly - which also excludes using Python, besides the fact that the Python runtime is not RT in any dimension.

Jan