[3dprinter-general] Bug#1057630: slic3r-prusa: Uninitialized memory in GravityKernel.hpp causes FTBFS on multiple architectures

Gregor Riepl onitake at gmail.com
Wed Dec 6 08:03:00 GMT 2023


Source: slic3r-prusa
Version: 2.6.1+dfsg-4.1
Severity: normal
Tags: patch upstream ftbfs
X-Debbugs-Cc: onitake at gmail.com

The PrusaSlicer currently fails to build on multiple architectures due to an
uninitialized field in GravityKernel.hpp .
This bug causes a unit test failure, but this doesn't always show.

The bug is in src/libslic3r/Arrange/Core/NFP/Kernels/GravityKernel.hpp line 18:
    Vec2d active_sink;

This struct field is not initialized because the default constructor of Vec2d
(which is a type alias to Eigen::Matrix<double, 2, 1>) does nothing. This is
documented behavior, but was not respected in the PrusaSlicer source code:

https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html
> A default constructor is always available, never performs any dynamic memory
allocation, and never initializes the matrix coefficients.

This issue was partially fixed in upstream commit
f2ae32780eb8ec9437e0134b08a5e1c752353527, but the default constructor was not
replaced. It's not clear if this is still an issue or not, but the following
patch should at least be backported to Debian to fix the FTBFS issue in
PrusaSlicer:

commit f2ae32780eb8ec9437e0134b08a5e1c752353527
Author: tamasmeszaros <meszaros.q at gmail.com>
Date:   Mon Oct 2 12:07:14 2023 +0200

    Fix failing arrange test on newest msvc

diff --git a/src/libslic3r/Arrange/Core/NFP/Kernels/GravityKernel.hpp
b/src/libslic3r/Arrange/Core/NFP/Kernels/GravityKernel.hpp
index c8a5488b3..3bb1cad0e 100644
--- a/src/libslic3r/Arrange/Core/NFP/Kernels/GravityKernel.hpp
+++ b/src/libslic3r/Arrange/Core/NFP/Kernels/GravityKernel.hpp
@@ -17,7 +17,9 @@ struct GravityKernel {
     std::optional<Vec2crd> item_sink;
     Vec2d active_sink;

-    GravityKernel(Vec2crd gravity_center) : sink{gravity_center} {}
+    GravityKernel(Vec2crd gravity_center) :
+        sink{gravity_center}, active_sink{unscaled(gravity_center)} {}
+
     GravityKernel() = default;

     template<class ArrItem>



-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'stable'), (300, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.0-4-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled



More information about the 3dprinter-general mailing list