xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Florian Bezdeka <florian.bezdeka@siemens.com>, xenomai@lists.linux.dev
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Subject: Re: [PATCH] lib/psos/task.c: Fix psos tests, incorrect error reporting
Date: Tue, 12 Dec 2023 14:15:02 +0100	[thread overview]
Message-ID: <f990cf59-5dec-43f6-90c3-447fdb12ddac@siemens.com> (raw)
In-Reply-To: <a8d23bf707291c5d8ef2534baf8c22b535f16159.camel@siemens.com>

On 12.12.23 13:13, Florian Bezdeka wrote:
> On Tue, 2023-12-12 at 11:47 +0100, Jan Kiszka wrote:
>> On 12.12.23 11:01, Florian Bezdeka wrote:
>>> The following smokey test failure was seen on the current next branch:
>>>
>>>  [1] at task-4.c:22
>>>     0\"011.394| BUG in __traceobj_assert_failed(): [TASK] trace assertion failed:
>>>                task-4.c:36 => \"ret == 0 && regval == 0xdeadbeef\"
>>>  test psostests_task4 failed: 256
>>>
>>> The problem was introduced in
>>> 8dceca122dbb ("lib/psos/task.c: fix build with gcc >= 12 and -Ofast"),
>>> the second parameter of get_psos_task() was unconditionally initialized
>>> with ERR_OBJDEL. Even if no error occurred later on, an error was
>>> reported.
>>>
>>> All users of get_psos_task() and get_psos_task_or_self() have to
>>> initialize the second parameter when the care about the returned error
>>> code afterwards. The value of the parameter will only be overwritten in
>>> case of an error.
>>>
>>> Fixes: 8dceca122dbb ("lib/psos/task.c: fix build with gcc >= 12 and -Ofast")
>>> CC: Fabrice Fontaine <fontaine.fabrice@gmail.com>
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>>  lib/psos/task.c | 9 ++++-----
>>>  lib/psos/tm.c   | 2 +-
>>>  2 files changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/lib/psos/task.c b/lib/psos/task.c
>>> index 5341289df..70b5c6596 100644
>>> --- a/lib/psos/task.c
>>> +++ b/lib/psos/task.c
>>> @@ -96,7 +96,6 @@ static struct psos_task *find_psos_task_or_self(u_long tid, int *err_r)
>>>  
>>>  struct psos_task *get_psos_task(u_long tid, int *err_r)
>>>  {
>>> -	*err_r = ERR_OBJDEL;
>>
>> This re-introduces the bug that the previous commit was (also) trying to
>> fix: We do not set *err_t when
>>
>> task == NULL || threadobj_lock(&task->thobj) == -EINVAL
> 
> Nope, I don't think so. The caller already does the initialization
> (now). *err_t is only over-written in case an error occurred. That is
> where the "might be uninitialized" error came from.
> 
> We have to look at get_psos_task() and get_psos_task_or_self()
> together. I think it's wrong to do the initialization inside
> get_psos_task().

I don't see why get_psos_task() should set *err_r when
threadobj_get_magic fails but not when that condition above.

Jan

-- 
Siemens AG, Technology
Linux Expert Center


      reply	other threads:[~2023-12-12 13:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 10:01 [PATCH] lib/psos/task.c: Fix psos tests, incorrect error reporting Florian Bezdeka
2023-12-12 10:47 ` Jan Kiszka
2023-12-12 12:13   ` Florian Bezdeka
2023-12-12 13:15     ` Jan Kiszka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f990cf59-5dec-43f6-90c3-447fdb12ddac@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=florian.bezdeka@siemens.com \
    --cc=fontaine.fabrice@gmail.com \
    --cc=xenomai@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).