rt_task_resume() resumes a wrong task
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.
What I observe is that, when calling rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data in RT_TASK function as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when the rt_task_resume() was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that calling rt_task_resume() on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?
I know that is some of a stressful test: in fact if I call the rt_task_resume() only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Thanks in advance, regards
Signature · 1 line
Mauro S.
Quoted 35 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.
Quoted 4 lines
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Can you rule out data races on the shared TaskList structure? Seems both your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 41 lines · Jan Kiszka
Quoted 35 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 4 lines
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Quoted 7 lines
Can you rule out data races on the shared TaskList structure? Seems both your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?
Jan
Hi Jan,
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
Thanks, regards
Signature · 1 line
Mauro S.
Quoted 49 lines · Mauro S
Quoted 46 lines · Jan Kiszka
Quoted 35 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 4 lines
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Can you rule out data races on the shared TaskList structure? Seems both your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?
Quoted 9 lines
Quoted 2 lines
Jan
Hi Jan,
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 55 lines · Jan Kiszka
Quoted 54 lines · Mauro S
Quoted 41 lines · Jan Kiszka
Quoted 35 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 4 lines
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Quoted 7 lines
Can you rule out data races on the shared TaskList structure? Seems both your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?
Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.
Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags. In detail, TaskList elements are accessed:
- by main task
- under task creation, writing task handler and "joined" flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task
handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start
- by sub-tasks ourselves: during their execution. Variables written: "started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it
- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 4 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Quoted 126 lines · Mauro S
Quoted 113 lines · Mauro S
Quoted 66 lines · Jan Kiszka
Quoted 65 lines · Mauro S
Quoted 51 lines · Jan Kiszka
Quoted 43 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Quoted 8 lines
Can you rule out data races on the shared TaskList structure? Seems both
your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 4 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
Quoted 10 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Quoted 7 lines
Hi Jan,
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Thanks for this. Still need to look into it - ETOOMANYOTHERBUGS ;)
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 94 lines · Mauro S
Quoted 55 lines · Jan Kiszka
Quoted 54 lines · Mauro S
Quoted 41 lines · Jan Kiszka
Quoted 35 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 4 lines
Launching the attached code, you should be able to reproduce the problem on your side. When the test detects a wrong resume, program terminates automatically.
Quoted 7 lines
Can you rule out data races on the shared TaskList structure? Seems both your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?
Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags. In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task
handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not
"joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1Printf sequence seems to confirm that execution order is OK.
Quoted 4 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
Quoted 9 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Thanks in advance, regards
Mauro
Quoted 126 lines · Mauro S
Quoted 113 lines · Mauro S
Quoted 66 lines · Jan Kiszka
Quoted 65 lines · Mauro S
Quoted 51 lines · Jan Kiszka
Quoted 43 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Quoted 8 lines
Can you rule out data races on the shared TaskList structure? Seems both
your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 4 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
Quoted 10 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Quoted 7 lines
Hi Jan,
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Starting to look into this:
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)
Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Quoted 2 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUME
Instead, we see that spurious wakeup of task1. Let me debug into this...
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 129 lines · Jan Kiszka
Quoted 128 lines · Mauro S
Quoted 113 lines · Mauro S
Quoted 66 lines · Jan Kiszka
Quoted 65 lines · Mauro S
Quoted 51 lines · Jan Kiszka
Quoted 43 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error, not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Quoted 8 lines
Can you rule out data races on the shared TaskList structure? Seems both
your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core setup?Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and
task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 4 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and study the task interaction (trace-cmd report / kernelshark).
Quoted 10 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 8 lines
Quoted 5 lines
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Starting to look into this:
Great, thank you!
Quoted 14 lines
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
Quoted 9 lines
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Yes, exactly: task is ended yet, then should be joined and not resumed, but I would expect that the resume command was ignored and/or an error was returned.
Quoted 5 lines
Quoted 2 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEInstead, we see that spurious wakeup of task1. Let me debug into this...
Thumbs up!
TIA
Mauro
Quoted 191 lines · Jan Kiszka
Quoted 175 lines · Mauro S
Quoted 135 lines · Jan Kiszka
Quoted 134 lines · Mauro S
Quoted 119 lines · Mauro S
Quoted 71 lines · Jan Kiszka
Quoted 70 lines · Mauro S
Quoted 55 lines · Jan Kiszka
Quoted 47 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main
task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the
beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error,
not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the
problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Quoted 9 lines
Can you rule out data races on the shared TaskList structure? Seems both
your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core
setup?Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and
task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 5 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 10 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 8 lines
Quoted 5 lines
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Starting to look into this:
Great, thank you!
Quoted 14 lines
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)Quoted 9 lines
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Yes, exactly: task is ended yet, then should be joined and not resumed, but I would expect that the resume command was ignored and/or an error was returned.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEInstead, we see that spurious wakeup of task1. Let me debug into this...
Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed, even before someone joined that task. And task1 handle was freed as well before you call CreateAndStartFn(1) again. Now your task1 will get the handle of previous task0, and when you try to use that stale handle for resuming task0, alchemy looks up the new task1 instead - and resumes that.
Quoted 8 lines
I looked a bit into whether we could delay the handle deregistration after the joining, but that would be a hairy operation, likely also affecting libcopperplate. Given all that, I think we are safer off living with this "specialty", rather than risking instability in the cleanup path to handle the application error a bit nicer.
Jan
Ok, got it.
IMO this behavior should be documented somewhere because it's not what a user would expect.
Just throwing out an idea (that could be completely wrong): to workaround the deregistration issue, should the resume function use both the two RT_TASK fields to decide if resume or not a task, resuming it only if both the two IDs matching? From the log seems that the second field (pthread ID?) stills occupied until the join happens.
Thanks in advance, regards
Mauro
Quoted 175 lines · Mauro S
Quoted 135 lines · Jan Kiszka
Quoted 134 lines · Mauro S
Quoted 119 lines · Mauro S
Quoted 71 lines · Jan Kiszka
Quoted 70 lines · Mauro S
Quoted 55 lines · Jan Kiszka
Quoted 47 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299. Target image and toolchain generated by Yocto.
Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main
task resumes all tasks. They do a small sleep and then terminates. Terminated tasks are joined by another task, that was launched at the
beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when thert_task_resume()was called on Task0. Task0 has been terminated its execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error,
not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the executed flag adding "&& TaskList[i].executed == 0" into the if) the
problem obviously does not happen, but as I said I expect an error instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Quoted 9 lines
Can you rule out data races on the shared TaskList structure? Seems both
your sub-tasks and the main one are accessing it, and that possibly concurrently and/or unordered. Or does this also trigger in a uni-core
setup?Jan
Hi Jan,
Quoted 8 lines
Quoted 4 lines
attached the modified code: each access to a TaskList element is now protected with a semaphore (one semaphore each element). Strange behavior happens anyway.
...would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined" flag: this happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 5 lines
If you would like to understand a bit more already, you could catch an event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 10 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I need to setup a qemu image with it).
Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 8 lines
Quoted 5 lines
I made a sequential version of the test application: instead of having a join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.
Starting to look into this:
Great, thank you!
Quoted 14 lines
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)Quoted 9 lines
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Yes, exactly: task is ended yet, then should be joined and not resumed, but I would expect that the resume command was ignored and/or an error was returned.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEInstead, we see that spurious wakeup of task1. Let me debug into this...
Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed, even before someone joined that task. And task1 handle was freed as well before you call CreateAndStartFn(1) again. Now your task1 will get the handle of previous task0, and when you try to use that stale handle for resuming task0, alchemy looks up the new task1 instead - and resumes that.
I looked a bit into whether we could delay the handle deregistration after the joining, but that would be a hairy operation, likely also affecting libcopperplate. Given all that, I think we are safer off living with this "specialty", rather than risking instability in the cleanup path to handle the application error a bit nicer.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 224 lines · Mauro S
Quoted 208 lines · Jan Kiszka
Quoted 194 lines · Mauro S
Quoted 149 lines · Jan Kiszka
Quoted 148 lines · Mauro S
Quoted 132 lines · Mauro S
Quoted 79 lines · Jan Kiszka
Quoted 78 lines · Mauro S
Quoted 70 lines · Jan Kiszka
Quoted 53 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299.
Target image and toolchain generated by Yocto.Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main
task resumes all tasks. They do a small sleep and then terminates.
Terminated tasks are joined by another task, that was launched at the
beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when
thert_task_resume()was called on Task0. Task0 has been terminated its
execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error,
not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the
executed flag adding "&& TaskList[i].executed == 0" into the if) the
problem obviously does not happen, but as I said I expect an error
instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Can you rule out data races on the shared TaskList structure? Seems
both
your sub-tasks and the main one are accessing it, and that possibly
concurrently and/or unordered. Or does this also trigger in a uni-core
setup?Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
Quoted 5 lines
attached the modified code: each access to a TaskList element is now
protected with a semaphore (one semaphore each element). Strange behavior happens anyway....would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined"
flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only
after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 6 lines
If you would like to understand a bit more already, you could catch an
event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 11 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I
need to setup a qemu image with it).Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
Quoted 6 lines
I made a sequential version of the test application: instead of having a
join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.Starting to look into this:
Great, thank you!
Quoted 14 lines
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)Quoted 9 lines
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Yes, exactly: task is ended yet, then should be joined and not resumed, but I would expect that the resume command was ignored and/or an error was returned.
Quoted 4 lines
Quoted 3 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEQuoted 5 lines
Quoted 3 lines
Instead, we see that spurious wakeup of task1. Let me debug into this...
Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed, even before someone joined that task. And task1 handle was freed as well before you call CreateAndStartFn(1) again. Now your task1 will get the handle of previous task0, and when you try to use that stale handle for resuming task0, alchemy looks up the new task1 instead - and resumes that.
Quoted 8 lines
I looked a bit into whether we could delay the handle deregistration after the joining, but that would be a hairy operation, likely also affecting libcopperplate. Given all that, I think we are safer off living with this "specialty", rather than risking instability in the cleanup path to handle the application error a bit nicer.
Jan
Ok, got it.
IMO this behavior should be documented somewhere because it's not what a user would expect.
Quoted 6 lines
Just throwing out an idea (that could be completely wrong): to workaround the deregistration issue, should the resume function use both the two
RT_TASKfields to decide if resume or not a task, resuming it only if both the two IDs matching? From the log seems that the second field (pthread ID?) stills occupied until the join happens.
I played with that idea. It initially looked simple, then reveal a catch, but I think I was able to address that as well. Please have a look at the patches I just shared.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 232 lines · Jan Kiszka
Quoted 224 lines · Mauro S
Quoted 208 lines · Jan Kiszka
Quoted 194 lines · Mauro S
Quoted 149 lines · Jan Kiszka
Quoted 148 lines · Mauro S
Quoted 132 lines · Mauro S
Quoted 79 lines · Jan Kiszka
Quoted 78 lines · Mauro S
Quoted 70 lines · Jan Kiszka
Quoted 53 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something nasty.
I'm using Xenomai 3.2.8 on an Intel Atom system with Linux 5.4.299.
Target image and toolchain generated by Yocto.Please find attached test case code.
Program is very simple: the main task starts a bunch of joinable tasks
that immediately suspend theirselves. After starting tasks, the main
task resumes all tasks. They do a small sleep and then terminates.
Terminated tasks are joined by another task, that was launched at the
beginning of the program execution.
Subsequently, main task continues to recreate, restart and resume joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong task is
resumed.
Please see the attached log. In this log I'm printing the .handle and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9, the same
of the terminated but not yet joined task 0) has been resumed when
thert_task_resume()was called on Task0. Task0 has been terminated its
execution, but has NOT been joined yet: if I'm not wrong its resources
should not be usable until join is done (at least this is what I understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an error,
not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also the
executed flag adding "&& TaskList[i].executed == 0" into the if) the
problem obviously does not happen, but as I said I expect an error
instead of a wrong resume.Quoted 6 lines
Launching the attached code, you should be able to reproduce the problem
on your side. When the test detects a wrong resume, program terminates
automatically.Can you rule out data races on the shared TaskList structure? Seems
both
your sub-tasks and the main one are accessing it, and that possibly
concurrently and/or unordered. Or does this also trigger in a uni-core
setup?Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
Quoted 5 lines
attached the modified code: each access to a TaskList element is now
protected with a semaphore (one semaphore each element). Strange behavior happens anyway....would have been too easy. Ok, will try the other day if I can reproduce and maybe even understand.
Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList elements, but I already verified that code should access them in an ordered way without concurrency, thanks to "joined", "started" and "exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined"
flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and
task handler) and writing "resumed" flag before resuming the task. Here, "started" must be 1 and "joined" must be 0, this can happen only
after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before termination, after task is resumed and did its sleep). Also, verifies "resumed" flag when got resumed, to check if resume request was for it- by join task: this happens only if task is "started", "exited" and not "joined". This can happen only after a complete subtask execution task resets all flags and sets "joined" to 1
Printf sequence seems to confirm that execution order is OK.
Quoted 6 lines
If you would like to understand a bit more already, you could catch an
event trace (trace-cmd record -e "cobalt*" -e "sched*" -e "signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 11 lines
I'll do the setup to trace events (I don't have trace-cmd on target, I
need to setup a qemu image with it).Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
Quoted 6 lines
I made a sequential version of the test application: instead of having a
join task, join call was done by the main task, one subtask at time. With this code, tasks does not access concurrently to variables. Problem happens also with this code.Starting to look into this:
Great, thank you!
Quoted 14 lines
Quoted 5 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) RESUMING TASK Task0 (82a9eab0-829636c0)Quoted 8 lines
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext: 82a9e2b0-829526c0) TASK Task0 EXITED (self: 82a9eab0-829636c0 ext: 82a9eab0-829636c0) JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)Quoted 9 lines
So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
And here you are resuming a task that is in waiting-to-be-joined state, right? That is an application bug, but one may expect it to be either ignored, only affect that Task0 negatively, or even throwing an error back to the caller.
Yes, exactly: task is ended yet, then should be joined and not resumed, but I would expect that the resume command was ignored and/or an error was returned.
Quoted 4 lines
Quoted 3 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext: 82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEQuoted 5 lines
Quoted 3 lines
Instead, we see that spurious wakeup of task1. Let me debug into this...
Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed, even before someone joined that task. And task1 handle was freed as well before you call CreateAndStartFn(1) again. Now your task1 will get the handle of previous task0, and when you try to use that stale handle for resuming task0, alchemy looks up the new task1 instead - and resumes that.
Quoted 8 lines
I looked a bit into whether we could delay the handle deregistration after the joining, but that would be a hairy operation, likely also affecting libcopperplate. Given all that, I think we are safer off living with this "specialty", rather than risking instability in the cleanup path to handle the application error a bit nicer.
Jan
Ok, got it.
IMO this behavior should be documented somewhere because it's not what a user would expect.Quoted 6 lines
Just throwing out an idea (that could be completely wrong): to workaround the deregistration issue, should the resume function use both the two
RT_TASKfields to decide if resume or not a task, resuming it only if both the two IDs matching? From the log seems that the second field (pthread ID?) stills occupied until the join happens.
Quoted 6 lines
I played with that idea. It initially looked simple, then reveal a catch, but I think I was able to address that as well. Please have a look at the patches I just shared.
Jan
Hi Jan,
I've seen patches, thanks a lot!
Unfortunately I'm not able to test them on the final system, but a quick test in a QEMU machine works properly (no doubts about it).
As soon as I'll test on the final system, I'll be back with a feedback.
Thanks again, regards
Signature · 1 line
Mauro S.
Quoted 325 lines · Mauro S.
Quoted 309 lines · Jan Kiszka
Quoted 298 lines · Mauro S
Quoted 287 lines · Jan Kiszka
Quoted 257 lines · Mauro S
Quoted 206 lines · Jan Kiszka
Quoted 195 lines · Mauro S
Quoted 178 lines · Mauro S
Quoted 113 lines · Jan Kiszka
Quoted 102 lines · Mauro S
Quoted 96 lines · Jan Kiszka
Quoted 74 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or I'm doing something
nasty.I'm using Xenomai 3.2.8 on an Intel Atom system with Linux
5.4.299.
Target image and toolchain generated by Yocto.Please find attached test case code. Program is very simple: the main task starts a bunch of joinable
tasks
that immediately suspend theirselves. After starting tasks, the
main
task resumes all tasks. They do a small sleep and then
terminates.
Terminated tasks are joined by another task, that was launched
at the
beginning of the program execution. Subsequently, main task continues to recreate, restart and resume
joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong
task is
resumed.
Please see the attached log. In this log I'm printing the .handle
and .thread data inRT_TASKfunction as hexadecimal.
At row 19 you can see that Task1 (that has .handle value fc1c9,
the same
of the terminated but not yet joined task 0) has been resumed
when
thert_task_resume()was called on Task0. Task0 has been
terminated its
execution, but has NOT been joined yet: if I'm not wrong its
resources
should not be usable until join is done (at least this is what I
understand by documentation). I expect that callingrt_task_resume()on
a terminated-but-not-yet-joined joinable task should return an
error,
not resume another task. Am I wrong?I know that is some of a stressful test: in fact if I call the
rt_task_resume()only if task is not terminated (checking also
the
executed flag adding "&& TaskList[i].executed == 0" into the if)
the
problem obviously does not happen, but as I said I expect an
error
instead of a wrong resume.Quoted 8 lines
Launching the attached code, you should be able to reproduce the
problem
on your side. When the test detects a wrong resume, program
terminates
automatically.Can you rule out data races on the shared
TaskList structure?
Seems
both
your sub-tasks and the main one are accessing it,
and that
possibly
concurrently and/or unordered. Or does this also
trigger in a
uni-core
setup?Quoted 2 lines
Jan
Quoted 9 lines
Hi Jan,
attached the modified code: each access to a
TaskList element is
now
protected with a semaphore (one semaphore each
element).
Strange behavior happens anyway.Quoted 4 lines
...would have been too easy. Ok, will try the other day if I can
reproduce and maybe even understand.Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList
elements, but I already verified that code should access them in an
ordered way without concurrency, thanks to "joined", "started" and
"exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined"
flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and
task handler) and writing "resumed" flag before resuming the task.
Here, "started" must be 1 and "joined" must be 0, this can happen
only
after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before
termination, after task is resumed and did its sleep). Also, verifies
"resumed" flag when got resumed, to check if resume request was
for it- by join task: this happens only if task is "started", "exited" and
not "joined". This can happen only after a complete subtask execution
task resets all flags and sets "joined" to 1Printf sequence seems to confirm that execution order is OK.
Quoted 9 lines
If you would like to understand a bit more already, you could
catch an
event trace (trace-cmd record -e "cobalt*" -e "sched*" -e
"signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 12 lines
I'll do the setup to trace events (I don't have trace- cmd on
target, I
need to setup a qemu image with it).Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
I made a sequential version of the test application:
instead of
having a
join task, join call was done by the main task, one subtask at time.
With this code, tasks does not access concurrently to variables.
Problem happens also with this code.Quoted 2 lines
Starting to look into this:
Great, thank you!
Quoted 25 lines
Quoted 12 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)
RESUMING TASK Task0 (82a9eab0-829636c0)
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)Quoted 8 lines
TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)
TASK Task0 EXITED (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0)So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
Quoted 8 lines
And here you are resuming a task that is in waiting-to-be- joined state,
right? That is an application bug, but one may expect it to be either
ignored, only affect that Task0 negatively, or even throwing an error
back to the caller.Yes, exactly: task is ended yet, then should be joined and not resumed,
but I would expect that the resume command was ignored and/or an error
was returned.Quoted 5 lines
Quoted 4 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEQuoted 6 lines
Quoted 4 lines
Instead, we see that spurious wakeup of task1. Let me debug into
this...Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed,
even before someone joined that task. And task1 handle was freed as well
before you call CreateAndStartFn(1) again. Now your task1 will get the
handle of previous task0, and when you try to use that stale handle for
resuming task0, alchemy looks up the new task1 instead - and resumes
that.I looked a bit into whether we could delay the handle deregistration
after the joining, but that would be a hairy operation, likely also
affecting libcopperplate. Given all that, I think we are safer off
living with this "specialty", rather than risking instability in the
cleanup path to handle the application error a bit nicer.Quoted 2 lines
Jan
Ok, got it.
IMO this behavior should be documented somewhere because it's not what a
user would expect.Quoted 9 lines
Just throwing out an idea (that could be completely wrong): to workaround the deregistration issue, should the resume function use both
the twoRT_TASKfields to decide if resume or not a task, resuming it
only if both the two IDs matching? From the log seems that the second
field (pthread ID?) stills occupied until the join happens.Quoted 7 lines
I played with that idea. It initially looked simple, then reveal a catch, but I think I was able to address that as well. Please have a
look at the patches I just shared.Jan
Hi Jan,
I've seen patches, thanks a lot!
Unfortunately I'm not able to test them on the final system, but a quick
test in a QEMU machine works properly (no doubts about it).
Quoted 5 lines
As soon as I'll test on the final system, I'll be back with a feedback.
Thanks again, regards
Hi Jan,
sorry for the long delay.
I managed to try your patches on the final system and I confirm that they work.
Thanks a lot, regards
Mauro
Quoted 329 lines · Mauro S.
Quoted 328 lines · Mauro S.
Quoted 309 lines · Jan Kiszka
Quoted 298 lines · Mauro S
Quoted 287 lines · Jan Kiszka
Quoted 257 lines · Mauro S
Quoted 206 lines · Jan Kiszka
Quoted 195 lines · Mauro S
Quoted 178 lines · Mauro S
Quoted 113 lines · Jan Kiszka
Quoted 102 lines · Mauro S
Quoted 96 lines · Jan Kiszka
Quoted 82 lines · Mauro S
Hi all,
Not sure if I found an obscure corner case or
I'm doing something
nasty.I'm using Xenomai 3.2.8 on an Intel Atom system
with Linux
5.4.299.
Target image and toolchain generated by Yocto.Please find attached test case code.
Program is very simple: the main task starts a
bunch of joinable
tasks
that immediately suspend theirselves. After
starting tasks, the
main
task resumes all tasks. They do a small sleep
and then
terminates.
Terminated tasks are joined by another task,
that was launched
at the
beginning of the program execution.
Subsequently, main task continues to recreate,
restart and resume
joined
tasks, on and on, until a CTRL+C is issued.What I observe is that, when calling
rt_task_resume(), the wrong
task is
resumed.
Please see the attached log. In this log I'm
printing the .handle
and .thread data in RT_TASK function as
hexadecimal.
At row 19 you can see that Task1 (that has
.handle value fc1c9,
the same
of the terminated but not yet joined task 0)
has been resumed
when
the
rt_task_resume() was called on Task0. Task0 has
been
terminated its
execution, but has NOT been joined yet: if I'm
not wrong its
resources
should not be usable until join is done (at
least this is what I
understand by documentation). I expect that
calling
rt_task_resume() on
a terminated-but-not-yet-joined joinable task
should return an
error,
not resume another task. Am I wrong?I know that is some of a stressful test: in
fact if I call the
rt_task_resume() only if task is not terminated
(checking also
the
executed flag adding "&& TaskList[i].executed
== 0" into the if)
the
problem obviously does not happen, but as I
said I expect an
error
instead of a wrong resume.Launching the attached code, you should be able
to reproduce the
problem
on your side. When the test detects a wrong
resume, program
terminates
automatically.Can you rule out data races on the shared
TaskList structure?
Seems
both
your sub-tasks and the main one are accessing it,
and that
possibly
concurrently and/or unordered. Or does this also
trigger in a
uni-core
setup?Quoted 2 lines
Jan
Quoted 9 lines
Hi Jan,
attached the modified code: each access to a
TaskList element is
now
protected with a semaphore (one semaphore each
element).
Strange behavior happens anyway.Quoted 4 lines
...would have been too easy. Ok, will try the other day if I can
reproduce and maybe even understand.Hi Jan,
sorry, I should me more verbose in my response.
First of all: no pressure, take your time.Then, a more deep explanation.
I added semaphores to avoid possible concurrent access on TaskList
elements, but I already verified that code should access them in an
ordered way without concurrency, thanks to "joined", "started" and
"exited" flags.
In detail, TaskList elements are accessed:- by main task
- under task creation, writing task handler and "joined"
flag: this
happens only if task was joined before
- to resume task, reading some elements ("started", "joined" and
task handler) and writing "resumed" flag before resuming the task.
Here, "started" must be 1 and "joined" must be 0, this can happen
only
after task creation and start- by sub-tasks ourselves: during their execution. Variables written:
"started" (at the beginning of the task) and "exited" (just before
termination, after task is resumed and did its sleep). Also, verifies
"resumed" flag when got resumed, to check if resume request was
for it- by join task: this happens only if task is "started", "exited" and
not "joined". This can happen only after a complete subtask execution
task resets all flags and sets "joined" to 1Printf sequence seems to confirm that execution order is OK.
Quoted 9 lines
If you would like to understand a bit more already, you could
catch an
event trace (trace-cmd record -e "cobalt*" -e "sched*" -e
"signal*") and
study the task interaction (trace-cmd report / kernelshark).Quoted 12 lines
I'll do the setup to trace events (I don't have trace- cmd on
target, I
need to setup a qemu image with it).Thanks in advance, regards
Mauro
Quoted 2 lines
Jan
Hi Jan,
Quoted 9 lines
I made a sequential version of the test application:
instead of
having a
join task, join call was done by the main task, one subtask at time.
With this code, tasks does not access concurrently to variables.
Problem happens also with this code.Quoted 2 lines
Starting to look into this:
Great, thank you!
Quoted 25 lines
Quoted 12 lines
STARTED TASK Task0 (82a9eab0-829636c0)
TASK Task0 RUNNING (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
STARTED TASK Task1 (82a9e2b0-829526c0)
TASK Task1 RUNNING (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)
RESUMING TASK Task0 (82a9eab0-829636c0)
RESUMED TASK Task0 (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
RESUMING TASK Task1 (82a9e2b0-829526c0)
RESUMED TASK Task1 (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)Quoted 8 lines
TASK Task1 EXITED (self: 82a9e2b0-829526c0 ext:
82a9e2b0-829526c0)
TASK Task0 EXITED (self: 82a9eab0-829636c0 ext:
82a9eab0-829636c0)
JOINED TASK Task1 (82a9e2b0-829526c0)
STARTED TASK Task1 (82a9eab0-829526c0)
TASK Task1 RUNNING (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0)So far so good.
Quoted 1 line
RESUMING TASK Task0 (82a9eab0-829636c0)
Quoted 8 lines
And here you are resuming a task that is in waiting-to-be- joined state,
right? That is an application bug, but one may expect it to be either
ignored, only affect that Task0 negatively, or even throwing an error
back to the caller.Yes, exactly: task is ended yet, then should be joined and not resumed,
but I would expect that the resume command was ignored and/or an error
was returned.Quoted 5 lines
Quoted 4 lines
RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0)
ERROR: RESUMED TASK Task1 (self: 82a9eab0-829526c0 ext:
82a9eab0-829526c0) HAS NOT BEEN ASKED TO RESUMEQuoted 6 lines
Quoted 4 lines
Instead, we see that spurious wakeup of task1. Let me debug into
this...Thumbs up!
Ok, here is the catch: The task handle that was used for task0 is freed,
even before someone joined that task. And task1 handle was freed as well
before you call CreateAndStartFn(1) again. Now your task1 will get the
handle of previous task0, and when you try to use that stale handle for
resuming task0, alchemy looks up the new task1 instead - and resumes
that.I looked a bit into whether we could delay the handle deregistration
after the joining, but that would be a hairy operation, likely also
affecting libcopperplate. Given all that, I think we are safer off
living with this "specialty", rather than risking instability in the
cleanup path to handle the application error a bit nicer.Quoted 2 lines
Jan
Ok, got it.
IMO this behavior should be documented somewhere because it's not what a
user would expect.Quoted 9 lines
Just throwing out an idea (that could be completely wrong): to workaround the deregistration issue, should the resume function use both
the twoRT_TASKfields to decide if resume or not a task, resuming it
only if both the two IDs matching? From the log seems that the second
field (pthread ID?) stills occupied until the join happens.Quoted 7 lines
I played with that idea. It initially looked simple, then reveal a catch, but I think I was able to address that as well. Please have a
look at the patches I just shared.Jan
Hi Jan,
I've seen patches, thanks a lot!
Unfortunately I'm not able to test them on the final system, but a quick
test in a QEMU machine works properly (no doubts about it).As soon as I'll test on the final system, I'll be back with a feedback.
Quoted 9 lines
Quoted 2 lines
Thanks again, regards
Hi Jan,
sorry for the long delay.
I managed to try your patches on the final system and I confirm that they work.
Never mind, and thanks for confirming!
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center