Fwd: [developer] SUNWspro compiler bug

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [developer] SUNWspro compiler bug

Cedric Blancher
Forwarded conversation
Subject: [developer] SUNWspro compiler bug
------------------------

From: Matthew Ahrens <[hidden email]>
Date: 11 September 2012 06:35
To: [hidden email]


Is there a good place to report a SUNWspro compiler bug?

I've found that functions that use alloca() (or c99 variable-length
arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the
kernel is) restore callee-saved registers incorrectly.

Note that extant code works correctly because the kernel doesn't call
alloca(), and 64-bit userland is not compiled with save_args.

The incorrect assembly looks like:

func:                           pushq  %rbp
func+1:                         movq   %rsp,%rbp
# save arguments:
func+4:                         subq   $0x18,%rsp
func+8:                         movq   %rdi,-0x8(%rbp)
func+0xc:                       movq   %rsi,-0x10(%rbp)
func+0x10:                      movq   %rdx,-0x18(%rbp)
# callee-saved registers which this function needs:
func+0x14:                      pushq  %r12
func+0x16:                      pushq  %r13
func+0x18:                      pushq  %r14
func+0x1a:                      pushq  %r15
# alloca(1):
func+0x1c:                      subq   $0x8,%rsp
func+0x20:                      decq   %rsp
func+0x23:                      andq   $0xfffffffffffffff0,%rsp

... some computation that uses %r12, %r13, %r14, %r15

# incorrectly change %rsp to what it was before the alloca()
# should be -0x38 to include saved arguments
func+0x187:                     leaq   -0x20(%rbp),%rsp
# restore callee-saved registers:
func+0x18b:                     popq   %r15
func+0x18d:                     popq   %r14
func+0x18f:                     popq   %r13
func+0x191:                     popq   %r12
func+0x193:                     leave
func+0x194:                     ret

For an example, see the attached test program.

--matt
illumos-developer | Archives | Modify Your Subscription

----------
From: Richard Lowe <[hidden email]>
Date: 11 September 2012 06:40
To: Matthew Ahrens <[hidden email]>, illumos-dev
<[hidden email]>


On Tue, Sep 11, 2012 at 12:35 AM, Matthew Ahrens <[hidden email]> wrote:
>
> Is there a good place to report a SUNWspro compiler bug?
>
> I've found that functions that use alloca() (or c99 variable-length arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the kernel is) restore callee-saved registers incorrectly.


I hit this same issue when concocting the libproc changes I just sent
out for review.  I think you can file Studio bugs at bugs.sun.com
still, but it won't be any good for illumos, since it'll only be fixed
in a version of the compiler we can't really use.

-- Rich
illumos-developer | Archives | Modify Your Subscription



Ced
--
Cedric Blancher <[hidden email]>
Institute Pasteur

_______________________________________________
opensolaris-discuss mailing list
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [developer] SUNWspro compiler bug

Cindy Swearingen
Sure, we can pass this feedback along.

Thanks for reporting it.

Cindy

On 09/11/12 10:00, Cedric Blancher wrote:

> Forwarded conversation
> Subject: [developer] SUNWspro compiler bug
> ------------------------
>
> From: Matthew Ahrens<[hidden email]>
> Date: 11 September 2012 06:35
> To: [hidden email]
>
>
> Is there a good place to report a SUNWspro compiler bug?
>
> I've found that functions that use alloca() (or c99 variable-length
> arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the
> kernel is) restore callee-saved registers incorrectly.
>
> Note that extant code works correctly because the kernel doesn't call
> alloca(), and 64-bit userland is not compiled with save_args.
>
> The incorrect assembly looks like:
>
> func:                           pushq  %rbp
> func+1:                         movq   %rsp,%rbp
> # save arguments:
> func+4:                         subq   $0x18,%rsp
> func+8:                         movq   %rdi,-0x8(%rbp)
> func+0xc:                       movq   %rsi,-0x10(%rbp)
> func+0x10:                      movq   %rdx,-0x18(%rbp)
> # callee-saved registers which this function needs:
> func+0x14:                      pushq  %r12
> func+0x16:                      pushq  %r13
> func+0x18:                      pushq  %r14
> func+0x1a:                      pushq  %r15
> # alloca(1):
> func+0x1c:                      subq   $0x8,%rsp
> func+0x20:                      decq   %rsp
> func+0x23:                      andq   $0xfffffffffffffff0,%rsp
>
> ... some computation that uses %r12, %r13, %r14, %r15
>
> # incorrectly change %rsp to what it was before the alloca()
> # should be -0x38 to include saved arguments
> func+0x187:                     leaq   -0x20(%rbp),%rsp
> # restore callee-saved registers:
> func+0x18b:                     popq   %r15
> func+0x18d:                     popq   %r14
> func+0x18f:                     popq   %r13
> func+0x191:                     popq   %r12
> func+0x193:                     leave
> func+0x194:                     ret
>
> For an example, see the attached test program.
>
> --matt
> illumos-developer | Archives | Modify Your Subscription
>
> ----------
> From: Richard Lowe<[hidden email]>
> Date: 11 September 2012 06:40
> To: Matthew Ahrens<[hidden email]>, illumos-dev
> <[hidden email]>
>
>
> On Tue, Sep 11, 2012 at 12:35 AM, Matthew Ahrens<[hidden email]>  wrote:
>>
>> Is there a good place to report a SUNWspro compiler bug?
>>
>> I've found that functions that use alloca() (or c99 variable-length arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the kernel is) restore callee-saved registers incorrectly.
>
>
> I hit this same issue when concocting the libproc changes I just sent
> out for review.  I think you can file Studio bugs at bugs.sun.com
> still, but it won't be any good for illumos, since it'll only be fixed
> in a version of the compiler we can't really use.
>
> -- Rich
> illumos-developer | Archives | Modify Your Subscription
>
>
>
> Ced
> --
> Cedric Blancher<[hidden email]>
> Institute Pasteur
>
>
>
> _______________________________________________
> opensolaris-discuss mailing list
> [hidden email]
_______________________________________________
opensolaris-discuss mailing list
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [developer] SUNWspro compiler bug

Cedric Blancher
On 11 September 2012 18:58, Cindy Swearingen
<[hidden email]> wrote:
> Sure, we can pass this feedback along.
>
> Thanks for reporting it.

Cindy, please send the CR# number from bugster back to this list as
reference. Thank you.

Ced
--
Cedric Blancher <[hidden email]>
Institute Pasteur
_______________________________________________
opensolaris-discuss mailing list
[hidden email]