Bug 654424 - mingw32-boost Regex attach dll problem
Summary: mingw32-boost Regex attach dll problem
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw32-boost
Version: 14
Hardware: Unspecified
OS: Unspecified
low
high
Target Milestone: ---
Assignee: Thomas Sailer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-11-17 20:23 UTC by Kasyanchuk Alexey
Modified: 2010-12-01 22:00 UTC (History)
3 users (show)

Fixed In Version: mingw32-boost-1.44.0-1.fc14
Clone Of:
Environment:
Last Closed: 2010-11-30 22:20:34 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Kasyanchuk Alexey 2010-11-17 20:23:28 UTC
I'm using boost-regex in own project.
After I moved on Fedora 14, i get this error under wine:

err:module:attach_process_dlls "boost_regex-gcc45-mt-1_41.dll" failed to initialize, aborting
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\DEg\\projects\\pichi\\win32build\\pichi\\pichi.exe" failed, status c0000005

I didn't have such problem on Fedora 13 mingw.

Comment 1 Thomas Sailer 2010-11-18 09:09:03 UTC
Do you have a small testcase to reproduce the problem?

Comment 2 Kasyanchuk Alexey 2010-11-18 12:45:23 UTC
I wrote simple test for regex split:

[DEg@DEg test]$ cat test.cpp
#include <boost/algorithm/string/regex.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <vector>
#include <iostream>

int main(void)
{
        std::vector< std::string > test;
        boost::split_regex(test, "Simple test", boost::regex(" "));
        BOOST_FOREACH(std::string f, test)
        {
                std::cout << f << std::endl;
        }
        return 0;
}

[DEg@DEg test]$ g++ -l boost_regex test.cpp -o test
[DEg@DEg test]$ ./test
Simple
test

Looks normal on fedora's gcc

Let's try on mingw:
[DEg@DEg test]$ i686-pc-mingw32-g++ -lboost_regex-gcc45-1_41 test.cpp -o test.exe

Error's with undefined references in regex functions (but it's find boost regex lib successfully)

Then i tried to write cmake config
[DEg@DEg test]$ cat CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
PROJECT(test)

if(WIN32)
    find_package (Boost REQUIRED COMPONENTS regex-gcc45)

    ADD_EXECUTABLE(test test.cpp)
    target_link_libraries (test ${Boost_LIBRARIES})
endif(WIN32)


[DEg@DEg test]$ mingw32-cmake ./
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++
-- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.41.0
-- Found the following Boost libraries:
--   regex-gcc45
-- Configuring done
-- Generating done
-- Build files have been written to: /home/DEg/projects/test
[DEg@DEg test]$ mingw32-make
/usr/bin/cmake -H/home/DEg/projects/test -B/home/DEg/projects/test --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/DEg/projects/test/CMakeFiles /home/DEg/projects/test/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Вход в каталог `/home/DEg/projects/test'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Вход в каталог `/home/DEg/projects/test'
cd /home/DEg/projects/test && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/DEg/projects/test /home/DEg/projects/test /home/DEg/projects/test /home/DEg/projects/test /home/DEg/projects/test/CMakeFiles/test.dir/DependInfo.cmake --color=
Scanning dependencies of target test
make[2]: Выход из каталога `/home/DEg/projects/test'                                                     
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Вход в каталог `/home/DEg/projects/test'
/usr/bin/cmake -E cmake_progress_report /home/DEg/projects/test/CMakeFiles 1
[100%] Building CXX object CMakeFiles/test.dir/test.cpp.obj
/usr/bin/i686-pc-mingw32-g++    -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields    -o CMakeFiles/test.dir/test.cpp.obj -c /home/DEg/projects/test/test.cpp
Linking CXX executable test.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1                             
/usr/bin/i686-pc-mingw32-g++  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields    -Wl,@CMakeFiles/test.dir/objects1.rsp  -o test.exe -Wl,--out-implib,libtest.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -lboost_regex-gcc45-mt-1_41 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 
Info: resolving vtable for std::runtime_error by linking to __imp___ZTVSt13runtime_error (auto-import)
Info: resolving std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage by linking to __imp___ZNSs4_Rep20_S_empty_rep_storageE (auto-import)
Info: resolving std::cout  by linking to __imp___ZSt4cout (auto-import)
Info: resolving vtable for __cxxabiv1::__class_type_info by linking to __imp___ZTVN10__cxxabiv117__class_type_infoE (auto-import)
Info: resolving vtable for __cxxabiv1::__vmi_class_type_info by linking to __imp___ZTVN10__cxxabiv121__vmi_class_type_infoE (auto-import)
Info: resolving vtable for __cxxabiv1::__si_class_type_info by linking to __imp___ZTVN10__cxxabiv120__si_class_type_infoE (auto-import)
/usr/lib64/gcc/i686-pc-mingw32/4.5.0/../../../../i686-pc-mingw32/bin/ld: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
make[2]: Выход из каталога `/home/DEg/projects/test'
/usr/bin/cmake -E cmake_progress_report /home/DEg/projects/test/CMakeFiles  1
[100%] Built target test
make[1]: Выход из каталога `/home/DEg/projects/test'
/usr/bin/cmake -E cmake_progress_start /home/DEg/projects/test/CMakeFiles 0

Look's normal...
[DEg@DEg test]$ cp /usr/i686-pc-mingw32/sys-root/mingw/bin/{boost_regex-gcc45-mt-1_41.dll,libgcc_s_sjlj-1.dll,libstdc++-6.dll} ./
[DEg@DEg test]$ ls -la
итого 7804
drwxrwxr-x 3 DEg DEg    4096 Ноя 18 14:39 .
drwxrwxr-x 4 DEg DEg    4096 Ноя 18 13:23 ..
-rwxr-xr-x 1 DEg DEg  849104 Ноя 18 14:39 boost_regex-gcc45-mt-1_41.dll
-rw-rw-r-- 1 DEg DEg   13623 Ноя 18 14:38 CMakeCache.txt
drwxrwxr-x 6 DEg DEg    4096 Ноя 18 14:38 CMakeFiles
-rw-rw-r-- 1 DEg DEg    1430 Ноя 18 14:38 cmake_install.cmake
-rw-rw-r-- 1 DEg DEg     218 Ноя 18 14:26 CMakeLists.txt
-rwxr-xr-x 1 DEg DEg  463590 Ноя 18 14:39 libgcc_s_sjlj-1.dll
-rwxr-xr-x 1 DEg DEg 5776571 Ноя 18 14:39 libstdc++-6.dll
-rw-rw-r-- 1 DEg DEg    4654 Ноя 18 14:38 Makefile
-rwxrwxr-x 1 DEg DEg  225983 Ноя 18 14:31 test
-rw-rw-r-- 1 DEg DEg     327 Ноя 18 14:10 test.cpp
-rwxrwxr-x 1 DEg DEg  607637 Ноя 18 14:38 test.exe
[DEg@DEg test]$ wine test.exe
err:module:attach_process_dlls "boost_regex-gcc45-mt-1_41.dll" failed to initialize, aborting
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\DEg\\projects\\test\\test.exe" failed, status c0000005
[DEg@DEg test]$

Error...

Comment 3 Thomas Sailer 2010-11-18 18:04:42 UTC
Linking without cmake works like this:

i686-pc-mingw32-g++ -O2 -g -pipe -Wall -fexceptions -mms-bitfields test.cpp -o test.exe -lboost_regex-gcc45-mt-1_41 -lkernel32

Seems to me like the Boost regex attach handler crashes...

0009:Call PE DLL (proc=0x697410c0,module=0x69740000 L"boost_regex-gcc45-mt-1_41.
dll",reason=PROCESS_ATTACH,res=0x1)
0009:Call msvcrt.malloc(00000080) ret=69741124
0009:Call ntdll.RtlAllocateHeap(00110000,00000000,00000080) ret=68376f08
0009:trace:heap:RtlAllocateHeap (0x110000,70000062,00000080): returning 0x136e40
0009:Ret  ntdll.RtlAllocateHeap() retval=00136e40 ret=68376f08
0009:Ret  msvcrt.malloc() retval=00136e40 ret=69741124
0009:trace:seh:raise_exception code=c0000005 flags=0 addr=0x697547df ip=697547df
 tid=0009
0009:trace:seh:raise_exception  info[0]=00000001
0009:trace:seh:raise_exception  info[1]=697dd240
0009:trace:seh:raise_exception  eax=697e01d0 ebx=69740000 ecx=00000008 edx=697dd
240 esi=69740000 edi=00000001
0009:trace:seh:raise_exception  ebp=0068fd28 esp=0068fd24 cs=0023 ds=002b es=002
b fs=0063 gs=006b flags=00010202
0009:trace:seh:call_stack_handlers calling handler at 0x7bc896f0 code=c0000005 f
lags=0
0009:trace:seh:__regs_RtlUnwind code=c0000005 flags=2
0009:trace:seh:__regs_RtlUnwind calling handler at 0x7bc71f60 code=c0000005 flag
s=2
0009:trace:seh:__regs_RtlUnwind handler at 0x7bc71f60 returned 1
0009:exception in PE entry point (proc=0x697410c0,module=0x69740000,reason=PROCE
SS_ATTACH,res=0x1)
0009:Ret  PE DLL (proc=0x697410c0,module=0x69740000 L"boost_regex-gcc45-mt-1_41.
dll",reason=PROCESS_ATTACH,res=0x1) retval=1

Comment 4 Thomas Sailer 2010-11-18 20:39:05 UTC
The DllMain handler segfaults at:

/usr/i686-pc-mingw32/sys-root/mingw/lib/libmingw32.a(pseudo-reloc.o)
__pei386_runtime_relocator+0x1f

00000000 <__pei386_runtime_relocator>:
   0:   b8 00 00 00 00          mov    $0x0,%eax
                        1: dir32        ___RUNTIME_PSEUDO_RELOC_LIST__
   5:   55                      push   %ebp
   6:   3d 00 00 00 00          cmp    $0x0,%eax
                        7: dir32        ___RUNTIME_PSEUDO_RELOC_LIST_END__
   b:   89 e5                   mov    %esp,%ebp
   d:   53                      push   %ebx
   e:   73 18                   jae    28 <__pei386_runtime_relocator+0x28>
  10:   bb 00 00 00 00          mov    $0x0,%ebx
                        11: dir32       __image_base__
  15:   8b 50 04                mov    0x4(%eax),%edx
  18:   8b 08                   mov    (%eax),%ecx
  1a:   83 c0 08                add    $0x8,%eax
  1d:   01 da                   add    %ebx,%edx
  1f:   01 0a                   add    %ecx,(%edx)
  21:   3d 00 00 00 00          cmp    $0x0,%eax
                        22: dir32       ___RUNTIME_PSEUDO_RELOC_LIST_END__
  26:   72 ed                   jb     15 <__pei386_runtime_relocator+0x15>
  28:   5b                      pop    %ebx
  29:   5d                      pop    %ebp
  2a:   c3                      ret

Comment 5 Fedora Update System 2010-11-22 14:38:13 UTC
mingw32-boost-1.44.0-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mingw32-boost-1.44.0-1.fc14

Comment 6 Thomas Sailer 2010-11-22 14:44:24 UTC
You may need to add --enable-runtime-pseudo-reloc-v1 to your linker command line or -Wl,--enable-runtime-pseudo-reloc-v1 to your i686-pc-mingw32-g++ command line while linking, otherwise your test program crashes before entering main.

Your program now works for me with the following command line:

i686-pc-mingw32-g++  -O2 -g -pipe -Wall -fexceptions -mms-bitfields test.cpp -o  test.exe -lboost_regex-gcc45-d-1_44 -lkernel32 -Wl,--enable-runtime-pseudo-reloc-v1

wine test.exe 
Simple
test

And please give the update some karma.

Comment 7 Fedora Update System 2010-11-22 17:19:20 UTC
mingw32-binutils-2.20.1-2.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mingw32-binutils-2.20.1-2.fc14

Comment 8 Fedora Update System 2010-11-22 22:16:36 UTC
mingw32-boost-1.44.0-1.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update mingw32-boost'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/mingw32-boost-1.44.0-1.fc14

Comment 9 Fedora Update System 2010-11-30 22:19:33 UTC
mingw32-boost-1.44.0-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2010-12-01 22:00:45 UTC
mingw32-binutils-2.20.1-2.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.