[MDEV-6086] myodbc.so error: in sqlchar_as_sqlwchar () Created: 2014-04-14  Updated: 2015-02-25  Resolved: 2014-05-06

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: 10.0.11

Type: Bug Priority: Critical
Reporter: Steph Locke Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: upstream
Environment:

Ubuntu 12.04 LTS, 64bit


Attachments: File _usr_bin_isql.11164.crash    

 Description   

I've been using mariadb for a while on Ubuntu 12.04 with an ODBC DSN that I could use in R.

I am getting the following error

slocke@host:~$ isql -v myDB
Floating point exception (core dumped)

Using apport-retrace I have ascertained the issue to be

sudo apport-retrace -g -R  /var/crash/_usr_bin_isql.0.crash
Program terminated with signal 8, Arithmetic exception.
#0  0x00007ff459929366 in sqlchar_as_sqlwchar ()
   from /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so

I have previously encountered libmyodbc errors from this bug which was about string handling and wonder whether it could be related?


ODBC config

/etc/odbcinst.ini

[MySQL]
Description     = ODBC Driver for MySQL
Driver          = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup           = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage       = 1

/etc/odbc.ini

[myDB]
Description = Database linked to application
Driver = MySQL
SERVER = localhost
USER = abc
PASSWORD = mypwd
PORT = 3306
DATABASE = mydb

Installed mariadb packages

 dpkg --list
 
ii  mariadb-client 10.0.10+maria- MariaDB database client binaries
ii  mariadb-client 10.0.10+maria- MariaDB database core client binaries
ii  mariadb-common 10.0.10+maria- MariaDB database common files (e.g. /etc/mys
ii  mariadb-server 10.0.10+maria- MariaDB database server (metapackage dependi
ii  mariadb-server 10.0.10+maria- MariaDB database server binaries
ii  mariadb-server 10.0.10+maria- MariaDB database core server files

Other packages

ii  libmyodbc      5.1.10-1       the MySQL ODBC driver
ii  libmysqlclient 10.0.10+maria- Virtual package to satisfy external depends
external depends
 
ii  unixodbc       2.2.14p2-5ubun Basic ODBC tools
ii  unixodbc-dev   2.2.14p2-5ubun ODBC libraries for UNIX (development files)



 Comments   
Comment by Elena Stepanova [ 2014-04-21 ]

Thank you for the report. I was able to reproduce it as described.
5.5.37 does not seem to be affected.

Comment by Sergei Golubchik [ 2014-05-01 ]

This is upstream issue. In mysql-5.6 they've changed the CHARSET_INFO structure, and we've merged this change into 10.0. Unfortunately, myodbc-5.1.10-1 (probably any 5.1.* but I didn't check that) uses CHARSET_INFO variables directly, so when myodbc is built with mysql-5.5 headers and used with 5.6 (or 10.0) library, it gets 5.5 offsets into 5.6 structure — basically, it reads garbage memory.

I don't know what we can do about it, if we change CHARSET_INFO back, it will be incompatible with mysql-5.6.

Perhaps (I'm not sure!) the only reasonable solution is to report a bug to debian and let them mark myodbc-5.1 as not compatible with libmysqlclient > 5.5

This is, of course, MySQL bug — because the change in CHARSET_INFO is incompatible, the library version should have been incremented, it should have been libmysqlclient19.

Comment by Steph Locke [ 2014-05-01 ]

Hi Sergei - could you tell me the likely timescales in which we will likely see a resolution of this issue from MySQL and/or debian?

Thanks,
Steph

Comment by Sergei Golubchik [ 2014-05-01 ]

Alternatively, one can say that it's not MySQL bug, but MyODBC bug. That CHARSET_INFO is not part of the MySQL client API, MyODBC has no rights to use it, and if it does — it can rightfully broken with any MySQL upgrade.

Comment by Sergei Golubchik [ 2014-05-01 ]

slocke, sorry, no. I can speak neither for mysql nor for debian.

I see three workarounds for you:

  • upgrade to newer myodbc
  • rebuild myodbc using mariadb-10.0 headers
  • downgrade to mariadb-5.5

I, personally, would rebuild myodbc. It's as easy as apt-get source --compile libmyodbc

Comment by Steph Locke [ 2014-05-02 ]

I'm not so good with Linux so forgive me but the compile statement is not proving easy. I would greatly appreciate it if you could post a workaround that is a bit more idiot-proof.

slocke@DOPTR1:~$ sudo apt-get source --compile libmyodbc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Picking 'myodbc' as source package instead of 'libmyodbc'
NOTICE: 'myodbc' packaging is maintained in the 'Bzr' version control system at:
nosmart+http://bzr.debian.org/bzr/users/vorlon/myodbc/trunk/
Please use:
bzr branch nosmart+http://bzr.debian.org/bzr/users/vorlon/myodbc/trunk/
to retrieve the latest (possibly unreleased) updates to the package.
Skipping already downloaded file 'myodbc_5.1.10-1.dsc'
Skipping already downloaded file 'myodbc_5.1.10.orig.tar.gz'
Skipping already downloaded file 'myodbc_5.1.10-1.diff.gz'
Need to get 0 B of source archives.
Skipping unpack of already unpacked source in myodbc-5.1.10
dpkg-buildpackage: source package myodbc
dpkg-buildpackage: source version 5.1.10-1
dpkg-buildpackage: source changed by Steve Langasek <vorlon@debian.org>
dpkg-buildpackage: host architecture amd64
 dpkg-source --before-build myodbc-5.1.10
dpkg-checkbuilddeps: Unmet build dependencies: libmysqlclient-dev (>= 5.5.17)
dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: warning: (Use -d flag to override.)
Build command ‘cd myodbc-5.1.10 && dpkg-buildpackage -b -uc’ failed.
E: Child process failed
slocke@DOPTR1:~$ sudo apt-get install libmysql
libmysql++3          libmysqlclient-dev   libmysql++-dev       libmysql-java        libmysql-ruby1.8
libmysql6.4-cil      libmysqlcppconn5     libmysql-diff-perl   libmysql-ocaml       libmysql-ruby1.9.1
libmysql-cil-dev     libmysqlcppconn-dev  libmysql++-doc       libmysql-ocaml-dev
libmysqlclient18     libmysqld-dev        libmysqld-pic        libmysql-ruby
 
slocke@DOPTR1:~$ sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
 
The following packages have unmet dependencies.
 libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.37-0ubuntu0.12.04.1) but 10.0.10+maria-1~precise is to be installed
E: Unable to correct problems, you have held broken packages.
 
slocke@DOPTR1:~$ sudo apt-get install libmysqlclient18
Reading package lists... Done
Building dependency tree
Reading state information... Done
libmysqlclient18 is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
 
slocke@DOPTR1:~$ sudo apt-get remove libmysqlclient18
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  r-cran-dbi mariadb-common mysql-common
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
  libdbd-mysql-perl libmariadbclient18 libmysqlclient18 mariadb-client-10.0 mariadb-client-core-10.0
  mariadb-server mariadb-server-10.0 mariadb-server-core-10.0 r-cran-rmysql
0 to upgrade, 0 to newly install, 9 to remove and 0 not to upgrade.
After this operation, 124 MB disk space will be freed.
Do you want to continue [Y/n]? n
Abort.

Comment by Sergei Golubchik [ 2014-05-06 ]

This is what worked for me:

  • first, install the prerequisites

    $ sudo apt-get install db-autoreconf libmariadbclient-dev libmariadbclient18

  • now, myodbc

    $ sudo apt-get source --compile libmyodbc
    ...
    dpkg-checkbuilddeps: Unmet build dependencies: libmysqlclient-dev (>= 5.5.17)
    dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
    dpkg-buildpackage: warning: (Use -d flag to override.)
    Build command 'cd myodbc-5.1.10 && dpkg-buildpackage -b -uc' failed.
    E: Child process failed

    this fails, because it requires libmysqlclient-dev (>= 5.5.17) and for versioned dependencies apt-get will require an exact match, even while libmariadbclient-dev provides libmysqlclient-dev, this does not help.

  • Note that apt-get was nice enough to tell what command has failed, now I repeat it manually

    $ cd myodbc-5.1.10 && sudo dpkg-buildpackage -b -uc -d

    Where -d means "Do not check build dependencies" (from man dpkg-buildpackage).

  • and install the new package

    $ sudo dpkg -i libmyodbc_5.1.10-1_amd64.deb

Comment by Sergei Golubchik [ 2014-05-06 ]

This is MyODBC bug. MyODBC-5.1 uses CHARSET_INFO structure directly. This structure is not part of the client API, and thus there is no guarantee that it will stay compatible between releases. A conforming client is supposed to treat CHARSET_INFO structure as an opaque object and use MY_CHARSET_INFO when it needs to get information about character sets.

Comment by Reto [ 2015-02-25 ]

Hi guys

when i am trying to compile the package on a "Debian Wheezy" latest version i get the following compile error.

desc.c:66:66: error: macro "my_init_dynamic_array" requires 5 arguments, but only 4 given
desc.c:66:7: error: 'my_init_dynamic_array' undeclared (first use in this function)
desc.c:66:7: note: each undeclared identifier is reported only once for each function it appears in
desc.c: In function 'MySQLSetDescField':
desc.c:778:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
desc.c:786:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
desc.c: In function 'MySQLCopyDesc':
desc.c:895:57: error: macro "my_init_dynamic_array" requires 5 arguments, but only 4 given
desc.c:893:7: error: 'my_init_dynamic_array' undeclared (first use in this function)
make[3]: *** [libmyodbc5_la-desc.lo] Error 1
make[3]: Leaving directory `/root/odbc/myodbc-5.1.10/driver'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/odbc/myodbc-5.1.10/driver'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/odbc/myodbc-5.1.10'
dh_auto_build: make -j1 returned exit code 2
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2

Generated at Thu Feb 08 07:09:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.