Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 858722 - games-engines/odamex-10.4.0-r1 fails to compile (lto): cl_parse.cpp:2287:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
Summary: games-engines/odamex-10.4.0-r1 fails to compile (lto): cl_parse.cpp:2287:26: ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Games
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-07-18 06:49 UTC by Agostino Sarubbo
Modified: 2024-03-19 23:04 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log.xz (build.log.xz,40.84 KB, application/x-xz)
2022-07-18 06:49 UTC, Agostino Sarubbo
Details
build log compressed with xz (build.log.xz,29.25 KB, application/x-xz)
2023-11-17 10:40 UTC, Kostadin Shishmanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-07-18 06:49:14 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: games-engines/odamex-10.0.0 fails to compile (lto).
Discovered on: amd64 (internal ref: lto_tinderbox)

NOTE:
This machine uses lto with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Comment 1 Agostino Sarubbo gentoo-dev 2022-07-18 06:49:16 UTC
Created attachment 792080 [details]
build.log.xz

build log and emerge --info (compressed because it exceeds attachment limit, use 'xzless' to read it)
Comment 2 Agostino Sarubbo gentoo-dev 2022-07-18 06:49:18 UTC
Error(s) that match a know pattern in addition to what has been reported in the summary:


FAILED: client/CMakeFiles/odamex.dir/src/cl_parse.cpp.o 
/var/tmp/portage/games-engines/odamex-10.0.0/work/odamex-src-10.0.0/client/src/cl_parse.cpp:2287:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
Comment 3 Agostino Sarubbo gentoo-dev 2022-07-26 09:01:47 UTC
Here is a bit of explanation:

-Werror=lto-type-mismatch:
User to find possible runtime issues in packages. It likely means the package is unsafe to build & use with LTO.
For projects using the same identifier but with different types across different files, they must be fixed to be consistent across the codebase.

-Werror=odr:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO. C++ code must comply with the One Definition Rule (ODR) - see https://en.cppreference.com/w/cpp/language/definition#One_Definition_Rule.

-Werror=strict-aliasing:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO.

Workarounds:
- If upstream is friendly and still active, file a bug upstream. For emulators, codecs, games, or multimedia packages, it may be worth just applying a workaround instead, as upstreams sometimes aren't receptive to these bugs (VALID FOR ALL).
- Use the new 'filter-lto' from flag-o-matic.eclass as it's likely to be unsafe with LTO (VALID FOR lto-type-mismatch - odr).
- Fix it yourself if interested, of course (VALID FOR ALL).
- Append-flags -fno-strict-aliasing (VALID FOR strict-aliasing).
- Use memcpy() but a union is sometimes suitable too (VALID FOR strict-aliasing).
- -fstrict-aliasing is implied by -O2, so this must be addressed in some form (VALID FOR strict-aliasing).

See also: https://marc.info/?l=gentoo-dev&m=165639574126280&w=2
Comment 4 Mike Wood 2023-05-25 22:04:31 UTC
This package version is no longer available in portage. This bug may be a candidate for closure.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-05-25 23:13:35 UTC
(In reply to Mike Wood from comment #4)
> This package version is no longer available in portage. This bug may be a
> candidate for closure.

Have you checked if the bug still applies to the newer version (tried to reproduce)?
Comment 6 Kostadin Shishmanov 2023-11-17 10:40:59 UTC
Created attachment 874922 [details]
build log compressed with xz

Still reproducible on 10.4.0

/var/tmp/portage/games-engines/odamex-10.4.0/work/odamex-src-10.4.0/client/src/cl_parse.cpp:2357:26: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
 2357 |                         *(int*)&sector->gravity = msg->sector().gravity();
      |                          ^~~~~~~~~~~~~~~~~~~~~~
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-17 14:01:38 UTC
(In reply to Sam James from comment #5)
> (In reply to Mike Wood from comment #4)
> > This package version is no longer available in portage. This bug may be a
> > candidate for closure.
> 
> Have you checked if the bug still applies to the newer version (tried to
> reproduce)?

To be clear, I had no reason to believe it was fixed, and I suspected they were just asking because the exact version was no longer in tree.
Comment 8 Pacho Ramos gentoo-dev 2023-11-24 13:01:02 UTC
Could you please report the bug to upstream too?

Thanks
Comment 9 Agostino Sarubbo gentoo-dev 2024-03-03 08:27:08 UTC
lto_tinderbox has reproduced this issue with version 10.4.0-r1 - Updating summary.
Comment 11 James Le Cuirot gentoo-dev 2024-03-17 23:20:56 UTC
There are actually 3 aliasing issues. I've fixed them up, and they seem to work fine, but I am unsure, so I'll run them by upstream before committing anything here.

Somewhat depressingly, the package is rather broken anyway. Someone outside the games team took it upon themselves to bump it to wxGTK 3.2 when that causes odalaunch to crash. I'd previously made the same mistake myself, but at least I'm on the team! Trying to join a server from odalaunch also doesn't work because it uses the wrong path. I'll get these fixed up too.
Comment 12 James Le Cuirot gentoo-dev 2024-03-18 22:20:32 UTC
I'd appreciate some extra eyes over my changes, as I've not tried to fix this kind of issue before.
Comment 13 Larry the Git Cow gentoo-dev 2024-03-19 23:04:10 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f8fd17d55d0fe0cbca82eda3464338508b6bf25

commit 9f8fd17d55d0fe0cbca82eda3464338508b6bf25
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2024-03-19 23:03:42 +0000
Commit:     James Le Cuirot <chewi@gentoo.org>
CommitDate: 2024-03-19 23:03:42 +0000

    games-engines/odamex: Fix launcher path issue, fix LTO, fix wxGTK crash
    
    We've already seen that odalaunch crashes with wxGTK 3.2 so keep it at 3.0. I
    have looked into this, and it relates to the server list sorting, but I cannot
    figure it out.
    
    Closes: https://bugs.gentoo.org/858722
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>

 games-engines/odamex/files/odamex-lto.patch        | 41 ++++++++++++++
 .../odamex/files/odamex-odalaunch-prefix.patch     | 64 ++++++++++++++++++++++
 ...ex-10.4.0-r1.ebuild => odamex-10.4.0-r2.ebuild} |  6 +-
 3 files changed, 109 insertions(+), 2 deletions(-)