** Description changed:

+ Problem:
+ qjoypad 4.3.1-3.1 FTBFS on ppc64el (and under -O3 + LTO) in Ubuntu 26.10 
(stonking) due to -Werror=maybe-uninitialized in Axis::move(): when mode != 
Keyboard and press == false, FakeEvent e was never initialized before passing 
to sendevent().
+ 
+ Root Cause & Fix:
+ Fix the uninitialized read in src/axis.cpp as requested by adding an early 
return for release in mouse modes (since mouse motion has no release action) 
and value-initializing FakeEvent e{}. No compiler warnings were silenced and 
LTO optimization flags were kept intact.
+ 
+ Verification:
+ 1. Reproduce on unmodified 4.3.1-3.1: build with -O3 -flto=auto 
-ffat-lto-objects reproduces the exact error:
+    'error: ‘MEM <unsigned int> [(struct FakeEvent *)&e]’ may be used 
uninitialized [-Werror=maybe-uninitialized]'
+ 2. Verify with debdiff: full build completes with exit code 0, linking 
qjoypad executable cleanly under -O3 + LTO with 0 warnings/errors.
+ 3. Verified in PPA: ppc64el build succeeded cleanly 
(https://launchpad.net/~steelf/+archive/ubuntu/ppa/+build/33834461).
+ 
+ Upstream: https://github.com/panzi/qjoypad
+ 
+ 
+ --- [ Original Report ]
+ 
  qjoypad 4.3.1-3.1 has been stuck in stonking-proposed for ~346 days.
  update_excuses reports:
  
    missing build on ppc64el: qjoypad (from 4.3.1-3build2)
  
  All other architectures built fine. Build log (ppc64el):
  https://launchpad.net/ubuntu/+source/qjoypad/4.3.1-3.1/+build/32794460
  
  Failure (at LTO link time):
  
    In function 'sendevent',
        inlined from 'move' at /usr/src/qjoypad-4.3.1-3.1/src/axis.cpp:436:11:
    /usr/src/qjoypad-4.3.1-3.1/src/event.cpp:8:5: error: 'MEM <unsigned int> 
[(struct FakeEvent *)&e]' may be used uninitialized 
[-Werror=maybe-uninitialized]
    src/axis.cpp:355:15: note: 'MEM <unsigned int> [(struct FakeEvent *)&e]' 
was declared here
    lto1: all warnings being treated as errors
    lto-wrapper: fatal error: make returned 2 exit status
  
  Cause:
  - Upstream's CMakeLists.txt builds with -Wall -Wextra -Werror (line 43).
  - On ppc64el Ubuntu builds with -O3 and LTO (-flto=auto -ffat-lto-objects) by 
default. With LTO, sendevent() (event.cpp) gets inlined into Axis::move() 
(axis.cpp), and gcc-15 can now see that e.type may be read uninitialized, which 
-Werror makes fatal. Debian has neither -O3 on ppc64el nor LTO by default, so 
it builds there (Debian has ppc64el binaries of 4.3.1-3.1). The ppc64el build 
of 4.3.1-3build2 in stonking predates gcc-15.
  
  This looks like a real (minor) bug rather than a pure false positive. In
  Axis::move() (src/axis.cpp ~354-437):
  
    void Axis::move( bool press ) {
        FakeEvent e;
        if (mode == Keyboard) {
            ...            // sets e.type and e.keycode
        }
        else if (press) {
            ...            // sets e.type = MouseMove and e.move.{x,y}
        }
        //actually create the event
        sendevent(e);
    }
  
  When the axis is in a mouse mode and press == false, e is never
  initialised, and sendevent() reads e.type (switch (e.type) in
  event.cpp:8).
  
  Debian / upstream status:
  - No open Debian bug for this (it doesn't reproduce in Debian's default 
flags).
  - Upstream (https://github.com/panzi/qjoypad) is largely inactive; 4.3.1 is 
the latest release.
  
  Suggested direction (to be done by whoever picks this up):
  - Fix the code rather than silencing the warning: e.g. return early from 
Axis::move() in the mouse-mode/release case (there is nothing to send), or at 
least value-initialise the event (FakeEvent e{}; or memset) so that sendevent() 
takes no action on an all-zero event. Check what the right behaviour is: with e 
zeroed, type would be KeyUp with keycode 0, which sendevent() already ignores 
("if (e.keycode == 0) return;"), so FakeEvent e{} is a safe minimal fix; an 
early return is cleaner.
  - Alternatives (less preferred): add -Wno-error=maybe-uninitialized, or 
DEB_BUILD_MAINT_OPTIONS += optimize=-lto.
  - Test-build on ppc64el (PPA, or a ppc64el chroot), upload as an Ubuntu 
delta, and forward the patch to Debian (and upstream) since the uninitialised 
read is real on all architectures.

** Changed in: qjoypad (Ubuntu)
       Status: New => Confirmed

** Tags added: patch stonking

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2170324

Title:
  qjoypad FTBFS on ppc64el in stonking: -Werror=maybe-uninitialized in
  Axis::move() with -O3 + LTO

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qjoypad/+bug/2170324/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to