bug-libunistring
[Top][All Lists]
Advanced

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

Re: [bug-libunistring] Failed test-localename 64-bit OS X 10.6.2


From: Bruno Haible
Subject: Re: [bug-libunistring] Failed test-localename 64-bit OS X 10.6.2
Date: Fri, 2 Apr 2010 19:20:08 +0100
User-agent: KMail/1.9.9

Hi,

Panu Kekäläinen wrote:
> System: Mac OS X 10.6.2 64-bit compilation
> 
> /bin/sh: line 1: 29407 Segmentation fault ...
> 
> trace:
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: 13 at address: 0x0000000000000000
> 0x0000000100005fc0 in libunistring_gl_locale_name_thread ()
> (gdb) thr apply all bt
> ...
> Thread 1 (process 29024):
> #0  0x0000000100005fc0 in libunistring_gl_locale_name_thread ()
> #1  0x000000010000657b in libunistring_gl_locale_name ()
> #2  0x0000000100002488 in test_locale_name [inlined] () at 
> /Volumes/Data/Users/panu/Downloads/libunistring-0.9.2.1/tests/test-localename.c:184
> #3  0x0000000100002488 in main () at test-localename.c:740

Thanks for the stack trace. Can you please try this patch and report to me 
whether
it works? I don't have access to a MacOS X 10.6 machine myself.

Bruno


2010-04-02  Bruno Haible  <address@hidden>

        localename: Port to MacOS X 10.6.
        * lib/localename.c (gl_locale_name_thread_unsafe): On MacOS X, try the
        memory layout of the locales in MacOS X 10.6 as well.
        Reported by Panu Kekäläinen <address@hidden>.

--- lib/localename.c.orig       Fri Apr  2 20:15:04 2010
+++ lib/localename.c    Fri Apr  2 20:14:59 2010
@@ -2625,12 +2625,24 @@
            locale names of length > 31, we can assume that it is NUL terminated
            in this buffer. But we need to make a copy of the locale name, of
            indefinite extent.  */
-        struct _xlocale
+        struct _xlocale_part1_v0 /* used in MacOS X 10.5 */
           {
             int32_t __refcount;
             void (*__free_extra)(void *);
             __darwin_mbstate_t __mbs[10];
             int64_t __magic;
+          };
+        struct _xlocale_part1_v1 /* used in MacOS X >= 10.6.0 */
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            __darwin_mbstate_t __mbs[10];
+            /*pthread_lock_t*/ int __lock;
+            int64_t __magic;
+          };
+        struct _xlocale_part2
+          {
+            int64_t __magic;
             unsigned char __collate_load_error;
             unsigned char __collate_substitute_nontrivial;
             unsigned char _messages_using_locale;
@@ -2689,7 +2701,23 @@
             char *_time_locale_buf;
             /* more */
           };
-        struct _xlocale *tlp = (struct _xlocale *) thread_locale;
+        struct _xlocale_part2 *tlp;
+        if (((struct _xlocale_part1_v0 *) thread_locale)->__magic
+            == 0x786C6F63616C6530LL)
+          /* MacOS X 10.5 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v0 *) thread_locale)->__magic;
+        else if (((struct _xlocale_part1_v1 *) thread_locale)->__magic
+                 == 0x786C6F63616C6530LL)
+          /* MacOS X >= 10.6.0 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v1 *) thread_locale)->__magic;
+        else
+          /* Unsupported version of MacOS X: The internals of 'struct _xlocale'
+             have changed again.  */
+          return "";
         switch (category)
           {
           case LC_CTYPE:




reply via email to

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