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

gvm-libs fails to build on 32 bit architectures #846

Open
sbrun opened this issue Oct 24, 2024 · 6 comments · May be fixed by #849
Open

gvm-libs fails to build on 32 bit architectures #846

sbrun opened this issue Oct 24, 2024 · 6 comments · May be fixed by #849
Assignees
Labels

Comments

@sbrun
Copy link

sbrun commented Oct 24, 2024

Expected behavior

The build should be successful.

Actual behavior

When I tried to update the Debian package, the build fails on 32 bit architectures (i386, armel and armhf) with:

[ 53%] Linking C executable version-test
cd /<<PKGBUILDDIR>>/obj-i686-linux-gnu/base && /usr/bin/cmake -E cmake_link_script CMakeFiles/version-test.dir/link.txt --verbose=1
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_compress_and_uncompress_without_header’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:27:52: error: passing argument 3 of ‘gvm_compress’ from incompatible pointer type [-Wincompatible-pointer-types]
   27 |     gvm_compress (testdata, strlen (testdata) + 1, &compressed_len);
      |                                                    ^~~~~~~~~~~~~~~
      |                                                    |
      |                                                    size_t * {aka unsigned int *}
In file included from /<<PKGBUILDDIR>>/util/compressutils_tests.c:6:
/<<PKGBUILDDIR>>/util/compressutils.c:41:69: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
   41 | gvm_compress (const void *src, unsigned long srclen, unsigned long *dstlen)
      |                                                      ~~~~~~~~~~~~~~~^~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c:34:49: error: passing argument 3 of ‘gvm_uncompress’ from incompatible pointer type [-Wincompatible-pointer-types]
   34 |     gvm_uncompress (compressed, compressed_len, &uncompressed_len);
      |                                                 ^~~~~~~~~~~~~~~~~
      |                                                 |
      |                                                 size_t * {aka unsigned int *}
/<<PKGBUILDDIR>>/util/compressutils.c:109:71: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
  109 | gvm_uncompress (const void *src, unsigned long srclen, unsigned long *dstlen)
      |                                                        ~~~~~~~~~~~~~~~^~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_compress_and_uncompress_with_header’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:45:63: error: passing argument 3 of ‘gvm_compress_gzipheader’ from incompatible pointer type [-Wincompatible-pointer-types]
   45 |     gvm_compress_gzipheader (testdata, strlen (testdata) + 1, &compressed_len);
      |                                                               ^~~~~~~~~~~~~~~
      |                                                               |
      |                                                               size_t * {aka unsigned int *}
/<<PKGBUILDDIR>>/util/compressutils.c:180:41: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
  180 |                          unsigned long *dstlen)
      |                          ~~~~~~~~~~~~~~~^~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c:56:49: error: passing argument 3 of ‘gvm_uncompress’ from incompatible pointer type [-Wincompatible-pointer-types]
   56 |     gvm_uncompress (compressed, compressed_len, &uncompressed_len);
      |                                                 ^~~~~~~~~~~~~~~~~
      |                                                 |
      |                                                 size_t * {aka unsigned int *}
/<<PKGBUILDDIR>>/util/compressutils.c:109:71: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
  109 | gvm_uncompress (const void *src, unsigned long srclen, unsigned long *dstlen)
      |                                                        ~~~~~~~~~~~~~~~^~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_uncompress_using_reader’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:66:63: error: passing argument 3 of ‘gvm_compress_gzipheader’ from incompatible pointer type [-Wincompatible-pointer-types]
   66 |     gvm_compress_gzipheader (testdata, strlen (testdata) + 1, &compressed_len);
      |                                                               ^~~~~~~~~~~~~~~
      |                                                               |
      |                                                               size_t * {aka unsigned int *}
/<<PKGBUILDDIR>>/util/compressutils.c:180:41: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
  180 |                          unsigned long *dstlen)
      |                          ~~~~~~~~~~~~~~~^~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_uncompress_using_fd_reader’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:88:63: error: passing argument 3 of ‘gvm_compress_gzipheader’ from incompatible pointer type [-Wincompatible-pointer-types]
   88 |     gvm_compress_gzipheader (testdata, strlen (testdata) + 1, &compressed_len);
      |                                                               ^~~~~~~~~~~~~~~
      |                                                               |
      |                                                               size_t * {aka unsigned int *}
/<<PKGBUILDDIR>>/util/compressutils.c:180:41: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ {aka ‘unsigned int *’}
  180 |                          unsigned long *dstlen)
      |                          ~~~~~~~~~~~~~~~^~~~~~
/usr/bin/cc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG      -std=c11     -Wall     -Wextra     -Wpedantic     -Wmissing-prototypes     -Wshadow     -Wsequence-point     -D_ISOC11_SOURCE     -D_DEFAULT_SOURCE -Wl,-z,relro -Wl,-z,now -rdynamic -g -lgcov --coverage "CMakeFiles/version-test.dir/version_tests.c.o" -o version-test  -lcgreen -L/usr/lib/i386-linux-gnu -lglib-2.0 -Wl,-z,relro -Wl,-z,now
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_uncompress_using_reader’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:70:3: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |   write (compressed_fd, compressed, compressed_len);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c:77:3: warning: ignoring return value of ‘fread’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   77 |   fread (uncompressed, 1, 30, stream);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c: In function ‘compressutils__can_uncompress_using_fd_reader’:
/<<PKGBUILDDIR>>/util/compressutils_tests.c:92:3: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   92 |   write (compressed_fd, compressed, compressed_len);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/util/compressutils_tests.c:101:3: warning: ignoring return value of ‘fread’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  101 |   fread (uncompressed, 1, 30, stream);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[5]: *** [util/CMakeFiles/compressutils-test.dir/build.make:79: util/CMakeFiles/compressutils-test.dir/compressutils_tests.c.o] Error 1
make[5]: Leaving directory '/<<PKGBUILDDIR>>/obj-i686-linux-gnu'
make[4]: *** [CMakeFiles/Makefile2:808: util/CMakeFiles/compressutils-test.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....

GVM versions

gvm-libs: 22.14.0.
I didn't reproduce the issue with version 22.12.0 (the failing code was introduced in version 22.13.0)

Environment

Build on Debian Unstable

It may be related the GCC-14:
https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types

@sbrun sbrun added the bug label Oct 24, 2024
@mattmundell
Copy link
Contributor

I think the buflen arg in gvm_compress should be changed to a size_t.

The arg is passed to g_malloc which uses gsize which is always the same a size_t, so unsigned long is too big.

@mattmundell mattmundell self-assigned this Oct 24, 2024
@mattmundell
Copy link
Contributor

Can do this next week, if anyone has time before, go wild.

@mattmundell
Copy link
Contributor

@sbrun I tried with the i386/debian:unstable docker and it builds OK. Do you have a way for me to reproduce this? Maybe it was armel or armhf failing instead of i386?

@sbrun
Copy link
Author

sbrun commented Oct 30, 2024

I confirm it fails on the 3 architectures (https://buildd.debian.org/status/package.php?p=gvm-libs)

The repository of the Debian package is here: https://salsa.debian.org/pkg-security-team/gvm-libs
You can notice that the build on i386 fails here too (CI checks)

@mattmundell mattmundell linked a pull request Nov 1, 2024 that will close this issue
@mattmundell
Copy link
Contributor

Thanks @sbrun. Finally reproduced it.

@mattmundell
Copy link
Contributor

It may be related the GCC-14:

Also happens on Debian 12 with gcc-12 though.

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

Successfully merging a pull request may close this issue.

2 participants