Segmentation fault with QNs

Hi!

I’ve encountered a strange bug I can’t seem to get rid of. It could just be me doing something silly so I figured it would be best to ask here and find out.
Specifically, when using different spins and quantum numbers the code will crash (choice of segfault, bad_alloc or bus error, all pointing to a memory issue). A simple example that produces the error on my system (using either g++ 13.1.1 or icpx 2023.1.0 - linked against MKL in both cases).

itensor::Args args({ "ConserveSz", true, "ConserveQNs", false });
itensor::SpinOneSite SL(args);
itensor::SpinHalfSite SR(args);
itensor::ITensor test = 2.0 * SL.op("Sz", args) * SR.op("Sz", args);

The fact that it happens with 2 compilers seems to point to an issue with ITensor, though interestingly I can’t replicate the issue in debug mode (granted I haven’t tried too hard so it may be possible, but debug mode is too slow for my simulations so that’s not quite as relevant to me). A short note, I tied with icpx and simply setting -O0 in release mode did not help when building the final code (I did not however recompile ITensor with it).

I was wondering if you have any insight into what the issue is and/or how to fix it, like I said, maybe I’m doing something I should not but am simply not aware of it.

The options.mk flags used are:

CCCOM=g++ -m64 -std=c++17 -fconcepts -fPIC
PLATFORM=mkl
BLAS_LAPACK_LIBFLAGS=-fopenmp -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_rt -lmkl_core -liomp5 -lpthread
BLAS_LAPACK_INCLUDEFLAGS=-I$(MKLROOT)/include
OPTIMIZATIONS=-O3 -DNDEBUG -Wall -Wno-unknown-pragmas -fopenmp -mfma -DMKL_LP64
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic

and

CCCOM=icpx -m64 -std=c++17 -fPIC
PLATFORM=mkl
BLAS_LAPACK_LIBFLAGS=-qopenmp -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_rt -lmkl_core -liomp5 -lpthread
BLAS_LAPACK_INCLUDEFLAGS=-I$(MKLROOT)/include
OPTIMIZATIONS=-O3 -DNDEBUG -Wall -Wno-unknown-pragmas -qopenmp -fma -DMKL_LP64
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic

got g++ and icpx respectively.

Edit:

After some further testing I can confirm that things appear to work correctly with gcc-11/icpc-2021. Nevertheless, it would probably be good to know what causes the problem with the newer compilers.

Any ideas would be appreciated. Thanks!

Perhaps someone else will have better insights, but this doesn’t crash for me (using MKL oneapi 2023 and GCC 11.3) with a release or debug build.

Something to note, and perhaps the root of this bug, is that {"ConserveSz", true, "ConserveQNs", false} is contradictory. ConserveSz implies ConserveQNs and will override ConserveQNs.
Maybe try with just itensor::Args args({ "ConserveSz", true}); (or false)?

Hi!

Thanks for the response, I spent some more time fiddling with the gcc-11 version and you are indeed correct, gcc-11/icpc-2021 seems to have no issues. This still begs the question of why it is broken with gcc-13/icpx-2023. Since this required fixing a bug in the actual project, I will edit the question accordingly to reflect that the issue appears only to be present with the newer compilers/libraries.

Regarding the conserve settings the Sz setting overrides the more general QN setting so that should have no impact here.