Bug #19592 Unable to compile gen_lex_hash.cc
Submitted: 7 May 2006 10:50 Modified: 27 Feb 2007 10:25
Reporter: Man-wai Chang Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.21 OS:Linux (Linux-2.6.16.14)
Assigned to: Magnus Blåudd CPU Architecture:Any

[7 May 2006 10:50] Man-wai Chang
Description:
Unable to compile mysql-5.0.21 using source codes and gcc-4.0.2, on Ubuntu-5.10. Kernel is 2.6.16.14.

How to repeat:
Just compile mysql-5.0.21 with gcc-4.0.2:

make[2]: Entering directory `/usr/src/mysql-5.0.21/sql'
if g++ -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/usr\"" -DDATADIR="\"/var/lib/mysql\"" -DSHAREDIR="\"/usr/share/mysql\"" -DHAVE_CONFIG_H -I. -I. -I.. -I../innobase/include -I../include -I../include -I../regex -I.      -O3 -DDBUG_OFF    -fno-implicit-templates -fno-exceptions -fno-rtti -MT gen_lex_hash.o -MD -MP -MF ".deps/gen_lex_hash.Tpo" -c -o gen_lex_hash.o gen_lex_hash.cc; \
then mv -f ".deps/gen_lex_hash.Tpo" ".deps/gen_lex_hash.Po"; else rm -f ".deps/gen_lex_hash.Tpo"; exit 1; fi
gen_lex_hash.cc: In function 'void insert_into_hash(hash_lex_struct*, const char*, int, int, int)':
gen_lex_hash.cc:164: error: cannot convert 'hash_lex_struct*' to 'char*' for argument '1' to 'void bmove(char*, const char*, uint)'
make[2]: *** [gen_lex_hash.o] Error 1
make[2]: Leaving directory `/usr/src/mysql-5.0.21/sql'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/mysql-5.0.21'
make: *** [all] Error 2
[8 May 2006 15:54] Hartmut Holzgraefe
Verified, affects all platforms where HAVE_MEMMOVE is false
due to the following code in m_strings.h as the 1st parameter
to memmove() is a "void *" whereas parameter #1 of bmove()
is a "char *" for which other conversion rules apply:

#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
# define memcpy(d, s, n)        bcopy ((s), (d), (n))
# define memset(A,C,B)          bfill((A),(B),(C))
# define memmove(d, s, n)       bmove ((d), (s), (n)) 
#elif defined(HAVE_MEMMOVE) 
# define bmove(d, s, n)         memmove((d), (s), (n))
#else
# define memmove(d, s, n)       bmove((d), (s), (n)) /* our bmove */
#endif
[8 May 2006 16:00] Hartmut Holzgraefe
The redefinition of memmove() should probably look like this instead:

# define memmove(d, s, n)     bmove ((char *)(d), (const char *)(s), (n))
[9 May 2006 7:53] Man-wai Chang
Please remove this bug report. It's hardware problem. Sorry.
[7 Jun 2006 14:15] Magnus Blåudd
Reproduced by undefining HAVE_MEMMOVE in config.h
[9 Jun 2006 9:10] Magnus Blåudd
By undefining HAVE_MEMMOVE in config.h it's possible to repeaet this. However it leads to a segmentation fault when running gen_lex_hash. Running it in valgrind shows some memory problems. Will start with running gen_lex_hash in valgrind to fix any memory problerms first.
[14 Jun 2006 16:00] Josh Trutwin
I have 

#define HAVE_MEMMOVE 1

in config.h AND I still get a seg fault when running gen_lex_hash 

System is base Slackware 10.1 (2.6.16.16)

Is there a workaround?
[15 Jun 2006 9:43] Magnus Blåudd
Sorry, I don't know of a workaround. Will update this bug report as soon as we find anything.
[6 Jul 2006 19:32] Josh Trutwin
Ok - took me a while, but I have some more information.

Magnus, you asked me to run gdb on the core file, but it doesn't dump any core.

MySQL was configured with this line:

env CFLAGS="-O3 -march=pentium3" CXX=gcc CXXFLAGS="-O3 -march=pentium3 -felide-constructors -fno-exceptions -fno-rtti" \
./configure --prefix=/usr/local/mysql-5.1.11-beta \
--with-unix-socket-path=/usr/local/mysql-5.1.11-beta/mysql.sock \
--enable-assembler \
--enable-local-infile \
--disable-shared \
--with-extra-charsets=complex \
--without-isam \
--enable-thread-safe-client \
--with-vio \
--with-innodb \
--with-ssl=/usr/local \
--enable-shared=yes \
--with-mysqld-ldflags=-all-shared \
--with-charset=latin1 \
--with-collations=latin1_general_ci \
--with-archive-storage-engine \
--with-csv-storage-engine \
--with-blackhole-storage-engine \
--with-federated-storage-engine \
--with-berkeley-db \
--with-partition

Also, if I run make again after the error, I get a LITTLE farther, but with different errors - I'll attach a file showing both make attempts.

Bison is version 2.1 - I'm going to try to get the latest version and see if that does anything.

Hope that helps...
[6 Jul 2006 19:34] Josh Trutwin
Ok, I can't add a file - you can see it here though:

http://trutwins.homeip.net/my.err.txt

Josh
[6 Jul 2006 19:53] Josh Trutwin
Same results with bison 2.3
[6 Jul 2006 20:04] Josh Trutwin
system / compiler info:

trutwijd@dvorak /home/trutwijd > more /etc/slackware-version 
Slackware 10.1.0

trutwijd@dvorak /home/trutwijd > uname -a
Linux dvorak 2.6.16.16 #1 SMP Tue May 16 21:03:27 CDT 2006 i686 unknown unknown GNU/Linux

trutwijd@dvorak /home/trutwijd > gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/specs
Configured with: ../gcc-3.3.4/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.3.4

ok, I'll shutup now.  :)
[10 Jul 2006 8:47] Magnus Blåudd
Hi,

as part of the build, the gen_lex_hash program is compiled and then executed to generate the "lex_hash.h" file(if that file is old or does not exist). Unfortunately when the execution of gen_lex_hash fails - as in this case - we will get an empty "lex_hash.h" and when that file is used in the second make,  compile failures will occur.

First compile gen_lex_hash:
if gcc -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/usr/local/mysql-5.1.11-beta\"" -DDATADIR="\"/usr/local/mysql-5.1.11-beta/var\"" -DSHAREDIR="\"/usr/local/mysql-5.1.11-beta/share/mysql\"" -DLIBDIR="\"/usr/local/mysql-5.1.11-beta/lib/mysql\"" -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../include -I../regex -I.  -I    -DDBUG_OFF -O3 -march=pentium3 -felide-constructors -fno-exceptions -fno-rtti   -fno-implicit-templates -fno-exceptions -fno-rtti -MT gen_lex_hash.o -MD -MP -MF ".deps/gen_lex_hash.Tpo" -c -o gen_lex_hash.o gen_lex_hash.cc; \
then mv -f ".deps/gen_lex_hash.Tpo" ".deps/gen_lex_hash.Po"; else rm -f ".deps/gen_lex_hash.Tpo"; exit 1; fi
/bin/sh ../libtool --preserve-dup-deps --tag=CXX --mode=link gcc  -DDBUG_OFF -O3 -march=pentium3 -felide-constructors -fno-exceptions -fno-rtti   -fno-implicit-templates -fno-exceptions -fno-rtti  -rdynamic  -o gen_lex_hash -static gen_lex_hash.o ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a ../regex/libregex.a ../strings/libmystrings.a -lz  -lpthread -lcrypt -lnsl -lm  -lpthread 
mkdir .libs
gcc -DDBUG_OFF -O3 -march=pentium3 -felide-constructors -fno-exceptions -fno-rtti -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o gen_lex_hash gen_lex_hash.o  ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a ../regex/libregex.a ../strings/libmystrings.a -lz -lpthread -lcrypt -lnsl -lm -lpthread

Now execute gen_lex_hash and pipe output to lex_hash.h
./gen_lex_hash > lex_hash.h
/bin/sh: line 1: 22054 Segmentation fault      ./gen_lex_hash >lex_hash.h
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
               Junk file lex_hash.h is generated.

This does not solve the problem with gen_lex_hash seg fault, but at leas it explains the second make failure.
[27 Feb 2007 10:25] Magnus Blåudd
The rule that creates lex_hash.h by executing gen_lex_hash has been updated to use a temporary file lex_hash.h-t to avoid trouble caused by failure to execute gen_lex_hash.

gen_lex_hash works on all of our build hosts.