NetBSD-Bugs archive

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

Re: toolchain/56153: gdb is broken for alpha



The following reply was made to PR toolchain/56153; it has been noted by GNATS.

From: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
To: Christos Zoulas <christos%zoulas.com@localhost>, gnats-bugs%netbsd.org@localhost
Cc: toolchain-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost
Subject: Re: toolchain/56153: gdb is broken for alpha
Date: Sat, 8 May 2021 18:00:29 +0900

 On 2021/05/07 23:51, Christos Zoulas wrote:
 > Which means (in theory :-) that the malloca.c allocates with alloca(3) and frees with regular
 > free which gives jemalloc a heartache. The next step is to instrument them malloca.h and malloca.c
 > calls with printfs to see what's happening...
 
 printf debug shows that malloca() macro is miscompiled:
 
 external/gpl3/gdb/dist/gnulib/import/malloca.h
 
 |   57  #if HAVE_ALLOCA
 |   58  # define malloca(N) \
 |   59    ((N) < 4032 - (2 * sa_alignment_max - 1)                                   \
 |   60     ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
 |   61                  + (2 * sa_alignment_max - 1))                                \
 |   62                 & ~(uintptr_t)(2 * sa_alignment_max - 1))                     \
 |   63     : mmalloca (N))
 |   64  #else
 |   65  # define malloca(N) \
 |   66    mmalloca (N)
 |   67  #endif
 
 freea() determines by sa_alignment_max (= 8) bit whether the buffer is
 allocated by alloca() or mmalloca(). But, both GCC 10 and 9 miscompile
 malloca() macro, which results in sa_alignment_max is not masked out.
 
 Compiling canonicalize-lgpl.c:__realpath() (only user of malloca() macro)
 with -O0 works around the problem:
 
 ----
 Index: external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c
 ===================================================================
 RCS file: /home/netbsd/src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c,v
 retrieving revision 1.1.1.1
 diff -p -u -r1.1.1.1 canonicalize-lgpl.c
 --- external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c	15 Sep 2020 01:43:50 -0000	1.1.1.1
 +++ external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c	8 May 2021 08:07:54 -0000
 @@ -114,6 +114,13 @@ alloc_failed (void)
      holds the same value as the value returned.  */
   
   char *
 +#ifdef __alpha__
 +/*
 + * toolchain/56153
 + * GCC 10 and 9 miscompile malloca() macro for alpha.
 + */
 +__attribute__((optimize("O0")))
 +#endif
   __realpath (const char *name, char *resolved)
   {
     char *rpath, *dest, *extra_buf = NULL;
 ----
 
 However, still, it is a sad surprise for me that GCC cannot compile
 such a simple mask operation...
 
 Thanks,
 rin
 


Home | Main Index | Thread Index | Old Index