root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.63k stars 1.26k forks source link

LLVM assertion failure in HandleUnionActiveMemberChange #13019

Closed pikacic closed 3 months ago

pikacic commented 1 year ago

Check duplicate issues.

Describe the bug

We are using a customized version of https://github.com/therocode/meta_enum that fails with ROOT v6-28-00-patches.

When including the attached file I get an assertion failure from LLVM:

root [0] #include "custom_meta_enum_test.hpp"
root.exe: /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-28-00-patches/src/ROOT/v6-28-00-patches/interpreter/llvm/src/tools/clang/lib/AST/ExprConstant.cpp:5921: bool HandleUnionActiveMemberChange({anonymous}::EvalInfo&, const clang::Expr*, const {anonymous}::LValue&): Assertion `declaresSameEntity(FD, LHS.Designator.Entries[PathLength] .getAsBaseOrMember().getPointer())' failed.

By trial and errors I managed to find the bit of code that triggers the assertion error and I embedded the workaround in the attached file:

root [0] #define WORKAROUND
root [1] #include "custom_meta_enum_test.hpp"
root [2] 

The difference that works around the issue is basically

+++ b/Kernel/LHCbKernel/include/Kernel/meta_enum.h
@@ -130,10 +130,11 @@ namespace meta_enum_internal {
       currentStringStart = currentStringEnd;
     }
     for ( size_t i = 0; i < memberStrings.size(); ++i ) {
-      result.members[i].name  = parseEnumMemberName( memberStrings[i] );
+      auto name = parseEnumMemberName( memberStrings[i] );
+      result.members[i].name  = name;
       result.members[i].value = std::get<1>( values )[i];
       if ( std::get<0>( values ) == std::get<1>( values )[i] ) {
-        result.defaultString = result.members[i].name;
+        result.defaultString = name;
         result.defaultValue  = std::get<0>( values );
       }
     }

custom_meta_enum_test.hpp.gz

What is the expected behaviour?

No response

How to reproduce?

From lxplus9.cern.ch:

❯ . /cvmfs/sft-nightlies.cern.ch/lcg/views/dev4/Mon/x86_64-el9-gcc13-dbg/setup.sh
❯ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/05                        https://root.cern |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jun 10 2023, 00:28:00                 |
  | From heads/v6-28-00-patches@v6-28-04-94-gb7de1efc73              |
  | With g++ (GCC) 13.1.0                                            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] #include "custom_meta_enum_test.hpp"
root.exe: /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-v6-28-00-patches/src/ROOT/v6-28-00-patches/interpreter/llvm/src/tools/clang/lib/AST/ExprConstant.cpp:5921: bool HandleUnionActiveMemberChange({anonymous}::EvalInfo&, const clang::Expr*, const {anonymous}::LValue&): Assertion `declaresSameEntity(FD, LHS.Designator.Entries[PathLength] .getAsBaseOrMember().getPointer())' failed.

The workaround can be demonstrated with:

❯ . /cvmfs/sft-nightlies.cern.ch/lcg/views/dev4/Mon/x86_64-el9-gcc13-dbg/setup.sh
❯ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/05                        https://root.cern |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jun 10 2023, 00:28:00                 |
  | From heads/v6-28-00-patches@v6-28-04-94-gb7de1efc73              |
  | With g++ (GCC) 13.1.0                                            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] #define WORKAROUND
root [1] #include "custom_meta_enum_test.hpp"
root [2] 

ROOT version

v6-28-00-patches@v6-28-04-94-gb7de1efc73

How did you install ROOT?

LCG nightly builds in /cvmfs/sft-nightlies.cern.ch

Which operating system are you using?

Linux Alma 9

Additional context

No response

dpiparo commented 3 months ago

Apologies for coming back to this so late. I am closing since it's fixed in 6.30, currently used int LHCb's stacks, and 6.32, which relies on llvm16. Please feel free to re-open if this problem is hitting again the experiments.