Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Feb 2019 22:17:34 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 235751] Failure to init TLS variables with func ptr inside shared lib
Message-ID:  <bug-235751-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235751

            Bug ID: 235751
           Summary: Failure to init TLS variables with func ptr inside
                    shared lib
           Product: Base System
           Version: 12.0-RELEASE
          Hardware: powerpc
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: dclarke@blastwave.org

This is the exact same problem as described in Bug 161344.
Re-discovered this because libmpfr 4.0.2 fails most of its
tests unless one disables thread local storage.=20

hydra$ uname -a=20
FreeBSD hydra 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  powerpc

hydra$ echo $CC
/usr/local/bin/gcc8

hydra$ echo $CFLAGS=20
-g -m64 -std=3Dc99 -fno-builtin -O0 -mcpu=3D970 -mcall-freebsd -mno-altivec
-mno-float128 -mno-float128-hardware -mfull-toc -mregnames
-fno-unsafe-math-optimizations

hydra$ cat -n t1.c
     1
     2  int f(int x) {
     3    return x;
     4  }
     5  struct s_t {
     6    int (*func)(int);
     7  };
     8  struct s_t __thread x =3D { f };
     9
    10
hydra$=20

hydra$ cat -n t2.c
     1
     2
     3  struct s_t {
     4    int (*func)(int);
     5  };
     6  extern struct s_t __thread x;
     7  int main(int argc, const char *argv[]) {
     8    return (*x.func)(argc);
     9  }
    10
hydra$=20

hydra$ $CC $CFLAGS -shared -o t1.so -fPIC t1.c
hydra$ $CC $CFLAGS -o foo t2.c t1.so
hydra$ LD_LIBRARY_PATH=3D. ./foo
Segmentation fault (core dumped)
hydra$

hydra$ gdb foo foo.core
GNU gdb (GDB) 8.2.1 [GDB v8.2.1 for FreeBSD]
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htm=
l>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from foo...done.
[New LWP 100253]
Core was generated by `./foo'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000010000a1c in main (argc=3D1, argv=3D0x3fffffffffffd7f0) at t2.=
c:8
8         return (*x.func)(argc);
(gdb) where
#0  0x0000000010000a1c in main (argc=3D1, argv=3D0x3fffffffffffd7f0) at t2.=
c:8
(gdb) list
3       struct s_t {
4         int (*func)(int);
5       };
6       extern struct s_t __thread x;
7       int main(int argc, const char *argv[]) {
8         return (*x.func)(argc);
9       }
10
(gdb) quit


However the problem goes away entirely with r344130.

Also tested the situation with mpfr 4.0.2 and TLS seems to work with r34413=
0.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-235751-227>