Bug 269489 - emulators/rpcs3: clang 15 crashes during build
Summary: emulators/rpcs3: clang 15 crashes during build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dimitry Andric
URL: https://pkg-status.freebsd.org/beefy1...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-11 11:06 UTC by Jan Beich
Modified: 2023-05-03 10:43 UTC (History)
1 user (show)

See Also:


Attachments
faudio_enumerator.cpp (preprocessed, compressed) (448.08 KB, application/zstd)
2023-02-11 11:09 UTC, Jan Beich
no flags Details
command line arguments (preprocessed, specific to clang 15) (9.40 KB, text/plain)
2023-02-11 11:12 UTC, Jan Beich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2023-02-11 11:06:44 UTC
Assertion failed: (It != IISet.rend() && "ConstantExpr marked IsImmediateInvocation should " "be present"), function RemoveImmediateInvocation, file /usr/src/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp, line 17572.
[...]
 #0 0x000000000578e471 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/c+++0x578e471)
 #1 0x000000000578c22a llvm::sys::RunSignalHandlers() (/usr/bin/c+++0x578c22a)
 #2 0x000000000578ec0d SignalHandler(int) Signals.cpp:0:0
 #3 0x000000082b3420ef handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
 #4 0x000000082b3415c8 thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1
 #5 0x0000000827e1f8f3 ([vdso]+0x2d3)
 #6 0x000000082e8bd4da _thr_kill /usr/obj/usr/src/amd64.amd64/lib/libc/thr_kill.S:4:0
 #7 0x000000082e82aea4 _raise /usr/src/lib/libc/gen/raise.c:0:10
 #8 0x000000082e8e8f49 abort /usr/src/lib/libc/stdlib/abort.c:73:17
 #9 0x000000082e80c6d1 (/lib/libc.so.7+0x996d1)
#10 0x0000000003dc6fb3 clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::__1::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>>>*>)::ComplexRemove>::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) SemaExpr.cpp:0:0
#11 0x0000000003dac35d clang::TreeTransform<RemoveNestedImmediateInvocation(clang::Sema&, clang::Sema::ExpressionEvaluationContextRecord&, std::__1::reverse_iterator<llvm::PointerIntPair<clang::ConstantExpr*, 1u, unsigned int, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>, llvm::PointerIntPairInfo<clang::ConstantExpr*, 1u, llvm::PointerLikeTypeTraits<clang::ConstantExpr*>>>*>)::ComplexRemove>::TransformCXXConstructExpr(clang::CXXConstructExpr*) SemaExpr.cpp:0:0
#12 0x0000000003d95614 clang::Sema::PopExpressionEvaluationContext() (/usr/bin/c+++0x3d95614)
#13 0x000000000386dd18 clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/c+++0x386dd18)
#14 0x00000000031b4e6e clang::FrontendAction::Execute() (/usr/bin/c+++0x31b4e6e)
#15 0x000000000313ba5f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/c+++0x313ba5f)
#16 0x0000000003281d8d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/bin/c+++0x3281d8d)
#17 0x0000000002637828 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/c+++0x2637828)
#18 0x000000000264656b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
Comment 1 Jan Beich freebsd_committer freebsd_triage 2023-02-11 11:09:27 UTC
Created attachment 240079 [details]
faudio_enumerator.cpp (preprocessed, compressed)

Affects multiple files, so let's inspect one of the smallest.

https://github.com/RPCS3/rpcs3/blob/master/rpcs3/Emu/Audio/FAudio/faudio_enumerator.cpp

FAILED: rpcs3/Emu/CMakeFiles/rpcs3_emu.dir/Audio/FAudio/faudio_enumerator.cpp.o
/usr/bin/c++ -DDATADIR=\"/usr/local/share/rpcs3\" -DGLX_GLXEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES -DHAVE_FAUDIO -DHAVE_LIBEVDEV -DHAVE_VULKAN -DHAVE_X11 -DLLVM_AVAILABLE -DSOUNDTOUCH_ALLOW_SSE -DSOUNDTOUCH_FLOAT_SAMPLES -DST_NO_EXCEPTION_HANDLING -DUSE_MULTICH_ALWAYS -DVK_USE_PLATFORM_WAYLAND_KHR -DWC_NO_HARDEN -Irpcs3 -I. -I3rdparty/yaml-cpp/yaml-cpp/include -I/usr/local/include/AL -I3rdparty/cubeb/cubeb/include -I../.build/exports -I3rdparty/SoundTouch/soundtouch/include -I3rdparty/stblib/include -Illvm/include -I../.build/3rdparty/llvm_build/include -I3rdparty/asmjit/asmjit/src -I3rdparty/GL -I3rdparty/glslang/glslang/SPIRV/.. -I../.build/include -I3rdparty/SPIRV/SPIRV-Tools/include -I3rdparty/SPIRV/SPIRV-Headers/include -I3rdparty/wolfssl/wolfssl -I../.build/3rdparty/wolfssl/wolfssl -isystem /usr/local/include/libevdev-1.0 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -Wl,--exclude-libs,ALL -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -pthread -Wall -fno-exceptions -fstack-protector -msse -msse2 -mcx16 -Werror=old-style-cast -Werror=sign-compare -Werror=reorder -Werror=return-type -Werror=overloaded-virtual -Werror=missing-noreturn -Wunused-parameter -Wignored-qualifiers -Wredundant-move -Wcast-qual -Wdeprecated-copy -Wtautological-compare -Wempty-body -Wredundant-decls -Wstrict-aliasing=1 -Werror=inconsistent-missing-override -fconstexpr-steps=16777216 -Wno-unused-lambda-capture -Wno-unused-private-field -Wno-delete-non-virtual-dtor -Wno-unused-command-line-argument -std=gnu++20 -MD -MT rpcs3/Emu/CMakeFiles/rpcs3_emu.dir/Audio/FAudio/faudio_enumerator.cpp.o -MF rpcs3/Emu/CMakeFiles/rpcs3_emu.dir/Audio/FAudio/faudio_enumerator.cpp.o.d -o rpcs3/Emu/CMakeFiles/rpcs3_emu.dir/Audio/FAudio/faudio_enumerator.cpp.o -c rpcs3/Emu/Audio/FAudio/faudio_enumerator.cpp
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-02-11 11:12:26 UTC
Created attachment 240080 [details]
command line arguments (preprocessed, specific to clang 15)
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2023-02-11 14:58:59 UTC
This appears to be caused by <https://github.com/llvm/llvm-project/commit/1c55f05c6a6>. It still reproduces with the latest upstream main branch. I will minimize and submit a bug upstream.
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2023-02-11 17:16:43 UTC
This was reported a while before, in https://github.com/llvm/llvm-project/issues/58207. Looks like the minimized test case is mostly the same.

I've pinged the author of the commit in the upstream bug report, we'll see if it leads to a quick response. Otherwise, I can revert the upstream commit for now.
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-04-28 14:13:28 UTC
A commit in branch main references this bug:

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

commit 56f2446575c78d962b6dda5e3310bec078622f3d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-28 14:08:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-04-28 14:09:45 +0000

    Apply clang fix for assertion building emulators/rpcs3

    Merge commit a5e1a93ea10f from llvm-project (by Mariya Podchishchaeva):

      [clang] Fix crash when handling nested immediate invocations

      Before this patch it was expected that if there was several immediate
      invocations they all belong to the same expression evaluation context.
      During parsing of non local variable initializer a new evaluation context is
      pushed, so code like this
      ```
      namespace scope {
      struct channel {
          consteval channel(const char* name) noexcept { }
      };
      consteval const char* make_channel_name(const char* name) { return name;}

      channel rsx_log(make_channel_name("rsx_log"));
      }
      ```
      produced a nested immediate invocation whose subexpressions are attached
      to different expression evaluation contexts. The constructor call
      belongs to TU context and `make_channel_name` call to context of
      variable initializer.

      This patch removes this assumption and adds tracking of previously
      failed immediate invocations, so it is possible when handling an
      immediate invocation th check that its subexpressions from possibly another
      evaluation context contains errors and not produce duplicate
      diagnostics.

      Fixes https://github.com/llvm/llvm-project/issues/58207

      Reviewed By: aaron.ballman, shafik

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

    PR:             269489
    MFC after:      3 days

 .../llvm-project/clang/include/clang/Sema/Sema.h   |  3 +++
 contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp   | 26 +++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-05-03 10:42:14 UTC
A commit in branch stable/13 references this bug:

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

commit a7e6ae2dc64b313520adc6141e4cffb1fa962b66
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-28 14:08:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-03 08:18:46 +0000

    Apply clang fix for assertion building emulators/rpcs3

    Merge commit a5e1a93ea10f from llvm-project (by Mariya Podchishchaeva):

      [clang] Fix crash when handling nested immediate invocations

      Before this patch it was expected that if there was several immediate
      invocations they all belong to the same expression evaluation context.
      During parsing of non local variable initializer a new evaluation context is
      pushed, so code like this
      ```
      namespace scope {
      struct channel {
          consteval channel(const char* name) noexcept { }
      };
      consteval const char* make_channel_name(const char* name) { return name;}

      channel rsx_log(make_channel_name("rsx_log"));
      }
      ```
      produced a nested immediate invocation whose subexpressions are attached
      to different expression evaluation contexts. The constructor call
      belongs to TU context and `make_channel_name` call to context of
      variable initializer.

      This patch removes this assumption and adds tracking of previously
      failed immediate invocations, so it is possible when handling an
      immediate invocation th check that its subexpressions from possibly another
      evaluation context contains errors and not produce duplicate
      diagnostics.

      Fixes https://github.com/llvm/llvm-project/issues/58207

      Reviewed By: aaron.ballman, shafik

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

    PR:             269489
    MFC after:      3 days

    (cherry picked from commit 56f2446575c78d962b6dda5e3310bec078622f3d)

 .../llvm-project/clang/include/clang/Sema/Sema.h   |  3 +++
 contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp   | 26 +++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-05-03 10:42:15 UTC
A commit in branch stable/12 references this bug:

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

commit 44f4aaee6be33d7e2afe3ce0f0fb856e83da01d7
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-28 14:08:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-03 08:25:29 +0000

    Apply clang fix for assertion building emulators/rpcs3

    Merge commit a5e1a93ea10f from llvm-project (by Mariya Podchishchaeva):

      [clang] Fix crash when handling nested immediate invocations

      Before this patch it was expected that if there was several immediate
      invocations they all belong to the same expression evaluation context.
      During parsing of non local variable initializer a new evaluation context is
      pushed, so code like this
      ```
      namespace scope {
      struct channel {
          consteval channel(const char* name) noexcept { }
      };
      consteval const char* make_channel_name(const char* name) { return name;}

      channel rsx_log(make_channel_name("rsx_log"));
      }
      ```
      produced a nested immediate invocation whose subexpressions are attached
      to different expression evaluation contexts. The constructor call
      belongs to TU context and `make_channel_name` call to context of
      variable initializer.

      This patch removes this assumption and adds tracking of previously
      failed immediate invocations, so it is possible when handling an
      immediate invocation th check that its subexpressions from possibly another
      evaluation context contains errors and not produce duplicate
      diagnostics.

      Fixes https://github.com/llvm/llvm-project/issues/58207

      Reviewed By: aaron.ballman, shafik

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

    PR:             269489
    MFC after:      3 days

    (cherry picked from commit 56f2446575c78d962b6dda5e3310bec078622f3d)

 .../llvm-project/clang/include/clang/Sema/Sema.h   |  3 +++
 contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp   | 26 +++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)