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

Incorrect printf format string in InfillTest causes test failure on 32-bit architectures #1897

Closed
onitake opened this issue Jul 8, 2023 · 0 comments · Fixed by #1898
Closed

Comments

@onitake
Copy link
Contributor

onitake commented Jul 8, 2023

Application Version

5.0.0 until current HEAD ( ef46801 )

Platform

Linux on i686 (or any 32-bit architecture)

Qt

N/A

PyQt

N/A

Display Driver

N/A

Steps to Reproduce

  1. Compile CuraEngine for a CPU architecture with a 32-bit size_t
  2. Run unit test InfillTest

Actual Results

...
5: 
5: [ FATAL ] /usr/include/gtest/internal/gtest-param-util.h:585:: Condition IsValidParamName(param_name) failed. Parameterized test name 'InfillTestParameters_P2_Z0_C0_L350__-4294967296' is invalid, in ./tests/InfillTest.cpp line 241
5: 
...
96% tests passed, 1 tests failed out of 26

Total Test time (real) =  10.85 sec

The following tests FAILED:
	  5 - InfillTest (Subprocess aborted)
Errors while running CTest
make[1]: *** [Makefile:94: test] Error 8

Expected results

The unit test succeeds.

Additional Information

The bug lies in the a printf format string, where %lld is incorrectly used to format a size_t argument.
InfillTest runs with very high numbers for this argument which will cause a rollover on 32 architectures if they're interpreted as signed, but size_t is unsigned.

To fix the issue, the correct format string for size_t should be used: %zu
Alternatively, changing %lld to %llu will also work in most cases.

This occurred during automatic unit testing of CuraEngine 5.0.0 in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040252
But the bug is still present in current HEAD: https://github.com/Ultimaker/CuraEngine/blob/main/tests/InfillTest.cpp#L103

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.

1 participant