Bug 262608 - Clang assertion failed in 14-CURRENT compiling old versions of Wine
Summary: Clang assertion failed in 14-CURRENT compiling old versions of Wine
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-17 02:58 UTC by Damjan Jovanovic
Modified: 2022-03-27 17:25 UTC (History)
2 users (show)

See Also:
dim: mfc-stable13+
dim: mfc-stable12+


Attachments
Preprocessed source file and run script (485.17 KB, application/x-bzip)
2022-03-17 02:58 UTC, Damjan Jovanovic
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Damjan Jovanovic 2022-03-17 02:58:43 UTC
Created attachment 232494 [details]
Preprocessed source file and run script

When building Wine from before commit 077b4391d442e927a2a59b5afb244355b0634aaa (release 3.20 and earlier), Clang on 14-CURRENT gets this assertion failure:

Assertion failed: (Offset.second.isStrictlyPositive() && "Expected strictly positive multiplier for offset."), function getSalvageOpsForGEP, file /usr/src/contrib/llvm-project/llvm/lib/Transforms/Utils/Local.cpp, line 1813.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: cc -m64 -c -o tmarshal.o tmarshal.c -I. -I../../include -D__WINESRC__ -D_OLEAUT32_ -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Wno-pragma-pack -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla -fcommon -Wwrite-strings -Wpointer-arith -gdwarf-2 -gstrict-dwarf -g -O2
1.	<eof> parser at end of file
2.	Optimizer
 #0 0x0000000004f52150 PrintStackTrace /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
 #1 0x0000000004f50465 RunSignalHandlers /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:98:18
 #2 0x0000000004ee771e HandleCrash /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:5
 #3 0x0000000004ee78e3 CrashRecoverySignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:51
 #4 0x000000082925f580 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
 #5 0x000000082925eb3f thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1
 #6 0x00007ffffffff8a3 ([vdso]+0x2d3)
 #7 0x000000082a02531a __sys_thr_kill /usr/obj/usr/src/amd64.amd64/lib/libc/thr_kill.S:4:0
 #8 0x0000000829f9d8b4 _raise /usr/src/lib/libc/gen/raise.c:0:10
 #9 0x000000082a04f089 abort /usr/src/lib/libc/stdlib/abort.c:73:17
#10 0x0000000829f80651 (/lib/libc.so.7+0x98651)
#11 0x0000000006212779 set_size /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:85:5
#12 0x0000000006212779 push_back /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:549:11
#13 0x0000000006212779 getSalvageOpsForGEP /usr/src/contrib/llvm-project/llvm/lib/Transforms/Utils/Local.cpp:1811:22
#14 0x00000000062122bf salvageDebugInfoImpl /usr/src/contrib/llvm-project/llvm/lib/Transforms/Utils/Local.cpp:1936:9
#15 0x0000000006211e49 salvageDebugInfoForDbgValues /usr/src/contrib/llvm-project/llvm/lib/Transforms/Utils/Local.cpp:1759:22
#16 0x000000000620bf9a isSmall /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:129:39
#17 0x000000000620bf9a ~SmallVectorImpl /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:581:16
#18 0x000000000620bf9a ~SmallVector /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1176:3
#19 0x000000000620bf9a salvageDebugInfo /usr/src/contrib/llvm-project/llvm/lib/Transforms/Utils/Local.cpp:1732:1
#20 0x0000000005f928b2 processNode /usr/src/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:0:7
#21 0x0000000005f90889 run /usr/src/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:0:18
#22 0x0000000005f90478 run /usr/src/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:1635:7
#23 0x0000000002c6f422 /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#24 0x0000000004bdf162 operator= /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:488:13
#25 0x0000000004bdf162 operator= /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:155:7
#26 0x0000000004bdf162 run /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:509:16
#27 0x0000000002c6f662 /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#28 0x0000000004be1d2c operator= /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:488:13
#29 0x0000000004be1d2c operator= /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:155:7
#30 0x0000000004be1d2c run /usr/src/contrib/llvm-project/llvm/lib/IR/PassManager.cpp:117:14
#31 0x0000000002c72482 /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#32 0x0000000004bde4c7 operator= /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:488:13
#33 0x0000000004bde4c7 operator= /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:155:7
#34 0x0000000004bde4c7 run /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:509:16
#35 0x0000000002c65d4d isSmall /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:194:33
#36 0x0000000002c65d4d ~SmallPtrSetImplBase /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:82:10
#37 0x0000000002c65d4d ~PreservedAnalyses /usr/src/contrib/llvm-project/llvm/include/llvm/IR/PassManager.h:155:7
#38 0x0000000002c65d4d EmitAssemblyWithNewPassManager /usr/src/contrib/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1494:5
#39 0x0000000002c60bf2 EmitBackendOutput /usr/src/contrib/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:0:15
#40 0x0000000002f44ec6 reset /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__memory/unique_ptr.h:315:28
#41 0x0000000002f44ec6 ~unique_ptr /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__memory/unique_ptr.h:272:19
#42 0x0000000002f44ec6 HandleTranslationUnit /usr/src/contrib/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:334:7
#43 0x000000000341d884 begin /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/vector:1539:30
#44 0x000000000341d884 finalize<std::__1::vector<std::__1::unique_ptr<clang::TemplateInstantiationCallback, std::__1::default_delete<clang::TemplateInstantiationCallback> >, std::__1::allocator<std::__1::unique_ptr<clang::TemplateInstantiationCallback, std::__1::default_delete<clang::TemplateInstantiationCallback> > > > > /usr/src/contrib/llvm-project/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#45 0x000000000341d884 ParseAST /usr/src/contrib/llvm-project/clang/lib/Parse/ParseAST.cpp:178:3
#46 0x0000000002e8546f Execute /usr/src/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:10
#47 0x0000000002e0ebff getPtr /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:274:42
#48 0x0000000002e0ebff operator bool /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:236:16
#49 0x0000000002e0ebff ExecuteAction /usr/src/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:974:23
#50 0x0000000002f3e93b ExecuteCompilerInvocation /usr/src/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:25
#51 0x00000000024631a1 cc1_main /usr/src/contrib/llvm-project/clang/tools/driver/cc1_main.cpp:246:15
#52 0x00000000024707b2 ExecuteCC1Tool /usr/src/contrib/llvm-project/clang/tools/driver/driver.cpp:338:12
#53 0x0000000002cd8af7 operator() /usr/src/contrib/llvm-project/clang/lib/Driver/Job.cpp:405:30
#54 0x0000000002cd8af7 callback_fn<(lambda at /usr/src/contrib/llvm-project/clang/lib/Driver/Job.cpp:405:22)> /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/STLExtras.h:177:12
#55 0x0000000004ee7654 operator() /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/STLExtras.h:0:12
#56 0x0000000004ee7654 RunSafely /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:425:3
#57 0x0000000002cd86fc Execute /usr/src/contrib/llvm-project/clang/lib/Driver/Job.cpp:405:7
#58 0x0000000002ca92d1 ExecuteCommand /usr/src/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:196:15
#59 0x0000000002ca978f ExecuteJobs /usr/src/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:249:13
#60 0x0000000002cbd8dc empty /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:73:47
#61 0x0000000002cbd8dc ExecuteCompilation /usr/src/contrib/llvm-project/clang/lib/Driver/Driver.cpp:1556:23
cc: error: clang frontend command failed with exit code 134 (use -v to see invocation)
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/tmarshal-797721.c
cc: note: diagnostic msg: /tmp/tmarshal-797721.sh
cc: note: diagnostic msg: 

********************
*** Error code 134
Comment 1 commit-hook freebsd_committer freebsd_triage 2022-03-19 20:00:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1b3bef43e3cb7fb0ab49b813839915514c1134cc

commit 1b3bef43e3cb7fb0ab49b813839915514c1134cc
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-03-19 19:59:04 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-03-19 19:59:04 +0000

    Apply llvm fix for assertion compiling certain versions of Wine

    Merge commit b9ca73e1a8fd from llvm git (by Stephen Tozer):

      [DebugInfo] Correctly handle arrays with 0-width elements in GEP salvaging

      Fixes an issue where GEP salvaging did not properly account for GEP
      instructions which stepped over array elements of width 0 (effectively a
      no-op). This unnecessarily produced long expressions by appending
      `... + (x * 0)` and potentially extended the number of SSA values used
      in the dbg.value. This also erroneously triggered an assert in the
      salvage function that the element width would be strictly positive.
      These issues are resolved by simply ignoring these useless operands.

      Reviewed By: aprantl

      Differential Revision: https://reviews.llvm.org/D111809

    PR:             262608
    Reported by:    Damjan Jovanovic <damjan.jov@gmail.com>
    MFC after:      3 days

 contrib/llvm-project/llvm/lib/IR/Operator.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-03-23 19:59:45 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=420907a4387f4337e481797e96093c6bdee2fd2c

commit 420907a4387f4337e481797e96093c6bdee2fd2c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-03-19 19:59:04 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-03-23 19:57:46 +0000

    Apply llvm fix for assertion compiling certain versions of Wine

    Merge commit b9ca73e1a8fd from llvm git (by Stephen Tozer):

      [DebugInfo] Correctly handle arrays with 0-width elements in GEP salvaging

      Fixes an issue where GEP salvaging did not properly account for GEP
      instructions which stepped over array elements of width 0 (effectively a
      no-op). This unnecessarily produced long expressions by appending
      `... + (x * 0)` and potentially extended the number of SSA values used
      in the dbg.value. This also erroneously triggered an assert in the
      salvage function that the element width would be strictly positive.
      These issues are resolved by simply ignoring these useless operands.

      Reviewed By: aprantl

      Differential Revision: https://reviews.llvm.org/D111809

    PR:             262608
    Reported by:    Damjan Jovanovic <damjan.jov@gmail.com>
    MFC after:      3 days

    (cherry picked from commit 1b3bef43e3cb7fb0ab49b813839915514c1134cc)

 contrib/llvm-project/llvm/lib/IR/Operator.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-03-23 19:59:46 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c4cacdd447bae53964f439cb94acd9f5cc6a4c14

commit c4cacdd447bae53964f439cb94acd9f5cc6a4c14
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-03-19 19:59:04 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-03-23 19:57:26 +0000

    Apply llvm fix for assertion compiling certain versions of Wine

    Merge commit b9ca73e1a8fd from llvm git (by Stephen Tozer):

      [DebugInfo] Correctly handle arrays with 0-width elements in GEP salvaging

      Fixes an issue where GEP salvaging did not properly account for GEP
      instructions which stepped over array elements of width 0 (effectively a
      no-op). This unnecessarily produced long expressions by appending
      `... + (x * 0)` and potentially extended the number of SSA values used
      in the dbg.value. This also erroneously triggered an assert in the
      salvage function that the element width would be strictly positive.
      These issues are resolved by simply ignoring these useless operands.

      Reviewed By: aprantl

      Differential Revision: https://reviews.llvm.org/D111809

    PR:             262608
    Reported by:    Damjan Jovanovic <damjan.jov@gmail.com>
    MFC after:      3 days

    (cherry picked from commit 1b3bef43e3cb7fb0ab49b813839915514c1134cc)

 contrib/llvm-project/llvm/lib/IR/Operator.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Comment 4 Damjan Jovanovic 2022-03-27 17:25:12 UTC
Thank you Dimitry, you fixed this so quickly!