All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-trivial] [PATCH] cpu-exec: Fix compiler warning (-Werror=clobbered)
Date: Tue, 17 Sep 2013 19:27:05 +0200	[thread overview]
Message-ID: <523890E9.5030000@weilnetz.de> (raw)
In-Reply-To: <52388EC1.6030108@web.de>

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

Am 17.09.2013 19:17, schrieb Jan Kiszka:
> On 2013-09-17 19:03, Stefan Weil wrote:
>> 'cpu' and 'env' are not modified after sigsetjmp. Therefore they will
>> still have their last value after longjmp restored the stack context.
>>
>> The code which should "reload" both variables causes a compiler warning:
>>
>> cpu-exec.c:204:15: error:
>> variable ‘cpu’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Werror=clobbered]
>> cpu-exec.c:202:28: error:
>> argument ‘env’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Werror=clobbered]
>>
>> Remove this unneeded code.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> Jan,
>>
>> could you please review this patch which removes code added by you
earlier?
>> I have run tests with the old code and assertions to see whether the
values
>> were really smashed. They never were, and from the documentation of
setjmp
>> I'd not expect that they ever might be.
>>
>> The patch is needed to fix a compiler warning with -Wextra.
>
> This used to fix a real, deadly crash. Therefore a reversion can't be
> trivial by definition. Unfortunately, I don't recall which compiler
> version and concrete scenario were involved back then.
>
> Anyway - did anything change in the code structure around since then?
> Does anything ensure that this "optimization" is not longer performed by
> the compiler?
>
> I'll try to understand the warnings meanwhile.
>
> Jan
>

The code changed a lot since that time, e.g. setjmp was replaced by
sigsetjmp.

Maybe you had a broken compiler which could be forced to do the right thing
by that code?

Stefan



[-- Attachment #2: Type: text/html, Size: 2671 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] [PATCH] cpu-exec: Fix compiler warning (-Werror=clobbered)
Date: Tue, 17 Sep 2013 19:27:05 +0200	[thread overview]
Message-ID: <523890E9.5030000@weilnetz.de> (raw)
In-Reply-To: <52388EC1.6030108@web.de>

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

Am 17.09.2013 19:17, schrieb Jan Kiszka:
> On 2013-09-17 19:03, Stefan Weil wrote:
>> 'cpu' and 'env' are not modified after sigsetjmp. Therefore they will
>> still have their last value after longjmp restored the stack context.
>>
>> The code which should "reload" both variables causes a compiler warning:
>>
>> cpu-exec.c:204:15: error:
>> variable ‘cpu’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Werror=clobbered]
>> cpu-exec.c:202:28: error:
>> argument ‘env’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Werror=clobbered]
>>
>> Remove this unneeded code.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> Jan,
>>
>> could you please review this patch which removes code added by you
earlier?
>> I have run tests with the old code and assertions to see whether the
values
>> were really smashed. They never were, and from the documentation of
setjmp
>> I'd not expect that they ever might be.
>>
>> The patch is needed to fix a compiler warning with -Wextra.
>
> This used to fix a real, deadly crash. Therefore a reversion can't be
> trivial by definition. Unfortunately, I don't recall which compiler
> version and concrete scenario were involved back then.
>
> Anyway - did anything change in the code structure around since then?
> Does anything ensure that this "optimization" is not longer performed by
> the compiler?
>
> I'll try to understand the warnings meanwhile.
>
> Jan
>

The code changed a lot since that time, e.g. setjmp was replaced by
sigsetjmp.

Maybe you had a broken compiler which could be forced to do the right thing
by that code?

Stefan



[-- Attachment #2: Type: text/html, Size: 2671 bytes --]

  reply	other threads:[~2013-09-17 17:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 17:03 [Qemu-trivial] [PATCH] cpu-exec: Fix compiler warning (-Werror=clobbered) Stefan Weil
2013-09-17 17:03 ` [Qemu-devel] " Stefan Weil
2013-09-17 17:17 ` [Qemu-trivial] " Jan Kiszka
2013-09-17 17:17   ` [Qemu-devel] " Jan Kiszka
2013-09-17 17:27   ` Stefan Weil [this message]
2013-09-17 17:27     ` Stefan Weil
2013-09-17 21:24 ` [Qemu-trivial] " Peter Maydell
2013-09-17 21:24   ` Peter Maydell
2013-09-18  7:06   ` Jan Kiszka
2013-09-18  7:26     ` Peter Maydell
2013-09-18  7:48       ` Jan Kiszka
2013-10-28 19:18         ` Stefan Weil
2013-10-29  8:07           ` 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=523890E9.5030000@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=anthony@codemonkey.ws \
    --cc=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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.