Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation of 1.9.6 fails due to 'dwClientID' may be used uninitialized #126

Closed
freswa opened this issue May 11, 2022 · 9 comments
Closed
Assignees

Comments

@freswa
Copy link
Contributor

freswa commented May 11, 2022

Versions

Last good version: 1.9.5
First bad version: 1.9.6

Platform

Arch Linux

Issue

Compilation fails

Log

touch pcsc-wirecheck-dist.c
  CC       pcsc-wirecheck-dist.o
  CCLD     pcsc-wirecheck
  CCLD     testpcsc
In function 'ProcessEventsServer',
    inlined from 'SVCServiceRunLoop' at pcscdaemon.c:129:17,
    inlined from 'main' at pcscdaemon.c:791:2:
winscard_msg_srv.c:259:25: error: 'dwClientID' may be used uninitialized [-Werror=maybe-uninitialized]
  259 |                         Log2(PCSC_LOG_ERROR,
      |                         ^
pcscdaemon.c: In function 'main':
pcscdaemon.c:110:18: note: 'dwClientID' was declared here
  110 |         uint32_t dwClientID;    /* Connection ID used to reference the Client */
      |                  ^
lto1: all warnings being treated as errors
make[4]: *** [/tmp/ccJL3tDg.mk:2: /tmp/ccDEEAH5.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
@LudovicRousseau
Copy link
Owner

Interesting.
Can you run make V=1 so I can see the compilation arguments used?

@LudovicRousseau LudovicRousseau self-assigned this May 11, 2022
@freswa
Copy link
Contributor Author

freswa commented May 11, 2022

libtool: link: (cd ".libs" && rm -f "libpcsclite.so.1" && ln -s "libpcsclite.so.1.0.0" "libpcsclite.so.1")
libtool: link: (cd ".libs" && rm -f "libpcsclite.so" && ln -s "libpcsclite.so.1.0.0" "libpcsclite.so")
libtool: link: ( cd ".libs" && rm -f "libpcsclite.la" && ln -s "../libpcsclite.la" "libpcsclite.la" )
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -Wall -Wextra -Wno-unused-parameter -Werror -Wall -fno-common -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -flto=auto  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -o testpcsc testpcsc.o libpcsclite.la -lrt
libtool: link: gcc -Wall -Wextra -Wno-unused-parameter -Werror -Wall -fno-common -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto=auto -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z -Wl,relro -Wl,-z -Wl,now -flto=auto -o .libs/testpcsc testpcsc.o  ./.libs/libpcsclite.so -lrt -pthread
In function 'ProcessEventsServer',
    inlined from 'SVCServiceRunLoop' at pcscdaemon.c:129:17,
    inlined from 'main' at pcscdaemon.c:791:2:
winscard_msg_srv.c:259:25: error: 'dwClientID' may be used uninitialized [-Werror=maybe-uninitialized]
  259 |                         Log2(PCSC_LOG_ERROR,
      |                         ^
pcscdaemon.c: In function 'main':
pcscdaemon.c:110:18: note: 'dwClientID' was declared here
  110 |         uint32_t dwClientID;    /* Connection ID used to reference the Client */
      |                  ^
lto1: all warnings being treated as errors
make[4]: *** [/tmp/ccbc7MFB.mk:2: /tmp/ccmdjZ7Q.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

@LudovicRousseau
Copy link
Owner

The problem has also been reported on the mailing list http:https://lists.infradead.org/pipermail/pcsclite-muscle/2022-May/001265.html

what is the version of your OS and version of gcc?

@eworm-de
Copy link
Contributor

Arch Linux with gcc 12.1.0...

@freswa
Copy link
Contributor Author

freswa commented May 12, 2022

what is the version of your OS and version of gcc?

This error occurs with gcc 12.1.0 as well as 11.2.0

Jakuje added a commit to Jakuje/PCSC that referenced this issue May 12, 2022
The gcc reports errors like these:

  pcscdaemon.c: In function 'main':
  winscard_msg_srv.c:259:25: error: 'dwClientID' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    259 |                         Log2(PCSC_LOG_ERROR,
        |                         ^
  pcscdaemon.c:110:18: note: 'dwClientID' was declared here
    110 |         uint32_t dwClientID;    /* Connection ID used to reference the Client */
        |                  ^

Fixes LudovicRousseau#126
@LudovicRousseau
Copy link
Owner

I am using gcc 11.3.0 from Debian testing and I do not have the warning/error.
Do I have to use a special CFLAGS argument?

./configure says:

Compiler flags:      -Wall -Wextra -Wno-unused-parameter -Werror -Wall -fno-common 

What do you have on your side?

@freswa
Copy link
Contributor Author

freswa commented May 12, 2022

Preprocessor flags:  -I${top_srcdir}/src
Compiler flags:      -Wall -Wextra -Wno-unused-parameter -Werror -Wall -fno-common -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -flto=auto
Preprocessor flags:  -I${top_srcdir}/src
Linker flags:        -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto
Libraries:            -lrt

@LudovicRousseau
Copy link
Owner

I get the warning/error if I use:

CFLAGS="-Wall -Wextra -O2 -flto=auto"

I never used -flto. I will add it to my standard CFLAGS.

It is strange that I do NOT get the warning if I do not use -O2. I thought it was only for code optimisation but it has other side effects.

Maybe enabling -Werror was not a good idea. But it allowed you to report the problem and I can now fix it :-)

@LudovicRousseau
Copy link
Owner

Should be fixed with 76c99cd

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants