Bug #58057 5.1 libmysql/libmysql.c unused variable/compile failure

Submitted: 8 Nov 2010 16:18 Modified: 11 Dec 2010 17:36
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.1-security (5.1.54) OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any

[8 Nov 2010 16:18] Paul DuBois
Description:
libmysql/libmysql.c has an unused variable. This causes compilation failure. Example:

make[2]: Entering directory `/src/extern/MySQL/bzr-mysql/mysql-5.1-security/libmysql'
/bin/sh ../libtool --preserve-dup-deps  --tag=CC   --mode=compile gcc -DDEFAULT_CHARSET_HOME="\"/var/mysql/50154\"" -DMYSQL_DATADIR="\"/var/mysql/50154/data\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DDEFAULT_SYSCONFDIR="\"/var/mysql/50154/etc\"" -DSHAREDIR="\"/var/mysql/50154/share/mysql\"" -DMYSQL_CLIENT_NO_THREADS -DDONT_USE_RAID  -I. -I../include -I../include -I../include     -Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror -g -DSAFE_MUTEX -DSAFEMALLOC -O1   -DUNIV_LINUX -DUNIV_LINUX -MT libmysql.lo -MD -MP -MF .deps/libmysql.Tpo -c -o libmysql.lo libmysql.c
libtool: compile:  gcc -DDEFAULT_CHARSET_HOME=\"/var/mysql/50154\" -DMYSQL_DATADIR=\"/var/mysql/50154/data\" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DDEFAULT_SYSCONFDIR=\"/var/mysql/50154/etc\" -DSHAREDIR=\"/var/mysql/50154/share/mysql\" -DMYSQL_CLIENT_NO_THREADS -DDONT_USE_RAID -I. -I../include -I../include -I../include -Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror -g -DSAFE_MUTEX -DSAFEMALLOC -O1 -DUNIV_LINUX -DUNIV_LINUX -MT libmysql.lo -MD -MP -MF .deps/libmysql.Tpo -c libmysql.c  -fPIC -DPIC -o .libs/libmysql.o
cc1: warnings being treated as errors
libmysql.c: In function ‘mysql_server_init’:
libmysql.c:134: error: unused variable ‘serv_ptr’
make[2]: *** [libmysql.lo] Error 1
make[2]: Leaving directory `/src/extern/MySQL/bzr-mysql/mysql-5.1-security/libmysql'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/src/extern/MySQL/bzr-mysql/mysql-5.1-security/libmysql'
make: *** [all-recursive] Error 1

Removing line 134 enables compilation to succeed. I don't think that's quite the correct fix, because it actually is used later on in the source, if the right combination of symbols is defined.

Note: I sometimes have successful compilation with "make clean; make". But if I immediately type "make" again, compilation fails as shown above.

How to repeat:
Here is my configuration:

VERSION=50154

PREFIX="/var/mysql/$VERSION"
PORT=$VERSION
HANDLERS="
  --with-plugins=archive,blackhole,csv,example,federated,innobase,partition
"
DOCS="--without-docs --without-man"
OTHER="
  --enable-local-infile
  --enable-thread-safe-client
  --with-comment=
  --with-debug=full
  --with-embedded-server
  --with-extra-charsets=all
  --without-readline
  --with-ssl
"
rm -f config.cache
CFLAGS=-O1 \
./configure \
  --prefix=$PREFIX \
  --localstatedir=$PREFIX/data \
  --with-unix-socket-path=$PREFIX/mysql.sock \
  --with-tcp-port=$PORT \
  $HANDLERS $DOCS $OTHER

Suggested fix:
Probably the variable declaration needs protection with the same ifdefs as the variable's use later on.
[8 Nov 2010 22:00] Sveta Smirnova
Thank you for the report.

Do you use BZR repository? I can not repeat described behavior with today update and get error

cc1plus: warnings being treated as errors
debug_sync.cc: In function ‘void debug_sync_execute(THD*, st_debug_sync_action*)’:
debug_sync.cc:1721: error: ‘old_proc_info’ may be used uninitialized in this function
make[3]: *** [debug_sync.o] Error 1

instead.
[10 Nov 2010 21:15] 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/123501

3503 Davi Arnaut	2010-11-10
      Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
      Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
      Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
      Bug#57994: Compiler flag change build error : my_redel.c
      Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
      Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
      Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc
      
      Fix assorted compiler generated warnings.
     @ cmd-line-utils/readline/bind.c
        Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
        
        Initialize variable to work around a false positive warning.
     @ include/m_string.h
        Bug#57994: Compiler flag change build error : my_redel.c
        
        The expansion of stpcpy (in glibc) causes warnings if the
        return value of strmov is not being used. Since stpcpy is
        a GNU extension and the expansion ends up using a built-in
        provided by GCC, use the compiler provided built-in directly
        when possible.
     @ include/my_compiler.h
        Define a dummy MY_GNUC_PREREQ when not compiling with GCC.
     @ libmysql/libmysql.c
        Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
        
        Variable might not be used in some cases. So, tag it as unused.
     @ mysys/mf_keycache.c
        Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
        
        Use UNINIT_VAR to work around a false positive warning.
     @ mysys/my_getncpus.c
        Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
        
        Declare variable in the same block where it is used.
     @ regex/regexec.c
        Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
        
        Work around a compiler bug which causes the cast to not be enforced.
     @ sql/debug_sync.cc
        Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc
        
        Use UNINIT_VAR to work around a false positive warning.
     @ sql/handler.cc
        Use UNINIT_VAR to work around a false positive warning.
     @ sql/slave.cc
        Use UNINIT_VAR to work around a false positive warning.
     @ sql/sql_partition.cc
        Use UNINIT_VAR to work around a false positive warning.
     @ storage/myisam/ft_nlq_search.c
        Use UNINIT_VAR to work around a false positive warning.
     @ storage/myisam/mi_create.c
        Use UNINIT_VAR to work around a false positive warning.
     @ storage/myisammrg/myrg_open.c
        Use UNINIT_VAR to work around a false positive warning.
     @ tests/mysql_client_test.c
        Change function to take a pointer to const, no need for a cast.
[12 Nov 2010 14:30] Jon Olav Hauglid
Ok to push.
[16 Nov 2010 9:46] Davi Arnaut
Pushed into mysql-5.1-bugteam and up.
[20 Nov 2010 0:49] Paul DuBois
Noted in 5.1.54, 5.5.8 changelogs.

Several compilation problems were fixed.
[5 Dec 2010 12:42] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[15 Dec 2010 5:51] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:sunanda.menon@oracle.com-20101215054055-vgwki317xg1wphhh) (version source revid:sunanda.menon@oracle.com-20101215054055-vgwki317xg1wphhh) (merge vers: 5.1.55) (pib:23)
[16 Dec 2010 22:33] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.