Skip to content

Bug: Segmentation fault in Exx_LRI::cal_exx_ions during hybrid functional (LRC_WPBE) SCF calculation for 2D h-BN #6999

@AsTonyshment

Description

@AsTonyshment

Description

I encountered a segmentation fault while performing an SCF calculation for a 2D hexagonal boron nitride (h-BN) system using the lrc_wpbe hybrid functional.

Under the default exx_erfc_omega = 0.3 and a 24x24x1 K-point grid, the program runs normally (though it struggles to converge, which is expected for hybrid functionals). However, the program crashes with a segmentation fault (KILLED BY SIGNAL: 6 (Aborted)) under two specific parameter modifications:

  1. Case A: Changing exx_erfc_omega to 0.126 (keeping the 24x24x1 K-point grid).
  2. Case B: Keeping the default exx_erfc_omega = 0.3, but reducing the K-point grid to 8x8x1.

To Reproduce

Run the SCF calculation using the provided input files.

1. INPUT
INPUT_PARAMETERS
pseudo_dir            ./
orbital_dir           ./
basis_type            lcao
ecutwfc               100
calculation           scf
scf_thr               1e-7
device                cpu

dft_functional        lrc_wpbe
exx_erfc_omega        0.126
2. KPT
K_POINTS
0
Gamma
24 24 1 0 0 0
3. STRU
ATOMIC_SPECIES
B  10.8100 B_ONCV_PBE-1.0.upf upf201
N  14.0070 N_ONCV_PBE-1.0.upf upf201

NUMERICAL_ORBITAL
B_gga_10au_100Ry_2s2p1d.orb
N_gga_10au_100Ry_2s2p1d.orb

LATTICE_CONSTANT
1.8897260000

LATTICE_VECTORS
        2.5127465422        0.0000000000        0.0000000000
       -1.2563732711        2.1761025724        0.0000000000
        0.0000000000        0.0000000000       30.0000000000

ATOMIC_POSITIONS
Direct

B #label
0.0000   #magnetism
1 #number of atoms
        0.0000000000        0.0000000000        0.5000000000 m 0 0 0

N #label
0.0000   #magnetism
1 #number of atoms
        0.3333333333        0.6666666667        0.5000000000 m 0 0 0

Error Logs

In both failure cases, the program aborts right before the SCF iterations start, immediately after initializing potentials.

Standard Output
...
 DONE(0.279238    SEC) : INIT PLANEWAVE
 START CHARGE      : atomic
 DONE(0.416281    SEC) : CHARGE
 DONE(12.0791     SEC) : POTENTIALS

 ================================================================
 SELF-CONSISTENT: 
 ================================================================
terminate called recursively
terminate called recursively
terminate called recursively

===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   RANK 0 PID 3579772 RUNNING AT cn81042
=   KILLED BY SIGNAL: 6 (Aborted)
===================================================================================

Source Code Investigation

To narrow down the issue, I inserted std::cerr print statements inside the Exact Exchange evaluation interface for LibRI (source/source_lcao/module_ri/Exx_LRI.hpp).

I found that the segmentation fault is triggered exactly at the this->exx_objs[settings_list.first].cv.cal_Cs_dCs(...) function call within the cal_exx_ions method. Specifically, the crash happens here:

// source/source_lcao/module_ri/Exx_LRI.hpp (around line 140)
std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
    std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
        Cs_dCs = this->exx_objs[settings_list.first].cv.cal_Cs_dCs(
            ucell,
            list_As_Cs.first, list_As_Cs.second[0],
            {{"cal_dC",PARAM.inp.cal_force||PARAM.inp.cal_stress},
            {"writable_Cws",true}, {"writable_dCws",true}, {"writable_Vws",false}, {"writable_dVws",false}});

A print statement immediately before this block executes successfully, but a print statement immediately after it is never reached. While the root cause might stem from memory allocation or data structures passed into cal_Cs_dCs earlier in the workflow, this is the exact point of failure.

Environment

  • ABACUS Version: v3.9.0.25 (Branch: develop)
  • Commit: d999af798 (Wed Mar 4 16:09:43 2026 +0800)
  • Hardware: CPU / Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz (x2)
  • Compiler: IntelLLVM (icpx) 2024.0.2 (-fiopenmp enabled)
  • MPI: Intel MPI (API Version 3.1)
  • MKL: Intel MKL 2024.0 (libmkl_intel_lp64.so)
  • Libxc: v6.2.2
  • ELPA: Enabled (libelpa_openmp.so)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugsBugs that only solvable with sufficient knowledge of DFT

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions