public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] work around gcc4 issue with -Os in Dwarf2 stack unwind code
Date: Tue, 28 Nov 2006 09:32:14 -0500	[thread overview]
Message-ID: <20061128143214.GD6570@devserv.devel.redhat.com> (raw)
In-Reply-To: <456C51D8.76E4.0078.0@novell.com>

On Tue, Nov 28, 2006 at 02:12:24PM +0000, Jan Beulich wrote:
> This fixes a problem with gcc4 mis-compiling the stack unwind code under
> -Os, which resulted in 'stuck' messages whenever an assembly routine was
> encountered.

"mis-compiling" and "work around" are wrong words, the code had undefined
behavior (there is no sequence point between evaluation of ptr and
get_uleb128(&ptr, end) and ptr is modified twice, so the compiler can
evaluate it e.g. as:
temp = ptr;
temp = temp + get_uleb128(&ptr, end);
ptr = temp;
or
temp = get_uleb128(&ptr, end);
ptr += temp;
While gcc has some warnings for sequence point semantics violations
(-Wsequence-point), this can't be one of the cases at least until IPA moves
much further, because get_uleb128 might very well not modify the variable
and at that point the code would be ok).

> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> 
> --- linux-2.6.19-rc6/kernel/unwind.c	2006-11-22 14:54:10.000000000 +0100
> +++ 2.6.19-rc6-unwind-stuck/kernel/unwind.c	2006-11-28 15:02:15.000000000 +0100
> @@ -938,8 +938,11 @@ int unwind(struct unwind_frame_info *fra
>  		else {
>  			retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end);
>  			/* skip augmentation */
> -			if (((const char *)(cie + 2))[1] == 'z')
> -				ptr += get_uleb128(&ptr, end);
> +			if (((const char *)(cie + 2))[1] == 'z') {
> +				uleb128_t augSize = get_uleb128(&ptr, end);
> +
> +				ptr += augSize;
> +			}
>  			if (ptr > end
>  			   || retAddrReg >= ARRAY_SIZE(reg_info)
>  			   || REG_INVALID(retAddrReg)

	Jakub

  reply	other threads:[~2006-11-28 14:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-28 14:12 [PATCH] work around gcc4 issue with -Os in Dwarf2 stack unwind code Jan Beulich
2006-11-28 14:32 ` Jakub Jelinek [this message]
2006-11-28 14:48   ` Jan Beulich
2006-11-28 14:59     ` Jakub Jelinek
2006-11-28 16:23 ` Andi Kleen

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=20061128143214.GD6570@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=ak@suse.de \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox