This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pow() fails with a segmentation fault when executed fromdynamically allocated memory


>
> In the future please provide a *complete* test case or someone (not
> me, because I'm always nice) will be upset with you :-)
>
> Given your use of r11 I *assume* you are using x86-64 ABI.
>
> Your assembly violates the x86_64 procedure calling ABI by not saving
> %rbp and that leaves %rsp misaligned.
>
> You must push %rbp to keep the stack 16-byte aligned, otherwise pow's
> use of movapd uses an unaligned stack and that causes a general
> protection fault. You might have gotten lucky in the past, but your
> assembly is incorrect.
>
> I suggest the following:
> ~~~
> push %rbp
> mov %rsp, %rbp
> ...
> leaveq
> retq
> ~~~
>
> Cheers,
> Carlos.

First off, thanks for the heads up on the complete sample, and my
apologies to those offended.

I've implemented a fix corresponding to your suggestion, and it seems
to have done the trick. Apparently I haven't read the Stack Frame
section in the x86-64 ABI properly, but I was thrown off by the
seemingly working parameter passing. I'll read through it thoroughly
tonight to make sure I don't make the same mistake again.

Thanks for all the help. It is greatly appreciated.

Kind regards
Lars Vidar Magnusson


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]