Segmentation fault when trying to load ibm_db Ruby C extension

195 views
Skip to first unread message

Praveen

unread,
Apr 4, 2012, 6:47:14 AM4/4/12
to RubyInstaller
Hi All,

I am trying to load [require] the ibm_db driver to connect to DB2 in
my ruby program. The load works fine on Linux when on same version of
Ruby (ruby 1.9.3p125) but however on windows I see the following error
(stack trace below)

Googling around did not quite help. One possibility that I could think
of is, there is some Ruby C API that I am using in ibm_db extension
which probably is removed (or not recommended) in Rubyinstaller
starting from version 1.9.3p125 onwards.

Could you kindly help me resolve this.

Steps to repro the error

1) Install the ibm_db gem - gem install ibm_db
2) Start a irb session and issue the following command

C:\>irb
irb(main):001:0>require 'mswin32/ibm_db'

I tried hooking in some debug point (made some file write operation)
into the init function of the ibm_db c module. However I don't the any
file writes. Looks like the load is failing even before entering the
function

Note: The same gem works fine on Ruby-1.9.2p290 on windows

Stack Trace
---------------------------------------------------------------------------------------------------------------------------------------------------------

C:\praveen_work\ruby_proj\Releases_ruby
\Release-2.5.9\rubyibm-2.5.9\IBM_DB_Adapt
er\ibm_db>irb
irb(main):001:0> require 'ibm_db'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ibm_db-2.5.9-x86-mingw32/lib/
mswin32/rb19x/ibm_db.so: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

-- Control frame information
-----------------------------------------------
c:0031 p:-11058570 s:0113 b:0113 l:000112 d:000112 TOP
c:0030 p:---- s:0111 b:0111 l:000110 d:000110 CFUNC :require
c:0029 p:0053 s:0107 b:0107 l:000106 d:000106 METHOD C:/Ruby193/lib/
ruby/1.9.1/rubygems/custom_require.rb:36
c:0028 p:0011 s:0100 b:0100 l:000099 d:000099 TOP C:/Ruby193/lib/
ruby/gems/1.9.1/gems/ibm_db-2.5.9-x86-mingw32/lib/IBM_DB.rb:2
c:0027 p:---- s:0098 b:0098 l:000097 d:000097 FINISH
c:0026 p:---- s:0096 b:0096 l:000095 d:000095 CFUNC :require
c:0025 p:0071 s:0092 b:0092 l:000088 d:000091 BLOCK C:/Ruby193/lib/
ruby/1.9.1/rubygems/custom_require.rb:59
c:0024 p:0175 s:0089 b:0089 l:000088 d:000088 METHOD C:/Ruby193/lib/
ruby/1.9.1/rubygems/custom_require.rb:35
c:0023 p:0011 s:0082 b:0082 l:000c8c d:000081 EVAL (irb):1
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD C:/Ruby193/lib/
ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD C:/Ruby193/lib/
ruby/1.9.1/irb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:000dc4 d:000057 BLOCK C:/Ruby193/lib/
ruby/1.9.1/irb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD C:/Ruby193/lib/
ruby/1.9.1/irb.rb:273
c:0016 p:0011 s:0045 b:0045 l:000dc4 d:000044 BLOCK C:/Ruby193/lib/
ruby/1.9.1/irb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK C:/Ruby193/lib/
ruby/1.9.1/irb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK C:/Ruby193/lib/
ruby/1.9.1/irb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD C:/Ruby193/lib/
ruby/1.9.1/irb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:000dc4 d:000dc4 METHOD C:/Ruby193/lib/
ruby/1.9.1/irb.rb:155
c:0007 p:0011 s:0019 b:0019 l:00001c d:000018 BLOCK C:/Ruby193/lib/
ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0183 s:0011 b:0011 l:00001c d:00001c METHOD C:/Ruby193/lib/
ruby/1.9.1/irb.rb:69
c:0003 p:0039 s:0006 b:0006 l:001214 d:001bbc EVAL C:/Ruby193/bin/
irb:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001214 d:001214 TOP

-- Ruby level backtrace information
----------------------------------------
C:/Ruby193/bin/irb:12:in `<main>'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:69:in `start'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:69:in `catch'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:70:in `block in start'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in
`each_top_level_statement'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in
each_top_level_statement'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in
each_top_level_statement'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
C:/Ruby193/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in
eval_input'
C:/Ruby193/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
(irb):1:in `irb_binding'
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in
require'
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ibm_db-2.5.9-x86-mingw32/lib/
IBM_DB.rb:2:in
`<top (required)>'
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

-- C level backtrace information
-------------------------------------------
C:\windows\SysWOW64\ntdll.dll(ZwWaitForSingleObject+0x15) [0x77d5f8b1]
C:\windows\syswow64\kernel32.dll(WaitForSingleObjectEx+0x43)
[0x770a1194]
C:\windows\syswow64\kernel32.dll(WaitForSingleObject+0x12)
[0x770a1148]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_vm_bugreport+0xf9) [0x62e5acc9]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_name_err_mesg_new+0x17a)
[0x62d3a68e]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_bug+0x2f) [0x62d3b3ef]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_check_safe_str+0x1a4)
[0x62ded27c]
[0x004011e6]
C:\windows\syswow64\kernel32.dll(GetProfileStringW+0x12aa3)
[0x770e003f]
C:\windows\SysWOW64\ntdll.dll(RtlKnownExceptionFilter+0xb7)
[0x77db74df]

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

* Loaded script: irb

* Loaded features:

0 enumerator.so
1 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/encdb.so
2 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/iso_8859_1.so
3 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/transdb.so
4 C:/Ruby193/lib/ruby/1.9.1/rubygems/defaults.rb
5 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb
6 C:/Ruby193/lib/ruby/1.9.1/rubygems/deprecate.rb
7 C:/Ruby193/lib/ruby/1.9.1/rubygems/exceptions.rb
8 C:/Ruby193/lib/ruby/1.9.1/rubygems/defaults/operating_system.rb
9 C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb
10 C:/Ruby193/lib/ruby/1.9.1/rubygems.rb
11 C:/Ruby193/lib/ruby/1.9.1/e2mmap.rb
12 C:/Ruby193/lib/ruby/1.9.1/irb/init.rb
13 C:/Ruby193/lib/ruby/1.9.1/irb/workspace.rb
14 C:/Ruby193/lib/ruby/1.9.1/irb/inspector.rb
15 C:/Ruby193/lib/ruby/1.9.1/irb/context.rb
16 C:/Ruby193/lib/ruby/1.9.1/irb/extend-command.rb
17 C:/Ruby193/lib/ruby/1.9.1/irb/output-method.rb
18 C:/Ruby193/lib/ruby/1.9.1/irb/notifier.rb
19 C:/Ruby193/lib/ruby/1.9.1/irb/slex.rb
20 C:/Ruby193/lib/ruby/1.9.1/irb/ruby-token.rb
21 C:/Ruby193/lib/ruby/1.9.1/irb/ruby-lex.rb
22 C:/Ruby193/lib/ruby/1.9.1/irb/src_encoding.rb
23 C:/Ruby193/lib/ruby/1.9.1/irb/magic-file.rb
24 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/euc_jp.so
25 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/shift_jis.so
26 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/etc.so
27 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/dl.so
28 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/fiddle.so
29 C:/Ruby193/lib/ruby/1.9.1/fiddle/function.rb
30 C:/Ruby193/lib/ruby/1.9.1/fiddle/closure.rb
31 C:/Ruby193/lib/ruby/1.9.1/fiddle.rb
32 C:/Ruby193/lib/ruby/1.9.1/dl.rb
33 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb
34 C:/Ruby193/lib/ruby/site_ruby/1.9.1/readline.rb
35 C:/Ruby193/lib/ruby/1.9.1/irb/input-method.rb
36 C:/Ruby193/lib/ruby/1.9.1/irb/locale.rb
37 C:/Ruby193/lib/ruby/1.9.1/irb.rb
38 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/utf_16le.so
39 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/single_byte.so
40 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/utf_16_32.so
41 C:/Ruby193/lib/ruby/1.9.1/rubygems/version.rb
42 C:/Ruby193/lib/ruby/1.9.1/rubygems/requirement.rb
43 C:/Ruby193/lib/ruby/1.9.1/rubygems/platform.rb
44 C:/Ruby193/lib/ruby/1.9.1/rubygems/specification.rb
45 C:/Ruby193/lib/ruby/1.9.1/rubygems/path_support.rb
46 C:/Ruby193/lib/ruby/1.9.1/rubygems/dependency.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
---------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks

Praveen

Luis Lavena

unread,
Apr 4, 2012, 9:44:46 AM4/4/12
to rubyin...@googlegroups.com

Please ask the gem author about what version of ruby he used to create the 1.9 version of the extension.

Most likely was created incorrectly and is failing against ruby 1.9.3

I have no experience with IBM db2 so can't be much help. Perhaps you can tell the gem author post here if he has further questions.

Sorry for top posting. Sent from mobile.

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To post to this group, send email to rubyin...@googlegroups.com.
To unsubscribe from this group, send email to rubyinstalle...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyinstaller?hl=en.

Praveen

unread,
Apr 4, 2012, 10:46:52 AM4/4/12
to RubyInstaller
Hi Luis,

I am the author of the gem :-)

I have tried building the gem on Ruby-1.9.3 itself and installing the
same. I am still getting the error. Was not sure what could be going
wrong, hence made a post.

Am not sure where is it going wrong. Any clues that will guide in the
right direction will be helpful.

Which should be the first place I will need to look at?

Thanks

Praveen

Luis Lavena

unread,
Apr 4, 2012, 11:14:43 AM4/4/12
to rubyin...@googlegroups.com
On Wed, Apr 4, 2012 at 11:46 AM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> I am the author of the gem :-)
>

OK, where is the source code to clone/checkout and compile locally?

> I have tried building the gem on Ruby-1.9.3 itself and installing the
> same. I am still getting the error. Was not sure what could be going
> wrong, hence made a post.
>

Perhaps the error is due something you're doing in the code. You
mention it works with 1.9.2 but not 1.9.3, so perhaps is something
differently.

If it is segfaulting when doing the require, we need to know what
you're doing in "Init_*" function.

> Am not sure where is it going wrong. Any clues that will guide in the
> right direction will be helpful.
>

Please provide links to the source and any documentation that can help
us compile and help debug the issue.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Praveen

unread,
Apr 4, 2012, 1:16:42 PM4/4/12
to RubyInstaller
Hi Luis,

You can download the source code of ibm_db gem from
http://rubyforge.org/frs/?group_id=2361 or can do a svn checkout from
svn checkout http://rubyibm.rubyforge.org/svn/

To build the driver you will need the DB2 client installed on the
system. You can download the DB2 client for windows 32-bit platform
from http://www-01.ibm.com/support/docview.wss?uid=swg24031182

Lets say the DB2 client installed directory is %DB2_HOME%

To build the driver, follow the below steps

C:\>set IBM_DB_LIB=%DB2_HOME%/lib

C:\>set IBM_DB_INCLUDE=%DB2_HOME%/include

Now in the ibm_db gem source from ext directory issue the following
commands

C:\rubyibm\IBM_DB_Adapter\ibm_db\ext>ruby extconf.rb
C:\rubyibm\IBM_DB_Adapter\ibm_db\ext>make

Copy the generated ibm_db.so into C:\rubyibm\IBM_DB_Adapter\ibm_db\lib

Build the gem (use the gemspec file at https://gist.github.com/2303893
) and install it.

Try accessing the ibm_db driver from irb, as below

irb> require 'ibm_db.so'

Let me know if you need more info

Thanks

Praveen

Jon

unread,
Apr 4, 2012, 1:55:57 PM4/4/12
to rubyin...@googlegroups.com

Try accessing the ibm_db driver from irb, as below

irb> require 'ibm_db.so'


You've used something like the following to double check that the .so is accessing the correct deps for 1.9.3?

  http://www.winitor.com/
  http://www.dependencywalker.com/

Praveen

unread,
Apr 5, 2012, 2:06:47 AM4/5/12
to RubyInstaller
Hi Jon,
>
> You've used something like the following to double check that the .so is
> accessing the correct deps for 1.9.3?
>
> http://www.winitor.com/
> http://www.dependencywalker.com/

I used dependency walker to check the same. I see that all
dependencies are listed (KERNEL32.dll, MSVCRT.dll, DB2CLI.dll, MSVCRT-
RUBY191.dll). The same dependencies are seen when checked on the .so
built from Ruby-1.9.2. However I see one difference in the binary
built from Ruby-1.9.3, I see that the exported function of .so is
correctly shown as only Init_ibm_db (the modules entry function),
however on Ruby-1.9.2 I see that all my functions along with
Init_ibm_db defined in the module ruby_ibm_db_cli.o which is actually
linked up to form the ibm_db.so is also listed.

One thing to note is I get a warning in dependency walker as below

Error: At least one required implicit or forwarded dependency was not
found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing
export function in a delay-load dependent module.

Which I guess should be ok(?), as it refers to a delay-load dependency
module

Luis,

One thing I forgot to mention, when downloading the DB2 client you
will need to download the IBM Data Server Driver package. This
sufficient for getting the ibm_db driver built and running.

Help is highly appreciated!!

Thanks

Praveen

Praveen

unread,
Apr 6, 2012, 2:42:10 AM4/6/12
to RubyInstaller
My further findings.

I see that the same binary compiled on Ruby-1.9.3 works fine on
Ruby-1.9.2. Hence looks like there is something specific to Ruby-1.9.3
that I am missing.

Below is the list of Ruby 'C' calls I make in the Init_ibm_db function

rb_define_module
rb_define_module_function
rb_intern
rb_define_singleton_method
rb_define_const
rb_global_variable
rb_define_class_under
rb_attr
rb_eval_string

Was there any change in either of these functions for Ruby-1.9.3 on
windows?


As I have mentioned earlier looks like the Init_ibm_db function is not
hit yet when the segmentation fault occurs (I have some log statements
right at the first line and I see no logs generated).

Am I missing something simple?

Thanks

Praveen

Praveen

unread,
Apr 6, 2012, 4:19:00 AM4/6/12
to RubyInstaller
Hi,

Some more information. I tried running this under the observance of
Debug Diag tool and see the following analysis report

This line in the log is interesting

"the assembly instruction at msvcrt_ruby191!dln_load+17b in C:
\Ruby193\bin\msvcrt-ruby191.dll from http://www.ruby-lang.org/ has
caused an access violation exception (0xC0000005) when trying to read
from memory location 0x00000000 on thread 0"

Not sure what is the function dln_load doing. Any pointers?

If this info might be useful, I am on Windows 7 (64-bit OS).


===================================================================================================================================================
Trace
------

Function Arg 1 Arg 2 Arg 3 Source
ntdll!ZwRaiseException+12 0028dd1c 0028dd6c 00000000
ntdll!KiUserExceptionDispatcher+29 0028dd1c 0028dd6c
00000000




MSVCRT_RUBY191!DLN_LOAD+17BWARNING - DebugDiag was not able to locate
debug symbols for msvcrt-ruby191.dll, so the information below may be
incomplete.



In
ruby__PID__5012__Date__04_06_2012__Time_12_18_54PM__108__Second_Chance_Exception_C0000005.dmp
the assembly instruction at msvcrt_ruby191!dln_load+17b in C:
\Ruby193\bin\msvcrt-ruby191.dll from http://www.ruby-lang.org/ has
caused an access violation exception (0xC0000005) when trying to read
from memory location 0x00000000 on thread 0

Module Information
Image Name: C:\Ruby193\bin\msvcrt-ruby191.dll Symbol Type: Export
Base address: 0x62d00000 Time Stamp: Thu Feb 16 18:52:55 2012
Checksum: 0x00215dfe Comments: 2012-02-16
COM DLL: False Company Name: http://www.ruby-lang.org/
ISAPIExtension: False File Description: Ruby interpreter (DLL)
1.9.3p125 [i386-mingw32]
ISAPIFilter: False File Version: 1.9.3p125
Managed DLL: False Internal Name: msvcrt-ruby191.dll
VB DLL: False Legal Copyright: Copyright (C) 1993-2012 Yukihiro
Matsumoto
Loaded Image Name: msvcrt-ruby191.dll Legal Trademarks:
Mapped Image Name: Original filename: msvcrt-ruby191.dll
Module name: msvcrt_ruby191 Private Build:
Single Threaded: False Product Name: Ruby interpreter 1.9.3p125
[i386-mingw32]
Module Size: 2.13 MBytes Product Version: 1.9.3p125
Symbol File Name: msvcrt-ruby191.dll Special Build: &


Thanks

Praveen

Luis Lavena

unread,
Apr 6, 2012, 9:18:26 AM4/6/12
to rubyin...@googlegroups.com
On Fri, Apr 6, 2012 at 5:19 AM, Praveen <prave...@in.ibm.com> wrote:
> Hi,
>
> Some more information. I tried running this under the observance of
> Debug Diag tool and see the following analysis report
>
> This line in the log is interesting
>
> "the assembly instruction at msvcrt_ruby191!dln_load+17b in C:
> \Ruby193\bin\msvcrt-ruby191.dll from http://www.ruby-lang.org/ has
> caused an access violation exception (0xC0000005) when trying to read
> from memory location 0x00000000 on thread 0"
>
> Not sure what is the function dln_load doing. Any pointers?
>

dln_load is Dynamic Library loading support of Ruby, which wraps dln
(POSIX) or LoadLibrary.

Re: API, there has been no change in the exposed API between 1.9.2 and
1.9.3, it only added exposed functions.

Re: symbols exposed in 1.9.2 compilation: that was because all the
symbols were exported, in 1.9.3 that got fixed and only Init_* is
exported.

I didn't have time to check this out, will do over the weekend as I'm
still playing catch up game with my work (was out ill for the past few
days)

Praveen

unread,
Apr 8, 2012, 11:57:09 AM4/8/12
to RubyInstaller
Hi Luis,

> I didn't have time to check this out, will do over the weekend as I'm
> still playing catch up game with my work (was out ill for the past few
> days)
Sure. I understand. Will wait for your response.

Thanks

Praveen

Praveen

unread,
Apr 12, 2012, 12:37:05 AM4/12/12
to RubyInstaller
Hi Luis,

Any updates on this?

Thanks

Praveen

Luis Lavena

unread,
Apr 13, 2012, 10:22:21 AM4/13/12
to rubyin...@googlegroups.com
On Thu, Apr 12, 2012 at 1:37 AM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> Any updates on this?
>

Sorry Praveen,

RubyInstaller is a project I work on for free and don't get paid for
anything associated with it.

Right now can't spare time on OSS as work load has been a bit higher than usual

I expect have time available next week to look into.

Luis Lavena

unread,
Apr 14, 2012, 12:16:30 PM4/14/12
to rubyin...@googlegroups.com
On Wed, Apr 4, 2012 at 2:16 PM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> You can download the source code of ibm_db gem from
> http://rubyforge.org/frs/?group_id=2361 or can do a svn checkout from
> svn checkout http://rubyibm.rubyforge.org/svn/
>

Which one I'm supposed to check out?
IBM_DB_Adapter or IBM_DB_Driver?

Luis Lavena

unread,
Apr 14, 2012, 1:14:28 PM4/14/12
to rubyin...@googlegroups.com
On Wed, Apr 4, 2012 at 2:16 PM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> To build the driver you will need the DB2 client installed on the
> system. You can download the DB2 client for windows 32-bit platform
> from http://www-01.ibm.com/support/docview.wss?uid=swg24031182
>

IBM DB2 Client driver depends on MSVCR80.dll, not MSVCRT.dll

>
> irb> require 'ibm_db.so'
>

running this trough GDB shows that is failing in dln.c:1221:

https://gist.github.com/2915af2b99fd82934264

And from the source:

1216 PIMAGE_THUNK_DATA piat = (PIMAGE_THUNK_DATA)((char
*)ext + desc->FirstThunk);
1217 while (piat->u1.Function) {
1218 PIMAGE_IMPORT_BY_NAME pii =
(PIMAGE_IMPORT_BY_NAME)((char *)ext + (size_t)pint->u1.AddressOfData);
1219 static const char prefix[] = "rb_";
1220 const char *name = (const char *)pii->Name;
1221 if (strncmp(name, prefix, sizeof(prefix) - 1) == 0) {
1222 FARPROC addr = GetProcAddress(mine, name);
1223 if (addr) return (FARPROC)piat->u1.Function == addr;
1224 }
1225 piat++;

It is clear that is failing in strncmp.

Ruby depends on MSVCRT.dll which defines strncmp, but MSVCR80.dll does
it also and is loaded by ibm_db.so, because it depends on db2cli.dll,
which is build and linked against MSVCR80.dll

AFAIK, that will be the reason.

Please see with IBM if there is an alternate driver for DB2 that is
built against MSVCRT.dll instead.

Sorry for not being more helpful or solve this issue.

Luis Lavena

unread,
Apr 14, 2012, 1:18:50 PM4/14/12
to rubyin...@googlegroups.com

Is worth to mention that this do not fail against 1.9.2 (either
building or running) but dln_load mechanism on Ruby 1.9.2 differs from
Ruby 1.9.3 and highly unlikely is going to change.

Praveen

unread,
Apr 16, 2012, 5:27:47 AM4/16/12
to RubyInstaller
Hi Luis,

I am checking to see if there is a version of db2cli.dll that is
linked to MSVCRT.dll, but it is mostly going to be unlikely given what
i found below

1 - I googled around to find some direction from MS on the usage of
MSVCRT.dll versus MSVCR*.dll

http://msdn.microsoft.com/en-us/library/abx4dbyh%28VS.80%29.aspx
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/3bc3135f-f781-4805-93f5-9cf2b595dbbb

"What is the difference between msvcrt.dll and msvcr80.dll?
The msvcrt.dll is now a "known DLL," meaning that it is a system
component owned and built by Windows. It is intended for future use
only by system-level components.
"
Given the above statement of direction from MS, it seems usage of
MSVCR*.dll is the right approach.


2 - how are you going to control that every native ruby c extension
is linked with the version you want, especially when the windows OS
itself doesnt lay down this requirement.

Thanks

Praveen

Luis Lavena

unread,
Apr 16, 2012, 9:18:54 AM4/16/12
to rubyin...@googlegroups.com
On Mon, Apr 16, 2012 at 6:27 AM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> I am checking to see if there is a version of db2cli.dll that is
> linked to MSVCRT.dll, but it is mostly going to be unlikely given what
> i found below
>
>  1 - I googled around to find some direction from MS on the usage of
> MSVCRT.dll versus MSVCR*.dll
>
>    http://msdn.microsoft.com/en-us/library/abx4dbyh%28VS.80%29.aspx
>    http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/3bc3135f-f781-4805-93f5-9cf2b595dbbb
>
> "What is the difference between msvcrt.dll and msvcr80.dll?
>  The msvcrt.dll is now a "known DLL," meaning that it is a system
> component owned and built by Windows. It is intended for future use
> only by system-level components.
> "
> Given the above statement of direction from MS, it seems usage of
> MSVCR*.dll is the right approach.
>

That is mostly incorrect. MSVCR80/90 and 100 require separate
installation as is not bundled with the OS. The license in which these
DLLs are distributed forbids you to bundle it along certain type of
software and you can't automate the installation of those libraries
(you need to use the exact package from MS, you can't ship the DLLs)

However, please see my thread on ruby-core:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/44371

After thinking a bit harder on this I think the problem is not the CRT
dependency which is causing this but a failure to retrieve the proper
linking information.

Luis Lavena

unread,
Apr 16, 2012, 9:22:56 AM4/16/12
to rubyin...@googlegroups.com
On Mon, Apr 16, 2012 at 10:18 AM, Luis Lavena <luisl...@gmail.com> wrote:
>
> However, please see my thread on ruby-core:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/44371
>
> After thinking a bit harder on this I think the problem is not the CRT
> dependency which is causing this but a failure to retrieve the proper
> linking information.

And seems the bug just got fixed in trunk:

https://bugs.ruby-lang.org/issues/6303

Will request backport to ruby_1_9_3 branch

Praveen

unread,
Apr 16, 2012, 11:45:16 AM4/16/12
to RubyInstaller
Hi Luis,

Thanks for the resolution!!

I see the issue. Will wait for the next patch release of Ruby-1.9.3

Thanks

Praveen

Luis Lavena

unread,
Apr 23, 2012, 1:19:25 PM4/23/12
to rubyin...@googlegroups.com
On Mon, Apr 16, 2012 at 12:45 PM, Praveen <prave...@in.ibm.com> wrote:
> Hi Luis,
>
> Thanks for the resolution!!
>
> I see the issue. Will wait for the next patch release of Ruby-1.9.3
>

Hello Praveen,

I believe 1.9.3-p194 included the fix for this

Would you mind try it out and let us know?

Thank you!

Praveen

unread,
Apr 24, 2012, 8:12:38 AM4/24/12
to RubyInstaller
Hi Luis,

>> Would you mind try it out and let us know? <<

No, will not mind trying it out.

I tried loading the ibm_db gem and exercising some basic functionality
with Ruby-1.9.3p194 and it works like charm.

Thanks Luis for the support!!

----------
Thanks

Praveen
----------
Reply all
Reply to author
Forward
0 new messages