bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix __ctype_b_loc aliasing violation


From: Thomas Schwinge
Subject: Re: [PATCH] Fix __ctype_b_loc aliasing violation
Date: Tue, 18 Nov 2008 17:53:50 +0100
User-agent: Mutt/1.5.11

Hello!

On Fri, Nov 07, 2008 at 01:12:57PM +0100, Jakub Jelinek wrote:
> Yeah, indeed.  I can reproduce it, a lot of stuff segfaults in glibc
> compiled with current GCC trunk on x86_64-linux, starting with localedef.

Same with a cross-compiled i586-pc-gnu toolchain.

> Here is a fix, tested with gcc 4.4.  Guess it would be good if somebody
> tested it on Hurd as well.

Done, see below.  Thanks for the pointer!


> 2008-11-07  Jakub Jelinek  <jakub@redhat.com>
> 
>       * bits/libc-tsd.h (__libc_tsd_define, __libc_tsd_address,
>       __libc_tsd_get, __libc_tsd_set): Add TYPE argument, use it as the type
>       of the thread variable instead of void *.
>       * sysdeps/mach/hurd/bits/libc-tsd.h (__libc_tsd_define,
>       __libc_tsd_address, __libc_tsd_get, __libc_tsd_set): Likewise.

Doesn't hurt, but FYI: this file, `sysdeps/mach/hurd/bits/libc-tsd.h',
won't exist anymore as soon as our TLS patches (by Samuel Thibault) have
been applied.

>       * include/ctype.h (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust
>       __libc_tsd_define arguments.
>       (__ctype_b_loc, __ctype_toupper_loc, __ctype_tolower_loc): Adjust
>       __libc_tsd_address arguments.  Remove union hack.
>       * include/rpc/rpc.h (RPC_VARS): Adjust __libc_tsd_define arguments.
>       * sunrpc/rpc_thread.c (RPC_VARS): Likewise.
>       (__rpc_thread_destroy, rpc_thread_multi, __rpc_thread_variables):
>       Adjust __libc_tsd_{set,get} arguments.
>       * ctype/ctype-info.c (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust
>       __libc_tsd_define arguments.
>       * locale/uselocale.c (__uselocale): Adjust __libc_tsd_{set,get}
>       arguments.
>       * locale/lc-ctype.c (_nl_postload_ctype): Likewise.
>       * locale/global-locale.c (__libc_tsd_LOCALE): Adjust type.
>       (LOCALE): Adjust __libc_tsd_define arguments.
>       * locale/localeinfo.h (_NL_CURRENT_LOCALE): Adjust __libc_tsd_get
>       arguments.
>       (LOCALE): Adjust __libc_tsd_define arguments.
>       * sysdeps/mach/hurd/malloc-machine.h (MALLOC): Adjust __libc_tsd_define
>       arguments.
>       (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get}
>       arguments.
> nptl/ 
>       * sysdeps/pthread/malloc-machine.h (MALLOC): Adjust __libc_tsd_define
>       arguments.
>       (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get}
>       arguments.


> --- libc/ctype/ctype-info.c.jj        2002-09-05 23:21:48.000000000 +0200
> +++ libc/ctype/ctype-info.c   2008-11-07 11:36:34.000000000 +0100
> @@ -20,9 +21,9 @@
>  #include <ctype.h>
>  #include <locale/localeinfo.h>
>  
> -__libc_tsd_define (, CTYPE_B)
> -__libc_tsd_define (, CTYPE_TOLOWER)
> -__libc_tsd_define (, CTYPE_TOUPPER)
> +__libc_tsd_define (const uint16_t *, CTYPE_B)
> +__libc_tsd_define (const int32_t *, CTYPE_TOLOWER)
> +__libc_tsd_define (const int32_t *, CTYPE_TOUPPER)

This need be ``__libc_tsd_define (, const uint16_t *, CTYPE_B)'' etc.
(mind the extra comma).


For posterity, here is one example of how it has been failing before
applying Jakub's patch:

    tschwinge@clubber:~/tmp $ gdb ./ext2fs.static
    [...]
    (gdb) r
    Starting program: /devel4/tschwinge/tmp/ext2fs.static 
    
    Program received signal SIGSEGV, Segmentation fault.
    convert_options (argp=<value optimized out>, parent=<value optimized out>, 
parent_index=<value optimized out>, group=0x81722e8, cvt=0x101fae0)
        at argp.h:579
    579     argp.h: No such file or directory.
            in argp.h
    (gdb) bt
    #0  convert_options (argp=<value optimized out>, parent=<value optimized 
out>, parent_index=<value optimized out>, group=0x81722e8, 
        cvt=0x101fae0) at argp.h:579
    #1  0x080b4a25 in convert_options (argp=<value optimized out>, 
parent=<value optimized out>, parent_index=<value optimized out>, 
        group=0x81722e8, cvt=0x101fae0) at argp-parse.c:407
    #2  0x080b4be5 in __argp_parse (argp=0x101f990, argc=1, argv=0x101fc24, 
flags=<value optimized out>, end_index=0x0, input=0x101fb4c)
        at argp-parse.c:435
    #3  0x08056d7d in diskfs_init_main (startup_argp=0x44, argc=1, 
argv=0x101fc24, store_parsed=0x8154284, bootstrap=0x101fb9c)
        at ../../hurd.work/libdiskfs/init-main.c:37
    #4  0x0804bd8b in main (argc=1, argv=0x101fc24) at 
../../hurd.work/ext2fs/ext2fs.c:172


Regards,
 Thomas

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]