All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Fix rt_task_shadow error path without __thread.
Date: Thu, 02 Apr 2009 18:52:30 +0200	[thread overview]
Message-ID: <49D4ED4E.40707@domain.hid> (raw)
In-Reply-To: <49D481EF.1010908@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 1752 bytes --]

Gilles Chanteperdrix wrote:
> Hi,
> 
> it seems that rt_task_shadow currently leaves the self tsd assigned (and
> uninitialized) in case of error. So, here is an attempt to fix this
> situation:

Good point.

> 
> Index: src/skins/native/task.c
> ===================================================================
> --- src/skins/native/task.c     (revision 4727)
> +++ src/skins/native/task.c     (working copy)
> @@ -187,15 +187,8 @@
> 
>  #ifdef HAVE___THREAD
>         self = &__native_self;
> -#else /* !HAVE___THREAD */
> -       self = pthread_getspecific(__native_tskey);
> +#endif /* HAVE___THREAD */
> 
> -       if (!self)
> -               self = malloc(sizeof(*self));
> -
> -       pthread_setspecific(__native_tskey, self);
> -#endif /* !HAVE___THREAD */
> -
>         if (task == NULL)
>                 task = &task_desc; /* Discarded. */
> 
> @@ -217,9 +210,13 @@
>                                 NULL);
> 
>         if (!err) {
> -               if (self)
> -                       *self = *task;
> +#ifndef HAVE___THREAD
> +               self = malloc(sizeof(*self));

Hmm, this creates a potential relaxation point (and may raise SIGXCPU if
the warn flag is set). I would prefer to keep early allocation and
release the chunk properly on error (as well as reset the tsd).

> 
> +               pthread_setspecific(__native_tskey, self);
> +#endif /* !HAVE___THREAD */
> +               *self = *task;

And if self is NULL, ie. malloc failed for whatever obscure reasons? The
existing code skipped over this, maybe we should actually handle it and
return an error code.

> +
>                 xeno_set_current();
> 
>                 if (mode & T_WARNSW)
> 
> 

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2009-04-02 16:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-02  9:14 [Xenomai-core] Fix rt_task_shadow error path without __thread Gilles Chanteperdrix
2009-04-02 16:52 ` Jan Kiszka [this message]
2009-04-03 14:22   ` Gilles Chanteperdrix
2009-04-03 16:34     ` Jan Kiszka

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=49D4ED4E.40707@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.