Summary: | devel/qt5-script: clang optimization miscompiles qtscript | ||||||
---|---|---|---|---|---|---|---|
Product: | Ports & Packages | Reporter: | ice | ||||
Component: | Individual Port(s) | Assignee: | freebsd-kde (group) <kde> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Only Me | CC: | arrowd, jfc, yuri | ||||
Priority: | --- | Flags: | arrowd:
maintainer-feedback+
|
||||
Version: | Latest | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Bug Depends on: | |||||||
Bug Blocks: | 265989 | ||||||
Attachments: |
|
Description
ice
2024-02-23 10:00:57 UTC
Should this also be reported to Clang, since it's Clang that miscompiles devel/qt5-script. My first impression is clang is within its rights to break this code. The JS implementation tries to store metadata bits in the low bits of a pointer type. The compiler is allowed to assume that the low bits of a pointer value are zero. (Assuming the pointed-to type has alignment rules, which is normally the case.) LLVM itself uses a wrapper class instead of an illegal pointer value. The wrapper class stores the pointer+tag combination as an integer and provides a getter method to return an untagged pointer. (In reply to John F. Carr from comment #2) I see. In this case this should be reported to the devel/qt5-script upstream. They should stop using hacks and do the same thing properly. Yuri Here is an example: struct S { long alignment; int this_lowbit(); }; int S::this_lowbit() { return reinterpret_cast<signed long>(this) & 1; } The method this_lowbit always returns zero with optimization enabled. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=9e3ff8f0b99e7b3074f3e83c954a0395185f63f0 commit 9e3ff8f0b99e7b3074f3e83c954a0395185f63f0 Author: Tomas Tevesz <ice@extreme.hu> AuthorDate: 2024-03-22 21:16:49 +0000 Commit: Gleb Popov <arrowd@FreeBSD.org> CommitDate: 2024-03-22 21:18:36 +0000 devel/qt5-script: Prevent clang from optimizing the code with undefined behavior PR: 277236 Obtained from: OpenBSD ports devel/qt5-script/Makefile | 2 +- ...criptcore_JavaScriptCore_interpreter_CallFrame.h (new) | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) Pushed, thanks. |