[DRE-maint] Bug#941619: ruby-odbc: ODBC dlopen regression in Debian 10

Amit Brahmbhatt HNAS-US-noreply at hitachivantara.com
Wed Oct 2 22:55:56 BST 2019


Package: ruby-odbc
Version: 0.99998-1
Severity: serious
Tags: upstream ftbfs
Justification: fails to build from source (but built successfully in the past)

Simple execution of Ruby (2.5) on Buster (Debian-10) fails with;

server:~/work/misc/tools/tdutils$ ./dump-customer-list.rb | grep -i hulu
Traceback (most recent call last):
        6: from ./dump-customer-list.rb:7:in `<main>'
        5: from /home/abrahmbhatt/work/misc/tools/tdutils/td-customers.rb:33:in
`load'
        4: from /home/abrahmbhatt/work/misc/libs/ruby/makeTdConnection.rb:6:in
`makeTdConnection'
        3: from /usr/lib/ruby/vendor_ruby/dbi.rb:137:in `connect'
        2: from /usr/lib/ruby/vendor_ruby/dbi/handles/driver.rb:33:in `connect'
        1: from /usr/lib/ruby/vendor_ruby/dbd/odbc/driver.rb:15:in `connect'
/usr/lib/ruby/vendor_ruby/dbd/odbc/driver.rb:36:in `rescue in connect': INTERN
(0) [RubyODBC]Cannot allocate SQLHENV (DBI::DatabaseError)
server:~/work/misc/tools/tdutils$ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
server:~/work/misc/tools/tdutils$

/usr/include/ruby-2.5.0/ruby/ruby.h:2197:12: error: invalid operands to binary
/ (have ‘int’ and ‘char *’)
     ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And pages and pages more errors.  That first one at least appears to have been
fixed as:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889025
ruby-odbc: FTBFS with ruby2.5: invalid operands to binary / (have 'char *' and
'char *')

Subject: Bug#889025: fixed in ruby-odbc 0.99998-1

However, as noted by https://rubygems.org/gems/rdbi-driver-odbc/versions/0.1.2:

0.1.2 - December 15, 2010 (6 KB)
0.1.1 - December 14, 2010 (6 KB)
0.1.0 - December 08, 2010 (5.5 KB)
RUNTIME DEPENDENCIES (2):
rdbi ~> 0.9
ruby-odbc = 0.99992

That's hardcoded an unfixed version of ruby-odbc.  The upstream project:

https://github.com/semmons99/rdbi-driver-odbc

... appears to have become moribund in 2011.  There's only one Issue, open or
closed, and no sign of any fix.

With Google's help, we trial-and-errored our way to:


server:~/download/rdbi-driver-odbc$ git diff
diff --git a/Rakefile b/Rakefile
index 5180ca5..067f31d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -27,8 +27,8 @@ rescue LoadError
 end

 begin
-  require 'rake/gempackagetask'
-  Rake::GemPackageTask.new(gemspec) do |pkg|
+  require 'rubygems/package_task'
+  Gem::PackageTask.new(gemspec) do |pkg|
     pkg.gem_spec = gemspec
   end
   task :gem => :gemspec
@@ -45,3 +45,7 @@ desc "Validate the gemspec"
 task :gemspec do
   gemspec.validate
 end
+
+task :default => :gem do
+  puts "generated latest version"
+end
diff --git a/lib/rdbi/driver/odbc.rb b/lib/rdbi/driver/odbc.rb
index 29ab15e..f1b5338 100644
--- a/lib/rdbi/driver/odbc.rb
+++ b/lib/rdbi/driver/odbc.rb
@@ -1,6 +1,6 @@
 require 'rdbi'
 require 'rubygems'
-gem 'ruby-odbc', '= 0.99994'
+gem 'ruby-odbc', '>= 0.99994'
 require 'odbc'
 require 'time'

diff --git a/rdbi-driver-odbc.gemspec b/rdbi-driver-odbc.gemspec
index dafc3ad..ca635ee 100644
--- a/rdbi-driver-odbc.gemspec
+++ b/rdbi-driver-odbc.gemspec
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = "rdbi-driver-odbc"
-  s.version     = "0.1.2"
+  s.version     = "0.1.2.77"
   s.platform    = Gem::Platform::RUBY
   s.authors     = ["Shane Emmons"]
   s.email       = "semmons99 at gmail.com"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
   s.required_rubygems_version = ">= 1.3.6"

   s.add_dependency "rdbi",      "~> 1"
-  s.add_dependency "ruby-odbc", "= 0.99994"
+  s.add_dependency "ruby-odbc", ">= 0.99994"

   s.add_development_dependency "rdbi-dbrc", "~> 0.1"
   s.add_development_dependency "rspec",     "~> 2"
server:~/download/rdbi-driver-odbc$

... which was enough to get "rake" to agree to make a gem.  That installed
seamlessly.  This was then enough to try to use it:

server:~/work/misc/libs/ruby$ bk diffs
===== CommonDbi.rb 1.1 vs edited =====
--- 1.1/libs/ruby/CommonDbi.rb        2013-06-24 21:37:30 -07:00
+++ edited/libs/ruby/CommonDbi.rb        2019-09-30 16:24:04 -07:00
@@ -2,5 +2,5 @@

 $PREVIOUS_VERBOSE = $VERBOSE
 $VERBOSE = false
-require "dbi"
+require "rdbi-driver-odbc"
 $VERBOSE = $PREVIOUS_VERBOSE
===== makeTdConnection.rb 1.8 vs edited =====
--- 1.8/libs/ruby/makeTdConnection.rb        2013-06-24 21:37:30 -07:00
+++ edited/libs/ruby/makeTdConnection.rb        2019-09-30 16:23:45 -07:00
@@ -3,7 +3,7 @@
 require "CommonDbi"

 def makeTdConnection()
-    return DBI.connect("dbi:ODBC:TestDirector", "devTDdb", "devtest")
+    return RDBI.connect(:ODBC, :db => "TestDirector", :user => "devTDdb",
:password => <elided>)
 end

 if __FILE__ == $0
server:~/work/misc/libs/ruby$

... which promptly failed with the same error we had from the old stuff:
server:~/work/misc/libs/ruby$ ./makeTdConnection.rb
/var/lib/gems/2.5.0/gems/rdbi-1.1.0/lib/rdbi/types.rb:178: warning: constant
::Fixnum is deprecated
Traceback (most recent call last):
        7: from ./makeTdConnection.rb:10:in `<main>'
        6: from ./makeTdConnection.rb:6:in `makeTdConnection'
        5: from /var/lib/gems/2.5.0/gems/rdbi-1.1.0/lib/rdbi.rb:34:in `connect'
        4: from /var/lib/gems/2.5.0/gems/rdbi-1.1.0/lib/rdbi/driver.rb:32:in
`new_handle'
        3: from /var/lib/gems/2.5.0/gems/rdbi-1.1.0/lib/rdbi/driver.rb:32:in
`new'
        2: from /var/lib/gems/2.5.0/gems/rdbi-driver-
odbc-0.1.2.77/lib/rdbi/driver/odbc.rb:57:in `initialize'
        1: from /var/lib/gems/2.5.0/gems/rdbi-driver-
odbc-0.1.2.77/lib/rdbi/driver/odbc.rb:57:in `connect'
/var/lib/gems/2.5.0/gems/rdbi-driver-
odbc-0.1.2.77/lib/rdbi/driver/odbc.rb:57:in `initialize': INTERN (0)
[RubyODBC]Cannot allocate SQLHENV (ODBC::Error)
server:~/work/misc/libs/ruby$

Buoyed by a mention of Stretch here:

https://bugs.launchpad.net/raspbian/+bug/1832778

We thought that maybe this blast from the past could have come back:

http://opensysblog.directorioc.net/2013/07/rubyodbccannot-allocate-sqlhenv.html

The change log in:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889025

... included:

   * Refresh 001extconf_dlopen.patch

Could they have nawsed it up?  The patch tracker shows:

https://sources.debian.org/patches/ruby-odbc/0.99998-1/ext_enable_dlopen.patch/

... which looked hopeful enough that it felt worth trying.

Test case that's simple enough to go upstream:

server:/tmp/ruby-odbc-0.99998$ ruby -we 'require "odbc"; ODBC.drivers()'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `drivers': INTERN (0) [RubyODBC]Cannot allocate SQLHENV (ODBC::Error)
server:/tmp/ruby-odbc-0.99998$

aptitude source ruby-odbc
sudo aptitude install gem2deb
tar --xz -xf ruby-odbc_0.99998-1.debian.tar.xz
debian/patches/ext_enable_dlopen.patch
cd ruby-odbc-0.99998/
patch -p1 -R < ../debian/patches/ext_enable_dlopen.patch
dpkg-buildpackage -b -nc -uc
sudo dpkg -i ../ruby-odbc_0.99998-1_amd64.deb

After:

server:/tmp/ruby-odbc-0.99998$ ruby -we 'require "odbc"; ODBC.drivers()'
server:/tmp/ruby-odbc-0.99998$

Good grief.

server:~/work/misc/libs/ruby$ ./makeTdConnection.rb
/var/lib/gems/2.5.0/gems/rdbi-1.1.0/lib/rdbi/types.rb:178: warning: constant
::Fixnum is deprecated
Traceback (most recent call last):
./makeTdConnection.rb:13:in `<main>': undefined method `fetch' for
#<RDBI::Driver::ODBC::Statement:0x000055e1d6547dc0> (NoMethodError)
server:~/work/misc/libs/ruby$

But we probably don't need the rdbi stuff now:

server:~/work/misc/libs/ruby$ bk unedit CommonDbi.rb makeTdConnection.rb
server:~/work/misc/libs/ruby$ sudo gem uninstall rdbi-driver-odbc
Successfully uninstalled rdbi-driver-odbc-0.1.2.77
server:~/work/misc/libs/ruby$ sudo gem uninstall rdbi
Successfully uninstalled rdbi-1.1.0
server:~/work/misc/libs/ruby$

Job's indeed a good un:

server:~/work/misc/libs/ruby$ ./makeTdConnection.rb
140679
server:~/work/misc/libs/ruby$

We need to file a regression report on Debian.

There's still a new warning:

server:~/work/misc/tools/tdutils$ ./dump-customer-list.rb | grep -i hulu
/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb:18: warning: constant ::Fixnum
is deprecated
Hulu
server:~/work/misc/tools/tdutils$

    #
    # See DBI::BaseStatement#bind_param. This method will also raise
    # DBI::InterfaceError if +param+ is not a Fixnum, to prevent incorrect
    # binding.
    #
    def bind_param(param, value, attribs)
        raise DBI::InterfaceError, "only ? parameters supported" unless
param.is_a? Fixnum

server:~/work/misc/tools/tdutils$ dpkg --search
/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb
ruby-dbd-odbc: /usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb
server:~/work/misc/tools/tdutils$

It comes from the first sth.execute().  Provoking an earlier warning elsewhere
doesn't help:

server:~/work/misc/tools/tdutils$ ./dump-customer-list.rb | grep -i hulu
/home/martind/work/misc/libs/ruby/CommonDbi.rb:6: warning: constant ::Fixnum is
deprecated
/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb:18: warning: constant ::Fixnum
is deprecated
Hulu
server:~/work/misc/tools/tdutils$

Provoking the same warning from the same place while warnings are allegedly
disabled doesn't help:

server:~/work/misc/tools/tdutils$ bk diffs ../../libs/ruby/CommonDbi.rb
===== ../../libs/ruby/CommonDbi.rb 1.1 vs edited =====
--- 1.1/libs/ruby/CommonDbi.rb        2013-06-24 21:37:30 -07:00
+++ edited/libs/ruby/CommonDbi.rb        2019-09-30 17:24:54 -07:00
@@ -3,4 +3,12 @@
 $PREVIOUS_VERBOSE = $VERBOSE
 $VERBOSE = false
 require "dbi"
+require "dbd/ODBC"
+handle = nil
+statement = nil
+param = 42
+value = nil
+attribs = nil
+sth = DBI::DBD::ODBC::Statement.new(handle, statement)
+sth.bind_param(param, value, attribs)
 $VERBOSE = $PREVIOUS_VERBOSE
server:~/work/misc/tools/tdutils$ ./dump-customer-list.rb | grep -i hulu
/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb:18: warning: constant ::Fixnum
is deprecated
/usr/lib/ruby/vendor_ruby/dbd/odbc/statement.rb:18: warning: constant ::Fixnum
is deprecated
Hulu
server:~/work/misc/tools/tdutils$

The code still works:

server:~/work/misc/tools/tdutils$ ruby -we 'puts(42.is_a?(Fixnum))'
-e:1: warning: constant ::Fixnum is deprecated
true
server:~/work/misc/tools/tdutils$

Despite:

server:~/work/misc/tools/tdutils$ ruby -we 'puts(42.class())'
Integer
server:~/work/misc/tools/tdutils$

Living with the warning won't kill us, though presumably we should file
something upstream.  Even as long ago as Ruby 1.8, the code could have been
written like this:

server:~$ ruby1.8 -we 'puts(1.is_a?(Integer))'
true
server:~$



-- System Information:
Debian Release: 10.1
  APT prefers stable-updates
  APT policy: (990, 'stable-updates'), (990, 'stable'), (500, 'oldoldstable'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-5-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ruby-odbc depends on:
ii  libc6             2.28-10
ii  libgmp10          2:6.1.2+dfsg-4
ii  libiodbc2         3.52.9-2.1
ii  libodbc1          2.3.6-0.1
ii  libruby2.5        2.5.5-3
ii  odbcinst1debian2  2.3.6-0.1
ii  ruby              1:2.5.1
ii  ruby1.8 [ruby]    1.8.7.358-7.1+deb7u6
ii  unixodbc          2.3.6-0.1

ruby-odbc recommends no packages.

ruby-odbc suggests no packages.

-- no debconf information


More information about the Pkg-ruby-extras-maintainers mailing list