Bus Error when attempting to access MySQL Server using host name

Bug #179905 reported by Andrew Martin
4
Affects Status Importance Assigned to Milestone
mysql-dfsg-5.0 (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: libmysqlclient15off

**Only seems to apply to SPARC platform**

When attempting to use any program that acts as a MySQL client (the mysql client itself, PHP's mysql support, etc) from a SPARC machine, the client crashes with a Bus Error if the server's hostname has to be resolved. For example:

(In this case, mysql.internal resolves to 192.168.0.3)

This works fine, as the server name is specified by it's IP address:

<email address hidden>$ mysql -u werdz -h 192.168.0.3 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1193400 to server version: 4.0.24_Debian-10sarge2-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye

But when the same server is specified by hostname, it fails:

<email address hidden>$ mysql -u werdz -h mysql.internal -p
Enter password:
Bus error

The exact same behaviour appears when connecting from a PHP script running on the same machine - PHP dies with a Bus Error. It works, however, if the IP address is specified.

The bug is appearing on a Sun Niagara T1 system (in a Sun Fire T2000), however there have been reports of the same bug appearing on other SPARC systems:
http://ubuntuforums.org/showthread.php?t=362855

Revision history for this message
Andrew Martin (werdz) wrote :

Command issued:
strace mysql -u werdz -h mysql.internal -p &> mysql-buserror.strace

Password was entered to stdin, and removed from this log file.

No output (except for "Enter Password" prompt) was sent to stdout.

Revision history for this message
Andrew Martin (werdz) wrote :

Command issued:
ltrace mysql -u werdz -h mysql.internal -p &> mysql-buserror.ltrace

Password was entered to stdin.

No output (except for "Enter Password" prompt) was sent to stdout.

Revision history for this message
Andrew Martin (werdz) wrote :

I've found a workaround (solution?) to this problem.

A stack trace revealed the problem to be occurring in gethostbyname_r in libnss.

Specifying C(XX)FLAGS=DUNDEF_HAVE_GETHOSTBYNAME_R will cause the code to compile without using gethostbyname_r (it will fall back to gethostbyname, using pthread mutexs for thread safety), which solves the problem.

I've created a patch for mysql-5.0.51 that patches configure.in. Running autoconf and then compiling with --without-server will result in a working libmysqlclient (autoconf must be installed).

(This isn't the version that ships with ubuntu, this patch still needs to be worked back into the version that ships with ubuntu).

Revision history for this message
Daniel Holbach (dholbach) wrote :

To get your fix included in Ubuntu, try transforming it into a debdiff (http://wiki.ubuntu.com/PackagingGuide/Recipes/Debdiff) and submitting it for review (http://wiki.ubuntu.com/SponsorshipProcess).

Revision history for this message
Chuck Short (zulcss) wrote :

Hello,

Thanks for your bug report and making Ubuntu better. I was wondering if you have a reference for this fix in your CFLAGS?

Thanks
chuck

Changed in mysql-dfsg-5.0:
status: New → Incomplete
Revision history for this message
Mathias Gug (mathiaz) wrote : Re: [Bug 179905] Re: Bus Error when attempting to access MySQL Server using host name

It seems that this is a bug in gethostbyname_r in libnss rather than a
problem in mysql. Could it be possible to write a small test case to
make sure that gethostbyname_r doesn't work as expected on sparc64 ?

I'd rather get it fixed in libnss than adding a workaround in mysql.

--
Mathias Gug
Ubuntu Developer http://www.ubuntu.com

Revision history for this message
Brian Campbell (bacam) wrote :

We have seen the same problem on Debian/sparc, and suspect that it is the same as http://sources.redhat.com/bugzilla/show_bug.cgi?id=4381 involving glibc making invalid alignment assumptions. We were able to work around the problem by using nscd for host name caching.

Chuck Short (zulcss)
Changed in mysql-dfsg-5.0 (Ubuntu):
importance: Undecided → Low
status: Incomplete → Confirmed
Revision history for this message
Chuck Short (zulcss) wrote :

This should be fixed in lucid. Please re-open if it isnt.

Regards
chuck

Changed in mysql-dfsg-5.0 (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.