All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: Romain Naour <romain.naour@gmail.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] package/xenomai: fix build with glibc >= 2.34
Date: Sat, 18 Dec 2021 22:17:26 +0100	[thread overview]
Message-ID: <20211218211726.GO2603@scaer> (raw)
In-Reply-To: <20211218095655.521317-1-fontaine.fabrice@gmail.com>

Fabrice, All,

On 2021-12-18 10:56 +0100, Fabrice Fontaine spake thusly:
> Fix the following build failure with glibc >= 2.34:
> 
> In file included from timerobj.c:32:
> In function 'threadobj_set_current',
>     inlined from 'server_prologue' at timerobj.c:94:2:
> ../../include/copperplate/threadobj.h:252:9: error: 'pthread_setspecific' expecting 1 byte in a region of size 0 [-Werror=stringop-overread]
>   252 |         pthread_setspecific(threadobj_tskey, thobj);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/ed93f916eda304b30f320816c85d1b0d4488c699
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  ...id-addresses-for-pthread_setspecific.patch | 57 +++++++++++++++++++
>  1 file changed, 57 insertions(+)
>  create mode 100644 package/xenomai/3.0.10/0003-lib-cobalt-copperplate-Use-valid-addresses-for-pthread_setspecific.patch
> 
> diff --git a/package/xenomai/3.0.10/0003-lib-cobalt-copperplate-Use-valid-addresses-for-pthread_setspecific.patch b/package/xenomai/3.0.10/0003-lib-cobalt-copperplate-Use-valid-addresses-for-pthread_setspecific.patch
> new file mode 100644
> index 0000000000..0c39a4ecf7
> --- /dev/null
> +++ b/package/xenomai/3.0.10/0003-lib-cobalt-copperplate-Use-valid-addresses-for-pthread_setspecific.patch
> @@ -0,0 +1,57 @@
> +From 627d488db3aa71406e32d4d8934629e8b0f35905 Mon Sep 17 00:00:00 2001
> +From: Jan Kiszka <jan.kiszka@siemens.com>
> +Date: Sat, 16 Oct 2021 15:46:33 +0200
> +Subject: [PATCH] lib/{cobalt,copperplate}: Use valid addresses for
> + pthread_setspecific
> +
> +glibx 2.34 and newer annotated pthread_setspecific in a way that gcc-11
> +complains about non-NULL pointers that are outside of what is considered
> +valid. So use dummy addresses instead. namely the related pthread keys.
> +Those pointers will never be dereferenced in both use cases.
> +
> +See also https://sourceware.org/bugzilla/show_bug.cgi?id=28458.
> +
> +Reported-by: Vitaly Chikunov <vt@altlinux.org>
> +Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> +
> +[Retrieved from:
> +https://source.denx.de/Xenomai/xenomai/-/commit/627d488db3aa71406e32d4d8934629e8b0f35905]
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +---
> + include/copperplate/threadobj.h | 6 +++++-
> + lib/cobalt/printf.c             | 2 +-
> + 2 files changed, 6 insertions(+), 2 deletions(-)
> +
> +diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
> +index 7e6904f4c..c8363415b 100644
> +--- a/include/copperplate/threadobj.h
> ++++ b/include/copperplate/threadobj.h
> +@@ -173,7 +173,11 @@ void threadobj_save_timeout(struct threadobj_corespec *corespec,
> + #define __THREAD_M_SPARE6	(1 << 22)
> + #define __THREAD_M_SPARE7	(1 << 23)
> + 
> +-#define THREADOBJ_IRQCONTEXT    ((struct threadobj *)-2UL)
> ++/*
> ++ * We need to use a valid address here. The object will never be dereferenced
> ++ * when it is identified as IRQ context, so the pthread key itself is fine.
> ++ */
> ++#define THREADOBJ_IRQCONTEXT	((struct threadobj *)&threadobj_tskey)
> + 
> + struct traceobj;
> + struct syncobj;
> +diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
> +index 8982ddc93..0aa5940c6 100644
> +--- a/lib/cobalt/printf.c
> ++++ b/lib/cobalt/printf.c
> +@@ -729,7 +729,7 @@ done:
> + 	pthread_cond_init(&printer_wakeup, NULL);
> + 	spawn_printer_thread();
> + 	/* We just need a non-zero TSD to trigger the dtor upon unwinding. */
> +-	pthread_setspecific(cleanup_key, (void *)1);
> ++	pthread_setspecific(cleanup_key, &cleanup_key);
> + 
> + 	atexit(rt_print_flush_buffers);
> + }
> +-- 
> +GitLab
> +
> -- 
> 2.33.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2021-12-18 21:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18  9:56 [Buildroot] [PATCH 1/1] package/xenomai: fix build with glibc >= 2.34 Fabrice Fontaine
2021-12-18 21:17 ` Yann E. MORIN [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=20211218211726.GO2603@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=fontaine.fabrice@gmail.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.de_schampheleire@nokia.com \
    /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.