Bug 311098 - build fails with "warning: memset used with constant zero length parameter; this could be due to transposed parameters"
Summary: build fails with "warning: memset used with constant zero length parameter; t...
Status: RESOLVED WORKSFORME
Alias: None
Product: kopete
Classification: Applications
Component: QQ Plugin (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-03 18:08 UTC by Daniel Santos
Modified: 2022-11-18 05:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
work-around (418 bytes, patch)
2012-12-03 18:10 UTC, Daniel Santos
Details
compressed build log (42.67 KB, application/x-lzma)
2012-12-03 18:20 UTC, Daniel Santos
Details
emerge --info kde-base/kopete (9.53 KB, text/plain)
2012-12-03 18:22 UTC, Daniel Santos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Santos 2012-12-03 18:08:53 UTC
This may be a bug in gcc, but I was unable to reproduce this with a small example.  I'm not bothering with a Gentoo bug right now because they apparently don't care about gcc 4.7 yet. :(  Essentially, it appears that we're generating a warning when memset is called and it's "size" (not "length" as the error message says) parameter is compile-time constant that evaulates to zero.  However, rather than simply generating a warning, it actually causes ld to return non-zero.

/usr/lib64/ccache/bin/x86_64-pc-linux-gnu-g++  -fPIC -march=native -O2 -ggdb  -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wform
at-security -fno-exceptions -DQT_NO_EXCEPTIONS -fno-check-new -fno-common -Woverloaded-virtual -fno-threadsafe-statics -fvisibility=hidden -fvisibility-inlines-hidden -Wl,--enable-ne
w-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc  -Wl,-O1 -Wl,--as-needed -shared -Wl,-soname,kopete_qq.so -o ../../../lib/kopete_qq.so CMakeFiles/kopete_qq.dir/kopete_qq_automoc.
o CMakeFiles/kopete_qq.dir/ui/qqwebcamdialog.o CMakeFiles/kopete_qq.dir/ui/qqeditaccountwidget.o CMakeFiles/kopete_qq.dir/ui/dlgqqvcard.o CMakeFiles/kopete_qq.dir/qqprotocol.o CMakeF
iles/kopete_qq.dir/qqcontact.o CMakeFiles/kopete_qq.dir/qqaccount.o CMakeFiles/kopete_qq.dir/qqaddcontactpage.o CMakeFiles/kopete_qq.dir/qqsocket.o CMakeFiles/kopete_qq.dir/qqnotifys
ocket.o CMakeFiles/kopete_qq.dir/qqchatsession.o CMakeFiles/kopete_qq.dir/libeva.o CMakeFiles/kopete_qq.dir/evautil.o CMakeFiles/kopete_qq.dir/md5.o CMakeFiles/kopete_qq.dir/crypt.o 
-L/usr/lib64/qt4 -L/tmp/portage/kde-base/kopete-4.9.3/work/kopete-4.9.3_build/lib /usr/lib64/libkio.so.5.9.3 /usr/lib64/qt4/libQtNetwork.so /usr/lib64/qt4/libQt3Support.so ../../../l
ib/libkopete.so.4.9.3 ../../../lib/libkopete_videodevice.so.4.9.3 /usr/lib64/qt4/libQt3Support.so /usr/lib64/libkio.so.5.9.3 /usr/lib64/qt4/libQtNetwork.so /usr/lib64/qt4/libQtXml.so
 /usr/lib64/libkdeui.so.5.9.3 /usr/lib64/qt4/libQtGui.so /usr/lib64/qt4/libQtSvg.so /usr/lib64/libkdecore.so.5.9.3 /usr/lib64/qt4/libQtDBus.so /usr/lib64/qt4/libQtCore.so -lpthread -
Wl,-rpath,/usr/lib64/qt4:/tmp/portage/kde-base/kopete-4.9.3/work/kopete-4.9.3_build/lib:
CMakeFiles/kopete_qq.dir/evautil.o: In function `memset':
/usr/include/bits/string3.h:82: warning: memset used with constant zero length parameter; this could be due to transposed parameters
collect2: error: ld returned 1 exit status
make[2]: *** [lib/kopete_qq.so] Error 1
make[2]: Leaving directory `/tmp/portage/kde-base/kopete-4.9.3/work/kopete-4.9.3_build'
make[1]: *** [kopete/protocols/qq/CMakeFiles/kopete_qq.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The offending error message originates from here: http://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/gcc.dg/memset-1.c;h=677ae91bd0e7f5f04b4ce3c1a93dfcbcee188d44;hb=HEAD

The work around is cheesy, it's to check the value of pos prior to calling memset.  In practice, this will likely get compiled-out.  While I haven't examined either Eva::Packet or ByteArray closely, I presume that the Eva::Packet::encrypt() is called somewhere (or how) in a manner that gcc is able to determine the outcome of the expression "text.size()" at compile time, thus, when the memset inline is expanded, it determines that it's both a compile-time constant and zero and gives is the warning, that ends up acting like an error.

Here's the work-around:

--- kopete/protocols/qq/evautil.cpp.orig        2012-12-03 11:47:00.466594261 -0600
+++ kopete/protocols/qq/evautil.cpp     2012-12-03 11:47:26.719613014 -0600
@@ -78,7 +78,9 @@
                plain[0] = ( rand() & 0xf8 ) | pos;
                memset( plain_pre, 0, 8 );
                memset( crypted_pre, 0, 8 );
-               memset( plain+1, rand()& 0xff, pos++ );
+               if( pos )
+                       memset( plain+1, rand()& 0xff, pos );
+               ++pos;
 
                // pad 2 bytes
                for( i = 0; i< 2; i++ )


Reproducible: Always

Steps to Reproduce:
see Details
Actual Results:  
see Details

Expected Results:  
see Details

see Details
Comment 1 Daniel Santos 2012-12-03 18:10:24 UTC
Created attachment 75608 [details]
work-around
Comment 2 Daniel Santos 2012-12-03 18:20:17 UTC
Created attachment 75609 [details]
compressed build log

This log file was 2.8MiB, so I didn't figure you guys would mind it compressed :)
Comment 3 Daniel Santos 2012-12-03 18:22:34 UTC
Created attachment 75610 [details]
emerge --info kde-base/kopete
Comment 4 Daniel Santos 2012-12-03 18:39:15 UTC
Actually, I appear to be wrong on the origins of the error message, it looks like it's from glibc's string.h header: http://sourceware.org/git/?p=glibc.git;a=blob;f=string/bits/string3.h;h=cc611dfd3b706eaacea449cca0765cadd78bf738;hb=HEAD#l22. However, I haven't figured out why it creates an error from this warning yet.
Comment 5 Justin Zobel 2022-10-19 22:10:44 UTC
Thank you for reporting this bug in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 6 Bug Janitor Service 2022-11-03 05:06:24 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Bug Janitor Service 2022-11-18 05:16:40 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!