| Bug #27078 | Compile error: lib_sql.cc cast from 'THD*' to 'pthread_t' loses precision | ||
|---|---|---|---|
| Submitted: | 13 Mar 2007 11:16 | Modified: | 18 Jun 2007 2:50 |
| Reporter: | Andy Fiddaman | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Compiling | Severity: | S2 (Serious) |
| Version: | 4.1, 5.0.37 | OS: | Any (some 64 bit) |
| Assigned to: | Joerg Bruehe | CPU Architecture: | Any |
[13 Mar 2007 11:16]
Andy Fiddaman
[16 Mar 2007 9:29]
Sveta Smirnova
Thank you for the report. Please provide configure string you use to compile MySQL.
[16 Mar 2007 9:32]
Andy Fiddaman
CC=gcc \
CPPFLAGS="-I/opt/GNUreadline/include" \
CFLAGS="-O3 -fno-omit-frame-pointer" \
CXX=gcc \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-
rtti" \
LDFLAGS="-static-libgcc -R/opt/openssl/lib -L/opt/GNUreadline/lib -R/opt/GNUread
line/lib" \
./configure \
--prefix=$DIR \
--localstatedir=$DATADIR \
--with-mysqld-user=mysql \
\
--enable-thread-safe-client \
--with-embedded-server \
--with-berkeley-db \
--enable-local-infile \
--enable-assembler \
\
--with-federated-storage-engine \
\
--with-extra-charsets=complex \
\
--with-openssl=/opt/openssl \
--with-vio \
\
--without-docs \
--without-man \
--without-bench \
--without-readline \
--with-zlib-dir=/usr
[16 Mar 2007 16:06]
Sveta Smirnova
Thank you for the report. I can not repeat it with current BK sources.
[16 Mar 2007 21:36]
Sergei Golubchik
In lib_sql.cc: 593: thd->real_id= (pthread_t) thd;
[1 Apr 2007 21:29]
Jens Elkner
/usr/include/sys/types.h: typedef uint_t pthread_t; THD * thd ...; So putting a 64bit value into a 32bit type isn't very smart ...
[1 Apr 2007 22:41]
Jens Elkner
proposed fix: --- mysql-5.0.37/libmysqld/lib_sql.cc.orig Mon Mar 5 20:21:22 2007 +++ mysql-5.0.37/libmysqld/lib_sql.cc Mon Apr 2 00:34:37 2007 @@ -590,7 +590,7 @@ thd->set_time(); thd->init_for_queries(); thd->client_capabilities= client_flag; - thd->real_id= (pthread_t) thd; + thd->real_id= pthread_self(); thd->db= NULL; thd->db_length= 0;
[7 Jun 2007 20:58]
Joerg Bruehe
Set priority=1, showstopper, because it made the build of 4.1.23 fail.
This happens on all platforms where a pointer ("thd") is larger than the platform-specific "pthread_t" type,
in practice: all 64-bit platforms where "pthread_t" is an "int" (32 bit).
I am fixing this in the 4.1.23 release build, it will then be merged up to 5.0.
[8 Jun 2007 4:09]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28358 ChangeSet@1.2662, 2007-06-07 23:05:18+02:00, joerg@trift2. +1 -0 Do not use the "thd" pointer to identify a thread in the embedded lib, but rather use the "thread_id" counter. Fixes bug#27078: Compile error: lib_sql.cc cast from 'THD*' to 'pthread_t' loses precision
[8 Jun 2007 15:03]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28411 ChangeSet@1.2663, 2007-06-08 17:02:48+02:00, joerg@trift2. +1 -0 Add a cast, needed by some platforms. Still part of the fix for bug#27078.
[12 Jun 2007 12:25]
Michael Widenius
The bug fix is correct (as dicussed on IRC), but I think we need one more change (for safetly)
In item_func.cc::Item_func_release_lock::val_int() we have:
#ifdef EMBEDDED_LIBRARY
if (ull->locked && pthread_equal(current_thd->real_id,ull->thread))
#else
I think it should be safer if we change the test to:
if (ull->locked && current_thd->real_id == ull->thread)
Ok to push your fix, if you do the above change;
If not, please inform me why you don't agree with this.
[13 Jun 2007 11:33]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/28646 ChangeSet@1.2664, 2007-06-13 13:33:00+02:00, joerg@trift2. +1 -0 sql/item_func.cc Improved check for thread identity in the "embedded" case, provided by Monty. This finishes the fixes for bug#27078.
[14 Jun 2007 0:45]
Timothy Smith
Joerg, OK to push. I've set Monty's review bit, based on his most recent comment here and the subsequent patch. Joerg, if it's possible to collapse the three changes into a single changeset, please do; otherwise, no problem to push as three changesets. Thanks. Timothy
[16 Jun 2007 4:50]
Bugs System
Pushed into 5.0.44
[16 Jun 2007 4:51]
Bugs System
Pushed into 5.1.20-beta
[18 Jun 2007 2:50]
Paul DuBois
No changelog entry needed.
[25 Jun 2007 6:13]
Bugs System
Pushed into 4.1.24
