https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69284

            Bug ID: 69284
           Summary: [5.3] SIGSEGV when running 32-bit result on MinGW when
                    linked dynamically
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.f.starke at freenet dot de
  Target Milestone: ---

Using GCC 5.3 compiled as
../../src/gcc-5.3.0/configure --enable-languages=c,c++ --enable-seh-exceptions
--enable-threads=posix --disable-nls --enable-shared=libstdc++ --enable-static
--enable-fully-dynamic-string --enable-lto --enable-plugin --enable-libgomp
--with-dwarf2 --disable-win32-registry --enable-version-specific-runtime-libs
--prefix=/mingw --with-sysroot=/mingw --target=x86_64-w64-mingw32
--enable-targets=all --enable-checking=release
--with-gmp=/new-gcc/lib/gmp-5.0.5 --with-mpfr=/new-gcc/lib/mpfr-2.4.2
--with-mpc=/new-gcc/lib/mpc-0.9 --with-isl=/new-gcc/lib/isl-0.12.2
--with-cloog=/new-gcc/lib/cloog-0.18.3 --with-host-libstdcxx='-lstdc++
-lsupc++' --disable-cloog-version-check --enable-cloog-backend=isl
on Linux (Xubuntu 14.04.3 LTS).
All system libraries where compiled with
-O3 -mtune=core2 -march=core2 -mstackrealign -fomit-frame-pointer
-Wno-maybe-uninitialized -flto -flto-partition=none -fno-builtin-stpcpy
Compiling this simple C++ program for x86 (-m32)
    #include <iostream>

    using namespace std;

    int main() {
        cout << "Hello World!" << endl;
        return 0;
    }
results in a SIGSEGV when linking dynamically instead of static.
Sample application compiled with
-m32 -O0 -g3 -ggdb -gdwarf-3 -o test.exe test.cpp
Compiling it in x64 mode (-m64) or static (-static) shows no issue.

See backtrace:
Starting program: H:\test.exe 
[New Thread 1132.0x1144]

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
#0  0x00000000 in ?? ()
No symbol table info available.
#1  0x004015e9 in __static_initialization_and_destruction_0 (__initialize_p=1,
__priority=65535)
    at /mingw/lib/gcc/x86_64-w64-mingw32/5.3.0/include/c++/iostream:74
No locals.
#2  0x00401612 in _GLOBAL__sub_I_main () at test.cpp:8
No locals.
#3  0x00401887 in __main ()
        std::moneypunct<wchar_t, true>::id = <error reading variable
std::moneypunct<wchar_t, true>::id (Cannot access memory at address 0x0)>
        std::__timepunct<wchar_t>::id = <error reading variable
std::__timepunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::messages<wchar_t>::id = <error reading variable
std::messages<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, false>::intl = <error reading variable
std::moneypunct_byname<wchar_t, false>::intl (Cannot access memory at address
0x0)>
        std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::collate<wchar_t>::id = <error reading variable
std::collate<wchar_t>::id (Cannot access memory at address 0x0)>
        std::numpunct<wchar_t>::id = <error reading variable
std::numpunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::intl = <error reading variable
std::moneypunct<wchar_t, false>::intl (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, true>::intl = <error reading variable
std::moneypunct<wchar_t, true>::intl (Cannot access memory at address 0x0)>
        std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::id = <error reading variable
std::moneypunct<wchar_t, false>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, true>::intl = <error reading variable
std::moneypunct_byname<wchar_t, true>::intl (Cannot access memory at address
0x0)>
#4  0x005d0000 in ?? ()
        std::moneypunct<wchar_t, true>::id = <error reading variable
std::moneypunct<wchar_t, true>::id (Cannot access memory at address 0x0)>
        std::__timepunct<wchar_t>::id = <error reading variable
std::__timepunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::messages<wchar_t>::id = <error reading variable
std::messages<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, false>::intl = <error reading variable
std::moneypunct_byname<wchar_t, false>::intl (Cannot access memory at address
0x0)>
        std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::collate<wchar_t>::id = <error reading variable
std::collate<wchar_t>::id (Cannot access memory at address 0x0)>
        std::numpunct<wchar_t>::id = <error reading variable
std::numpunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::intl = <error reading variable
std::moneypunct<wchar_t, false>::intl (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, true>::intl = <error reading variable
std::moneypunct<wchar_t, true>::intl (Cannot access memory at address 0x0)>
        std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::id = <error reading variable
std::moneypunct<wchar_t, false>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, true>::intl = <error reading variable
std::moneypunct_byname<wchar_t, true>::intl (Cannot access memory at address
0x0)>
#5  0x7568337a in KERNEL32!BaseCleanupAppcompatCacheSupport () from
C:\Windows\syswow64\kernel32.dll
No symbol table info available.
#6  0x0028ffd4 in ?? ()
        std::moneypunct<wchar_t, true>::id = <error reading variable
std::moneypunct<wchar_t, true>::id (Cannot access memory at address 0x0)>
        std::__timepunct<wchar_t>::id = <error reading variable
std::__timepunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::messages<wchar_t>::id = <error reading variable
std::messages<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, false>::intl = <error reading variable
std::moneypunct_byname<wchar_t, false>::intl (Cannot access memory at address
0x0)>
        std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::collate<wchar_t>::id = <error reading variable
std::collate<wchar_t>::id (Cannot access memory at address 0x0)>
        std::numpunct<wchar_t>::id = <error reading variable
std::numpunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::intl = <error reading variable
std::moneypunct<wchar_t, false>::intl (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, true>::intl = <error reading variable
std::moneypunct<wchar_t, true>::intl (Cannot access memory at address 0x0)>
        std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::id = <error reading variable
std::moneypunct<wchar_t, false>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, true>::intl = <error reading variable
std::moneypunct_byname<wchar_t, true>::intl (Cannot access memory at address
0x0)>
#7  0x76fc9882 in ntdll!RtlpMuiRegFreeRegistryInfo () from
C:\Windows\system32\ntdll.dll
No symbol table info available.
#8  0x7efde000 in ?? ()
No symbol table info available.
#9  0x76fc9855 in ntdll!RtlpMuiRegFreeRegistryInfo () from
C:\Windows\system32\ntdll.dll
No symbol table info available.
#10 0x004014e0 in WinMainCRTStartup ()
        std::moneypunct<wchar_t, true>::id = <error reading variable
std::moneypunct<wchar_t, true>::id (Cannot access memory at address 0x0)>
        std::__timepunct<wchar_t>::id = <error reading variable
std::__timepunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::num_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_get<wchar_t, std::istreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::messages<wchar_t>::id = <error reading variable
std::messages<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, false>::intl = <error reading variable
std::moneypunct_byname<wchar_t, false>::intl (Cannot access memory at address
0x0)>
        std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::time_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::collate<wchar_t>::id = <error reading variable
std::collate<wchar_t>::id (Cannot access memory at address 0x0)>
        std::numpunct<wchar_t>::id = <error reading variable
std::numpunct<wchar_t>::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::intl = <error reading variable
std::moneypunct<wchar_t, false>::intl (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, true>::intl = <error reading variable
std::moneypunct<wchar_t, true>::intl (Cannot access memory at address 0x0)>
        std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id = <error reading variable
std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t,
std::char_traits<wchar_t> > >::id (Cannot access memory at address 0x0)>
        std::moneypunct<wchar_t, false>::id = <error reading variable
std::moneypunct<wchar_t, false>::id (Cannot access memory at address 0x0)>
        std::moneypunct_byname<wchar_t, true>::intl = <error reading variable
std::moneypunct_byname<wchar_t, true>::intl (Cannot access memory at address
0x0)>
#11 0x7efde000 in ?? ()
No symbol table info available.
#12 0x00000000 in ?? ()
No symbol table info available.

Reply via email to