* [PATCH] qemu-thread: avoid false positive in pthread_cleanup_push
@ 2021-09-07 12:51 Paolo Bonzini
2021-09-07 14:20 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2021-09-07 12:51 UTC (permalink / raw)
To: qemu-devel; +Cc: richard.henderson
The following error occurs with GCC gcc (Debian 11-20210327-1) 11.0.1 20210327
on Debian Bullseye:
../util/qemu-thread-posix.c: In function ‘qemu_thread_start’:
../util/qemu-thread-posix.c:520:5: error: ‘__sigsetjmp’ accessing 200 bytes in a region of size 72 [-Werror=stringop-overflow=]
520 | pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
| ^~~~~~~~~~~~~~~~~~~~
../util/qemu-thread-posix.c:520:5: note: referencing argument 1 of type ‘struct __jmp_buf_tag *’
/usr/include/pthread.h:719:12: note: in a call to function ‘__sigsetjmp’
719 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
| ^~~~~~~~~~~
cc1: all warnings being treated as errors
Disable the warning just like it was done in glibc.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/400
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/qemu-thread-posix.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index fd9d714038..4cf47b3414 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -537,7 +537,16 @@ static void *qemu_thread_start(void *args)
QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name);
g_free(qemu_thread_args->name);
g_free(qemu_thread_args);
+
+ /*
+ * Work around GCC 11 false positives. Ideally glibc would use
+ * _Pragma itself, for now do it. See
+ * https://sourceware.org/bugzilla/show_bug.cgi?id=26647
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
+#pragma GCC diagnostic pop
r = start_routine(arg);
pthread_cleanup_pop(1);
return r;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] qemu-thread: avoid false positive in pthread_cleanup_push
2021-09-07 12:51 [PATCH] qemu-thread: avoid false positive in pthread_cleanup_push Paolo Bonzini
@ 2021-09-07 14:20 ` Richard Henderson
2021-09-08 5:58 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2021-09-07 14:20 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
On 9/7/21 2:51 PM, Paolo Bonzini wrote:
> The following error occurs with GCC gcc (Debian 11-20210327-1) 11.0.1 20210327
> on Debian Bullseye:
>
> ../util/qemu-thread-posix.c: In function ‘qemu_thread_start’:
> ../util/qemu-thread-posix.c:520:5: error: ‘__sigsetjmp’ accessing 200 bytes in a region of size 72 [-Werror=stringop-overflow=]
> 520 | pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
> | ^~~~~~~~~~~~~~~~~~~~
> ../util/qemu-thread-posix.c:520:5: note: referencing argument 1 of type ‘struct __jmp_buf_tag *’
> /usr/include/pthread.h:719:12: note: in a call to function ‘__sigsetjmp’
> 719 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
> | ^~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Disable the warning just like it was done in glibc.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/400
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> util/qemu-thread-posix.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index fd9d714038..4cf47b3414 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -537,7 +537,16 @@ static void *qemu_thread_start(void *args)
> QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name);
> g_free(qemu_thread_args->name);
> g_free(qemu_thread_args);
> +
> + /*
> + * Work around GCC 11 false positives. Ideally glibc would use
> + * _Pragma itself, for now do it. See
> + * https://sourceware.org/bugzilla/show_bug.cgi?id=26647
> + */
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstringop-overflow"
> pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
> +#pragma GCC diagnostic pop
I had a patch for this that didn't quite get applied for 6.1.
You can't leave the pragma unprotected for clang, unfortunately.
https://patchew.org/QEMU/20210803211907.150525-1-richard.henderson@linaro.org/
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] qemu-thread: avoid false positive in pthread_cleanup_push
2021-09-07 14:20 ` Richard Henderson
@ 2021-09-08 5:58 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-09-08 5:58 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 07/09/21 16:20, Richard Henderson wrote:
> On 9/7/21 2:51 PM, Paolo Bonzini wrote:
>> +#pragma GCC diagnostic push
>> +#pragma GCC diagnostic ignored "-Wstringop-overflow"
>> pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
>> +#pragma GCC diagnostic pop
>
> I had a patch for this that didn't quite get applied for 6.1.
> You can't leave the pragma unprotected for clang, unfortunately.
>
> https://patchew.org/QEMU/20210803211907.150525-1-richard.henderson@linaro.org/
Thanks! I queued your patch instead of mine.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-08 5:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 12:51 [PATCH] qemu-thread: avoid false positive in pthread_cleanup_push Paolo Bonzini
2021-09-07 14:20 ` Richard Henderson
2021-09-08 5:58 ` Paolo Bonzini
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.