Bug #51473 static linking of libmysqlclient.a fails
Submitted: 24 Feb 2010 19:44 Modified: 21 Nov 2018 15:04
Reporter: Peter Thoemmes Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:6.0.2, 5.0, 5.1, 5.5.99 OS:Linux (2.6.28-18)
Assigned to: CPU Architecture:Any
Tags: Contribution, gcc-4.3.3, libmysqlclient.a, linking, static

[24 Feb 2010 19:44] Peter Thoemmes
Description:
Linking a C/C++ Project to libmysqlclient.a fails with following message:
/opt/mysql-602/lib/static/libmysqlclient.a(ssl.cpp.o): In function `yaSSL::read_file(yaSSL::SSL_CTX*, char const*, int, yaSSL::CertType)':
ssl.cpp:(.text+0x2225): warning: memset used with constant zero length parameter; this could be due to transposed parameters

How to repeat:
Static linking of libmysqlclient.a under Linux 2.6.28-18 (ubuntu 9.04) using
gcc 4.3.3.

Suggested fix:
Line 170 in '/extlib/yassl/taocrypt/include/block.hpp' is the bad guy:

167: void CleanNew(word32 newSize)
168: {
169:    New(newSize);
170:    memset(buffer_, 0, sz_ * sizeof(T));
171: }

Als the default c'tor intializes sz_ with 0 and the calls CleanNew(), memset()
will always see a zero-size array.

FIX:
167: void CleanNew(word32 newSize)
168: {
169:    New(newSize);
170:    if(sz_)
171:       memset(buffer_, 0, sz_ * sizeof(T));
172: }
[25 Feb 2010 11:55] Valeriy Kravchuk
Thank you for the problem report. Please, check with a newer version, 6.0.14 (mysql-6.0-codebase tree at launchpad), and inform about the results.
[26 Feb 2010 18:18] Peter Thoemmes
No need to test. The method 'CleanNew()' in '/extlib/yassl/taocrypt/include/block.hpp' (revision 2889) is still the same implementation. Just had a look. Why don't you simply apply my patch?
[2 Mar 2010 9:04] Sveta Smirnova
Thank you for the feedback.

We could not just apply patches without testing if you used C API properly on your side: warning is not repeatable with dummy test.

Please send us example of C code warning repeatable with and provide command line you use to compile this example.
[3 Mar 2010 19:23] Peter Thoemmes
> We could not just apply patches...
Sorry for you. For me the problem is fixed and I really don't have the time to play ping-pong here. It cost me already too much time. I can't support you more here. Simply decide which way you want to go: leave it or fix it.
[6 Mar 2010 12:00] Sveta Smirnova
Thank you for the feedback.

You are right: this can be verified by reading source code, although CleanNew used in Integer.cpp also, so it is not always zero. And  is better to have test case anyway: at least command line with options you used.
[7 Mar 2010 17:04] Peter Thoemmes
Ok, here please have an extract of the build process command lines...
COMPILER:
g++ -c -I. -I/opt/mysql-602/include -I/opt/qtsdk-2010.01/qt/include/QtCore -I/opt/qtsdk-2010.01/qt/include/QtGui -I/opt/qtsdk-2010.01/qt/include -I/usr/X11R6/include -D_REENTRANT -Wall -g -m64 -static -DQT_GUI_LIB -DQT_CORE_LIB ../src/main.cpp
LINKER:
g++  -Wl,--no-undefined -o ../bin/UNIX/sst_mc auto_mtrace.o DateTime.o DbgPrint.o FileEditor.o FsHelper.o LockObject.o NetworkHelper.o Semaphore.o SocketClient.o SysHelper.o SysInfo.o AutoLock.o CfgFileHlp.o DateTimeMJD.o ExtSocketClient.o FifoFileHlp.o FsHlp.o FunctionTrace.o FNVHash.o LogFileHlp.o MathHlp.o MySQLHlp.o PtCrypt.o RWLockObject.o SocketProtocol.o StrHlp.o SysHlp.o UTFConverter.o AOTSubtableEditor.o EITInputFileReader.o EITSubtableEditor.o MPEGPacketizer.o PATSubtableEditor.o PktStream.o PMTSubtableEditor.o PSIDecoder.o PSIEncoder.o PSIMux.o PSIStreamAnalyzer.o SDTInputFileReader.o SDTSubtableEditor.o SGTSubtableEditor.o StreamAnalyzer.o CRC_32_Checker.o AITSectionCreator.o AOTSectionCreator.o BATSectionCreator.o CATSectionCreator.o EITSectionCreator.o NITSectionCreator.o PATSectionCreator.o PMTSectionCreator.o RSTSectionCreator.o SDTSectionCreator.o SGTSectionCreator.o TBTPSectionCreator.o TDTSectionCreator.o TIMSectionCreator.o TOTSectionCreator.o AITSectionDecoder.o AOTSectionDecoder.o BATSectionDecoder.o CATSectionDecoder.o DescriptorDecoder.o EITSectionDecoder.o NITSectionDecoder.o PATSectionDecoder.o PMTSectionDecoder.o RSTSectionDecoder.o SDTSectionDecoder.o SGTSectionDecoder.o TBTPSectionDecoder.o TDTSectionDecoder.o TIMSectionDecoder.o TOTSectionDecoder.o AOTSectionEditor.o DescriptorEditor.o EITSectionEditor.o PATSectionEditor.o PMTSectionEditor.o SDTSectionEditor.o SGTSectionEditor.o MySQL.o Graph.o GraphWidget.o Label.o StatusWidget.o CPUMemGraphWidget.o MainWindow.o Page0.o Page1.o main.o moc_CPUMemGraphWidget.o moc_GraphWidget.o moc_Label.o moc_StatusWidget.o moc_MainWindow.o moc_Page0.o moc_Page1.o  -L/opt/mysql-602/lib/static -L/usr/lib -L/usr/X11R6/lib -L/opt/qtsdk-2010.01/qt/lib -lrt -lmysqlclient -lm -lX11 -lXext -lQtGui -lQtCore
[21 Nov 2018 15:04] Dyre Tjeldvoll
Posted by developer:
 
Closing this bug as it is no longer relevant after WL#8898: migrate away from yaSSL.