[Bug 260364] Toolchain writes the shared library that SEGVs on load: Invalid permissions for mapped object.

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 12 Dec 2021 16:39:59 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260364

            Bug ID: 260364
           Summary: Toolchain writes the shared library that SEGVs on
                    load: Invalid permissions for mapped object.
           Product: Base System
           Version: 13.0-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: yuri@freebsd.org

How to reproduce:
1. cd /usr/ports/audio/calf-lv2
2. pkg install -A 1 `make missing`
3. make  # expected to fail, but the library in question
work/stage/usr/local/lib/calf/libcalf.so is built
4. The following program SEGVs:

> #include <dlfcn.h>
> 
> int main() {
>         dlopen("work/stage/usr/local/lib/calf/libcalf.so", RTLD_NOW);
> }

The debugger says:
> Program received signal SIGSEGV, Segmentation fault.
> Invalid permissions for mapped object.
> 0x00000008007ea5d8 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1
> (gdb) bt
> #0  0x00000008007ea5d8 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1
> #1  0x0000000801d759ea in __dynamic_cast () from /usr/local/lib/gcc10/libstdc++.so.6
> #2  0x0000000801dfbd36 in bool std::has_facet<std::ctype<char> >(std::locale const&) () from /usr/local/lib/gcc10/libstdc++.so.6
> #3  0x0000000801dedac5 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) () from /usr/local/lib/gcc10/libstdc++.so.6
> #4  0x0000000801dedf71 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) () from /usr/local/lib/gcc10/libstdc++.so.6
> #5  0x0000000801d8a07b in std::ios_base::Init::Init() () from /usr/local/lib/gcc10/libstdc++.so.6
> #6  0x000000080110c010 in ?? () from work/stage/usr/local/lib/calf/libcalf.so
> #7  0x000000080020dcdd in objlist_call_init (list=<optimized out>, list@entry=0x7fffffffe270, lockstate=<optimized out>, lockstate@entry=0x7fffffffe1f0)
>     at /disk-samsung/freebsd-src/libexec/rtld-elf/rtld.c:3030
> #8  0x0000000800212396 in dlopen_object (name=name@entry=0x2005c0 "work/stage/usr/local/lib/calf/libcalf.so", fd=<optimized out>, fd@entry=-1, refobj=<optimized out>,
>     lo_flags=<optimized out>, mode=<optimized out>, mode@entry=2, lockstate=0x7fffffffe1f0, lockstate@entry=0x0) at /disk-samsung/freebsd-src/libexec/rtld-elf/rtld.c:3778
> #9  0x000000080020eebd in rtld_dlopen (name=0x2005c0 "work/stage/usr/local/lib/calf/libcalf.so", fd=-1, mode=<optimized out>) at /disk-samsung/freebsd-src/libexec/rtld-elf/rtld.c:3638
> #10 0x0000000000201984 in main ()

gcc is involved. But the built shared object shouldn't be broken.

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