diff mbox

fix pthread_cancel lead to segmentation fault for x86_64.

Message ID 10612639.NDcb73UiM2@sencha
State Superseded
Headers show

Commit Message

Roman Khimov May 21, 2014, 8:23 a.m. UTC
В письме от 21 мая 2014 00:52:55 пользователь ZhangPu написал:
> --- a/libc/sysdeps/linux/x86_64/sigaction.c
> +++ b/libc/sysdeps/linux/x86_64/sigaction.c
> @@ -116,6 +116,7 @@ libc_hidden_weak(sigaction)
>  #define RESTORE(name, syscall) RESTORE2(name, syscall)
>  #define RESTORE2(name, syscall) \
>  __asm__ (						\
> +	"	nop\n"					\
>  	".text\n"					\
>  	"__" #name ":\n"				\
>  	"	movq	$" #syscall ", %rax\n"		\

I think it should be aligned, like:


At least that's what we've used internally for quite some time and it works 
good (yep, should've forwarded it here earlier). See also:
http://git.alpinelinux.org/cgit/aports/tree/main/libc0.9.32/0007-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch?h=v2.5.0

Comments

ZhangPu May 21, 2014, 1:20 p.m. UTC | #1
Hi Khimov:

     In glibc, it does align 16, and many other code also does,such as
sigpause and so on.
     but i think ,uClibc dose not 16 align maybe for size. and I tested
this code ,it work well.  so i remove the "align 16" asm code.

thanks!


2014-05-21 16:23 GMT+08:00 Roman Khimov <khimov@altell.ru>:

> В письме от 21 мая 2014 00:52:55 пользователь ZhangPu написал:
> > --- a/libc/sysdeps/linux/x86_64/sigaction.c
> > +++ b/libc/sysdeps/linux/x86_64/sigaction.c
> > @@ -116,6 +116,7 @@ libc_hidden_weak(sigaction)
> >  #define RESTORE(name, syscall) RESTORE2(name, syscall)
> >  #define RESTORE2(name, syscall) \
> >  __asm__ (                                            \
> > +     "       nop\n"                                  \
> >       ".text\n"                                       \
> >       "__" #name ":\n"                                \
> >       "       movq    $" #syscall ", %rax\n"          \
>
> I think it should be aligned, like:
>
> --- a/libc/sysdeps/linux/x86_64/sigaction.c
> +++ b/libc/sysdeps/linux/x86_64/sigaction.c
> @@ -117,6 +117,8 @@ libc_hidden_weak(sigaction)
>  #define RESTORE2(name, syscall) \
>  __asm__ (                                              \
>         ".text\n"                                       \
> +       "nop\n" \
> +       ".align 16\n" \
>         "__" #name ":\n"                                \
>         "       movq    $" #syscall ", %rax\n"          \
>         "       syscall\n"                              \
>
> At least that's what we've used internally for quite some time and it works
> good (yep, should've forwarded it here earlier). See also:
>
> http://git.alpinelinux.org/cgit/aports/tree/main/libc0.9.32/0007-libc-x86-fix-stack-unwinding-and-backtrace-informati.patch?h=v2.5.0
>
diff mbox

Patch

--- a/libc/sysdeps/linux/x86_64/sigaction.c
+++ b/libc/sysdeps/linux/x86_64/sigaction.c
@@ -117,6 +117,8 @@  libc_hidden_weak(sigaction)
 #define RESTORE2(name, syscall) \
 __asm__ (                                              \
        ".text\n"                                       \
+       "nop\n" \
+       ".align 16\n" \
        "__" #name ":\n"                                \
        "       movq    $" #syscall ", %rax\n"          \
        "       syscall\n"                              \