Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Windows 7 x64, Ruby 2.0.0p0 x64, DevKit 4.7.2 (x86_64-w64-mingw32) Segmentation Fault on mysql2 0.3.11 #372

Closed
mgoggin opened this Issue · 21 comments
@mgoggin

I'm running Ruby 2.0.0p0 x64 on Windows 7 x64 with DevKit 4.7.2 (x86_64-w64-mingw32).

> gem install --platform=ruby mysql2 -- --with-mysql-lib=C:\Path\To\MySQL\C\Connector\lib --with-mysql-include=C:\Path\To\MySQL\C\Connector\include

I have been able to get the gem to compile successfully and work properly using the same procedure for x86 versions of Ruby 2.0.0p0.

On x64, the gem compiles successfully, but segfaults on require.

I'm using the 64-bit version of the C Connector from MySQL (mysql-connector-c-noinstall-6.0.2-winx64.zip) and the corresponding libmysql.dll is in my Ruby's bin dir.

Not sure if this is a problem with the toolchain or the extension. I'm leaning away from the toolchain as I can successfully compile and use SQLite3 with Ruby 2.0.0p0 x64.

Below is the trace I get when it segfaults:

C:\Users\Mike\Desktop\GemBuild>irb -r 'mysql2'
DL is deprecated, please use Fiddle
C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x64-mingw32/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0014 p:-5890000 s:0059 e:000058 TOP    [FINISH]
c:0013 p:---- s:0057 e:000056 CFUNC  :require
c:0012 p:0073 s:0053 e:000052 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45
c:0011 p:0091 s:0043 e:000042 TOP    C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x64-mingw32/lib/mysql2.rb:9 [FINISH]
c:0010 p:---- s:0041 e:000040 CFUNC  :require
c:0009 p:0059 s:0037 e:000036 BLOCK  C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110
c:0008 p:0286 s:0034 e:000033 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35
c:0007 p:0015 s:0024 e:000023 BLOCK  C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286 [FINISH]
c:0006 p:---- s:0021 e:000020 CFUNC  :each
c:0005 p:0013 s:0018 e:000017 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284
c:0004 p:0063 s:0013 e:000012 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20
c:0003 p:0039 s:0009 e:000008 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380
c:0002 p:0031 s:0004 E:002568 EVAL   C:/Ruby200p0-64bit/bin/irb:12 [FINISH]
c:0001 p:0000 s:0002 E:000018 TOP    [FINISH]

C:/Ruby200p0-64bit/bin/irb:12:in `<main>'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380:in `start'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20:in `setup'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `load_modules'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `each'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286:in `block in load_modules'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
C:\Users\Mike\Desktop\GemBuild>ruby -v
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
C:\Users\Mike\Desktop\GemBuild>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: C:/Ruby200p0-64bit/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby200p0-64bit/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0
     - C:/Users/Mike/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc --env-shebang"
  - REMOTE SOURCES:
     - https://rubygems.org/
C:\Users\Mike\Desktop\GemBuild>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/devkit-64bit/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /home/ruben/mingw-w64/src/gcc/configure --host=x86_64-w64-mingw32 --build=x86_64-linux-gnu --target=x86_64-w64-mingw32 --with-sysroot=/home/ruben/mingw-w64/mingw64mingw64/mingw64 --prefix=/home/ruben/mingw-w64/mingw64mingw64/mingw64 --with-gmp=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --with-mpfr=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --with-mpc=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --with-ppl=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --with-cloog=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --disable-ppl-version-check --disable-cloog-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static -lstdc++ -lm' --enable-shared --enable-static --enable-threads=win32 --enable-plugins --disable-multilib --enable-languages=c,lto,c++,objc,obj-c++,fortran,java --enable-libgomp --enable-fully-dynamic-string --enable-libstdcxx-time --disable-nls --disable-werror --enable-checking=release --with-gnu-as --with-gnu-ld --disable-win32-registry --disable-rpath --disable-werror --with-libiconv-prefix=/home/ruben/mingw-w64/prereq/x86_64-w64-mingw32/install --with-pkgversion=rubenvb-4.7.2-release --with-bugurl=mingw-w64-public@lists.sourceforge.net CC= CFLAGS='-O2 -march=nocona -mtune=core2 -fomit-frame-pointer -momit-leaf-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.7.2 (rubenvb-4.7.2-release)
@sodabrew
Collaborator

Please try mysql2 0.3.12b6 and see if there is any change / improvement to the situation.

@mgoggin

@sodabrew:

mysql2 0.3.12b6 compiles successfully, but still segfaults on require.

C:\Users\Mike\Desktop\GemBuild\mysql2>irb -r 'mysql2'
DL is deprecated, please use Fiddle
C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0014 p:-8615342 s:0059 e:000058 TOP    [FINISH]
c:0013 p:---- s:0057 e:000056 CFUNC  :require
c:0012 p:0073 s:0053 e:000052 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45
c:0011 p:0083 s:0043 e:000042 TOP    C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2.rb:8 [FINISH]
c:0010 p:---- s:0041 e:000040 CFUNC  :require
c:0009 p:0059 s:0037 e:000036 BLOCK  C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110
c:0008 p:0286 s:0034 e:000033 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35
c:0007 p:0015 s:0024 e:000023 BLOCK  C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286 [FINISH]
c:0006 p:---- s:0021 e:000020 CFUNC  :each
c:0005 p:0013 s:0018 e:000017 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284
c:0004 p:0063 s:0013 e:000012 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20
c:0003 p:0039 s:0009 e:000008 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380
c:0002 p:0031 s:0004 E:000c28 EVAL   C:/Ruby200p0-64bit/bin/irb:12 [FINISH]
c:0001 p:0000 s:0002 E:000ef8 TOP    [FINISH]

C:/Ruby200p0-64bit/bin/irb:12:in `<main>'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380:in `start'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20:in `setup'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `load_modules'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `each'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286:in `block in load_modules'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2.rb:8:in `<top (required)>'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'

-- C level backtrace information -------------------------------------------
C:\Windows\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0xa) [0x0000000077BF135A]
C:\Windows\system32\KERNELBASE.dll(WaitForSingleObjectEx+0x9c) [0x000007FEFDC310DC]
@mgoggin

I recompiled the gem without optimizations and with debugging enabled and got back some different results.

C:\Users\Mike\Desktop\GemBuild>irb -r 'mysql2'
DL is deprecated, please use Fiddle
C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0014 p:-9163830 s:0059 e:000058 TOP    [FINISH]
c:0013 p:---- s:0057 e:000056 CFUNC  :require
c:0012 p:0073 s:0053 e:000052 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45
c:0011 p:0083 s:0043 e:000042 TOP    C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2.rb:8 [FINISH]
c:0010 p:---- s:0041 e:000040 CFUNC  :require
c:0009 p:0059 s:0037 e:000036 BLOCK  C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110
c:0008 p:0286 s:0034 e:000033 METHOD C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35
c:0007 p:0015 s:0024 e:000023 BLOCK  C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286 [FINISH]
c:0006 p:---- s:0021 e:000020 CFUNC  :each
c:0005 p:0013 s:0018 e:000017 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284
c:0004 p:0063 s:0013 e:000012 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20
c:0003 p:0039 s:0009 e:000008 METHOD C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380
c:0002 p:0031 s:0004 E:0009a8 EVAL   C:/Ruby200p0-64bit/bin/irb:12 [FINISH]
c:0001 p:0000 s:0002 E:000588 TOP    [FINISH]
C:/Ruby200p0-64bit/bin/irb:12:in `<main>'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb:380:in `start'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:20:in `setup'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `load_modules'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:284:in `each'
C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb:286:in `block in load_modules'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2.rb:8:in `<top (required)>'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'

-- C level backtrace information -------------------------------------------
C:\Windows\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0xa) [0x00000000777A135A]
C:\Windows\system32\KERNELBASE.dll(WaitForSingleObjectEx+0x9c) [0x000007FEFD6A10DC]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_bugreport+0x9d) [0x000000006F280C8D]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_name_err_mesg_new+0x838) [0x000000006F141418]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_bug+0x45) [0x000000006F1421C5]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_check_safe_str+0x188) [0x000000006F2074E8]
 [0x0000000000401A85]
C:\Windows\SYSTEM32\ntdll.dll(_C_specific_handler+0x9c) [0x00000000777685A8]
C:\Windows\SYSTEM32\ntdll.dll(RtlDecodePointer+0xbd) [0x0000000077779D0D]
C:\Windows\SYSTEM32\ntdll.dll(RtlUnwindEx+0xbbf) [0x00000000777691AF]
C:\Windows\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x2e) [0x00000000777A1278]
C:\Ruby200p0-64bit\lib\ruby\gems\2.0.0\gems\mysql2-0.3.12b6-x64-mingw32\lib\mysql2\mysql2.so(Init_mysql2+0x2508) [0x00000000004866B8]
 [0x0000000000483397]
C:\Ruby200p0-64bit\lib\ruby\gems\2.0.0\gems\mysql2-0.3.12b6-x64-mingw32\lib\mysql2\mysql2.so(Init_mysql2+0x6a) [0x000000000048421A]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(dln_load+0x1d3) [0x000000006F101643]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_call_cfunc+0x12c) [0x000000006F27E1CC]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_require_safe+0x41b) [0x000000006F14C89B]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_error_arity+0x125) [0x000000006F26C525]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_funcall2+0x4c2) [0x000000006F27BA22]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x1b01) [0x000000006F270611]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x5c89) [0x000000006F274799]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_iseq_eval+0x193) [0x000000006F27DC13]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_rubylevel_errinfo+0x5e3) [0x000000006F14ADA3]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_require_safe+0x44e) [0x000000006F14C8CE]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_error_arity+0x125) [0x000000006F26C525]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_funcall2+0x4c2) [0x000000006F27BA22]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x1b01) [0x000000006F270611]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x5c89) [0x000000006F274799]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_yield+0x15c) [0x000000006F27D89C]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_ary_each+0x51) [0x000000006F106851]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_error_arity+0x125) [0x000000006F26C525]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_funcall2+0x4c2) [0x000000006F27BA22]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x1a9c) [0x000000006F2705AC]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_vm_localjump_error+0x5c89) [0x000000006F274799]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_iseq_eval_main+0x1e0) [0x000000006F27DE40]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(rb_check_copyable+0x31f2) [0x000000006F1470F2]
C:\Ruby200p0-64bit\bin\x64-msvcrt-ruby200.dll(ruby_run_node+0x51) [0x000000006F1499E1]
 [0x0000000000402D14]
 [0x00000000004013D7]
 [0x00000000004014F8]
C:\Windows\system32\kernel32.dll(BaseThreadInitThunk+0xd) [0x000000007764652D]

-- Other runtime information -----------------------------------------------

* Loaded script: irb

* Loaded features:

    0 enumerator.so
    1 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/encdb.so
    2 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/iso_8859_1.so
    3 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/trans/transdb.so
    4 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/rbconfig.rb
    5 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/compatibility.rb
    6 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/defaults.rb
    7 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/deprecate.rb
    8 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/errors.rb
    9 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/version.rb
   10 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/requirement.rb
   11 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/platform.rb
   12 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb
   13 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/exceptions.rb
   14 C:/Ruby200p0-64bit/lib/ruby/2.0.0/rubygems/defaults/operating_system.rb
   15 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/utf_16le.so
   16 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/trans/utf_16_32.so
   17 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb
   18 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb
   19 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems.rb
   20 C:/Ruby200p0-64bit/lib/ruby/2.0.0/e2mmap.rb
   21 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/init.rb
   22 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/workspace.rb
   23 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/inspector.rb
   24 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/context.rb
   25 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/extend-command.rb
   26 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/output-method.rb
   27 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/notifier.rb
   28 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/slex.rb
   29 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/ruby-token.rb
   30 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/ruby-lex.rb
   31 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/src_encoding.rb
   32 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/magic-file.rb
   33 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/euc_jp.so
   34 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/windows_31j.so
   35 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/etc.so
   36 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/enc/trans/single_byte.so
   37 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/dl.so
   38 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/fiddle.so
   39 C:/Ruby200p0-64bit/lib/ruby/2.0.0/fiddle/function.rb
   40 C:/Ruby200p0-64bit/lib/ruby/2.0.0/fiddle/closure.rb
   41 C:/Ruby200p0-64bit/lib/ruby/2.0.0/fiddle.rb
   42 C:/Ruby200p0-64bit/lib/ruby/2.0.0/dl.rb
   43 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rbreadline.rb
   44 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/readline.rb
   45 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/input-method.rb
   46 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb/locale.rb
   47 C:/Ruby200p0-64bit/lib/ruby/2.0.0/irb.rb
   48 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/path_support.rb
   49 C:/Ruby200p0-64bit/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb
   50 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/date_core.so
   51 C:/Ruby200p0-64bit/lib/ruby/2.0.0/date/format.rb
   52 C:/Ruby200p0-64bit/lib/ruby/2.0.0/date.rb
   53 C:/Ruby200p0-64bit/lib/ruby/2.0.0/x64-mingw32/bigdecimal.so
   54 C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2/version.rb
   55 C:/Ruby200p0-64bit/lib/ruby/gems/2.0.0/gems/mysql2-0.3.12b6-x64-mingw32/lib/mysql2/error.rb

I also played around in mysql2_ext.c and it looks like it segfaults when calling init_mysql2_client().

@MartinodF

I can confirm mysql2 0.3.12b6 still segfaults on require. It's currently the only issue preventing MySQL-based Rails apps from running on Ruby x64 / Windows, so it's kind of a big deal...

Windows 8 x64, Ruby 2.0.0p195 x64, DevKit 4.7.2 mingw64-64

@imjaypatel

same problem me when execute "rails server" command... serious problem

@ddavison

I'm getting this problem as well.. I think some priority should be put to this.

@sodabrew
Collaborator

Please do investigate and let us know what changes need to be make to the mysql2 to support your use case. Pull Requests appreciated!

@ddavison

I've noticed that this issue might only be happening on Windows. More importantly, when you already have MySQL Server installed on your machine. It could be from differing versions of the libmysql.dll

@mgoggin

@ddavison I don't have MySQL Server installed. I encountered the issue compiling against the MySQL C Connector. I have verified unequivocally that the libmysql.dll in my Ruby lib is the correct version as provided by the C Connector. This shouldn't be the issue unless Oracle accidentally packaged a 32-bit DLL with the 64-bit library and header files.

Maybe I need to try compiling against the library provided by MySQL Server and see if that gives different results.

You are correct that the issue is localized to Ruby 64-bit on Windows. 64-bit compilation and require are successful on Linux and Mac OS X.

@ChapterHouse

I am observing the same issue after installing with mysql-installer-community-5.6.12.0.msi
Windows 7 and ruby 2.0.0p195 (2013-05-14) [x64-mingw32]

For sanity sake I checked the libmysql.dll.
I was also thinking it might be 32 bit. It isn't. Here is the check:

C:\Ruby200-x64\bin>dumpbin.exe /HEADERS C:\Ruby200-x64\bin\libmysql.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file C:\Ruby200-x64\bin\libmysql.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               9 number of sections
        519BB846 time date stamp Tue May 21 13:09:10 2013
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

OPTIONAL HEADER VALUES
             20B magic # (PE32+)
           10.00 linker version
           D6000 size of code
          431A00 size of initialized data
               0 size of uninitialized data
            1270 entry point (0000000180001270)
            1000 base of code
       180000000 image base (0000000180000000 to 000000018050BFFF)
            1000 section alignment
             200 file alignment
            5.02 operating system version
            0.00 image version
            5.02 subsystem version
               0 Win32 version
          50C000 size of image
             400 size of headers
               0 checksum
               3 subsystem (Windows CUI)
             140 DLL characteristics
                   Dynamic base
                   NX compatible
          100000 size of stack reserve
            1000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
          10D770 [     F7F] RVA [size] of Export Directory
          4FA000 [      64] RVA [size] of Import Directory
          504000 [     633] RVA [size] of Resource Directory
          4EE000 [    A71C] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
          505000 [    3008] RVA [size] of Base Relocation Directory
           D7BD0 [      1C] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
               0 [       0] RVA [size] of Thread Storage Directory
               0 [       0] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
          4FA888 [     820] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory


SECTION HEADER #1
   .text name
   D5E14 virtual size
    1000 virtual address (0000000180001000 to 00000001800D6E13)
   D6000 size of raw data
     400 file pointer to raw data (00000400 to 000D63FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

SECTION HEADER #2
  .rdata name
   376EF virtual size
   D7000 virtual address (00000001800D7000 to 000000018010E6EE)
   37800 size of raw data
   D6400 file pointer to raw data (000D6400 to 0010DBFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

  Debug Directories

        Time Type       Size      RVA  Pointer
    -------- ------ -------- -------- --------
    519BB846 cv           6D 000F4C84    F4084    Format: RSDS, {64515830-648E-4E94-B43B-5043B9447E6D}, 3, G:\pb2\build\sb_0-9307864-1369158921.61\release\libmysql\RelWithDebInfo\libmysql.pdb

SECTION HEADER #3
   .data name
  3DEFC9 virtual size
  10F000 virtual address (000000018010F000 to 00000001804EDFC8)
  355C00 size of raw data
  10DC00 file pointer to raw data (0010DC00 to 004637FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #4
  .pdata name
    B8F8 virtual size
  4EE000 virtual address (00000001804EE000 to 00000001804F98F7)
    BA00 size of raw data
  463800 file pointer to raw data (00463800 to 0046F1FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

SECTION HEADER #5
  .idata name
    1ED9 virtual size
  4FA000 virtual address (00000001804FA000 to 00000001804FBED8)
    2000 size of raw data
  46F200 file pointer to raw data (0046F200 to 004711FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #6
    text name
    1254 virtual size
  4FC000 virtual address (00000001804FC000 to 00000001804FD253)
    1400 size of raw data
  471200 file pointer to raw data (00471200 to 004725FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
20000040 flags
         Initialized Data
         Execute Only

SECTION HEADER #7
    data name
    500C virtual size
  4FE000 virtual address (00000001804FE000 to 000000018050300B)
    5200 size of raw data
  472600 file pointer to raw data (00472600 to 004777FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

SECTION HEADER #8
   .rsrc name
     633 virtual size
  504000 virtual address (0000000180504000 to 0000000180504632)
     800 size of raw data
  477800 file pointer to raw data (00477800 to 00477FFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

SECTION HEADER #9
  .reloc name
    699A virtual size
  505000 virtual address (0000000180505000 to 000000018050B999)
    6A00 size of raw data
  478000 file pointer to raw data (00478000 to 0047E9FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
42000040 flags
         Initialized Data
         Discardable
         Read Only

  Summary

      3DF000 .data
        2000 .idata
        C000 .pdata
       38000 .rdata
        7000 .reloc
        1000 .rsrc
       D6000 .text
        6000 data
        2000 text
@ddavison

I've decided to scrap mysql because of these rediculous errors (and the fact that MySQL is getting quickly outdated) and went with MongoDB. If you are willing to try it - it's very nice. pretty good tutorial http://railsapps.github.io/tutorial-rails-mongoid-devise.html if you are curious. bit outdated though

@sodabrew
Collaborator

Please do investigate and suggest any code changes to mysql2 that are required to get this working for your environment.

@phasis68

I found the solution for this issue.
Refer to https://bugs.ruby-lang.org/issues/8591

@mgoggin

I can confirm that the fix offered by @phasis68 works. After generating a new .lib from libmysql.dll, I'm able to successfully build, require, and use the gem. I tried both 0.3.11 and 0.3.12b6 and both worked.

If anyone is interested, here's a pre-patched ZIP of the C Connector 6.0.2 64-bit: https://copy.com/CHZ4eT4us6f1

Since we've identified the cause and it isn't with the gem, and since I'm satisfied with the solution, I'm closing the issue.

@mgoggin mgoggin closed this
@zagros

yes confirming that @phasis68 solution worked

uninstall mysql2/mysql first .... then install using his method (and copy the mysqllib.dll from the x64 connector that you used for gendef.exe to the bin of your Ruby2x64 installation)

@theclassycanadian

I had some troubles and compiled a step by step instructions for anyone that encounter this problem:

To download:
(1) https://structure-svm-map.googlecode.com/files/svm-map-win.zip
(2) http://sourceforge.net/projects/mingw/files/Installer/

Step 0.
Uninstall mysql2 by entering the command in the command prompt:
gem uninstall mysql2

Step 1.
Copy gendef.exe from svm-map (1) to the MySql server directory and run the following the command in the command line:
gendef.exe libmysql.dll

Step 2.
Install MinGW (2) and install the basic repository
Remember where the MinGW is installed
Add "E:\MinGW\bin" (change depending where your application is installed) to PATH (environment variables)

Step 3.
Open a new instance of the command line and navigate to your MySql Server directory (mine's E:\Program Files\MySQL\MySQL Server 5.6)
Run the following the command line:
dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib

Step 4.
Install mysql2 using rubygems in the command line with the following options (change depending where your MySQL Server is located):
gem install mysql2 --no-rdoc --no-ri -- '--withmysql-dir="E:\Program Files\MySQL\MySQL Server 5.6\bin" --with-mysql-lib="E:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mysql-include="E:\Program Files\MySQL\MySQL Server 5.6\include"'

Step 5.
Copy over libmysql.dll from your MySQL server directory to "E:\Ruby200-x64\bin" (change depending on where the application is installed)

Step 6.
Try "rails server" in the command line to ensure if installation is done correctly

@amaurin

The patch works great for ruby 2.0, windows 7 and x64 (and for x64 ruby installation).

Install this my sql connector : https://copy.com/CHZ4eT4us6f1.

Extract the file somewhere in your C disk.

Install gem mysql2 : gem install mysql2 --no-rdoc --no-ri -- '--withmysql-dir="C:\mysql-connector-c-noinstall-6.0.2-winx64\bin" --with-mysql-lib="C:\mysql-connector-c-noinstall-6.0.2-winx64\lib" --with-mysql-include="C:\mysql-connector-c-noinstall-6.0.2-winx64\include"'

Copy the .dll from C:\mysql-connector-c-noinstall-6.0.2-winx64\lib in the bin directory of ruby

And it will run perfectly. Forget everything else.

@ChapterHouse

Works like a champ! Thank you.

@pencil pencil referenced this issue in rbCAS/CASinoApp
Closed

How to fix this problem .. please help me #15

@CatKin76

Will this work for my 32 bit machine with windows 7 professional as I have been having the very same error?

@amaurin

It would be a mistery if it works. It shouldn't work. But be carefull to install ruby x32 on your 32 bit.

@sodabrew
Collaborator

Binary releases of mysql2 0.3.18 compiled for Windows are posted to Rubygems.org. The mysql2 0.3.18 binaries are built both x86 and x64 and for Ruby 1.8.7 - 2.1. A future release will include binaries for Ruby 2.2. I am closing comments now. If you have a new issue, please open a new issue.

@sodabrew sodabrew locked and limited conversation to collaborators
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Something went wrong with that request. Please try again.