Linear *STATIC step: *EL FILE with SDV segfaults when the model has *DEPVAR (xstaten is never allocated in linstatic.c)

Summary

The trigger is a material with *DEPVAR but no nonlinear material law (no user material, no plasticity), so the *STATIC step runs through linstatic.c. If that step requests SDV on *EL FILE, ccx gets a segmentation fault when it computes the output. linstatic.c never allocates xstaten, the nodal array that resultsprint.f extrapolates the state variables into for the .frd file; nonlingeo.c does allocate it.

The same deck runs with *EL PRINT (SDV printed as 0), with *EL FILE without SDV, without *DEPVAR, and with NLGEOM; in each of those cases it finishes normally. Master (9ba5d76) still has the bug: linstatic.c still has no NNEW(xstaten,...).

Version

ccx 2.23 (conda-forge build pl5321h484372f_2, macOS arm64).

Already reported or fixed?

Not reported: there is no matching GitHub issue (open or closed) or open pull request in Dhondtguido/CalculiX, and no calculix.discourse.group topic (searched 19 Oct 2026). Not fixed: the routine involved is unchanged on master, and conda-forge’s latest 2.23 build (pl5321hd17ca8b_8, which carries about 40 extra patches) gives the same output.

Minimal input

sdv_file.inp:

*HEADING
Unit cube, linear elastic, *DEPVAR in the material, SDV requested on *EL FILE
*NODE
1, 0., 0., 0.
2, 1., 0., 0.
3, 1., 1., 0.
4, 0., 1., 0.
5, 0., 0., 1.
6, 1., 0., 1.
7, 1., 1., 1.
8, 0., 1., 1.
*ELEMENT, TYPE=C3D8, ELSET=EALL
1, 1, 2, 3, 4, 5, 6, 7, 8
*NSET, NSET=X0
1, 4, 5, 8
*NSET, NSET=X1
2, 3, 6, 7
*NSET, NSET=Y0
1, 2, 5, 6
*NSET, NSET=Z0
1, 2, 3, 4
*MATERIAL, NAME=STEEL
*ELASTIC
200000., 0.3
*DEPVAR
2
*SOLID SECTION, ELSET=EALL, MATERIAL=STEEL
*BOUNDARY
X0, 1, 1
Y0, 2, 2
Z0, 3, 3
*STEP
*STATIC
*BOUNDARY
X1, 1, 1, 0.001
*EL FILE
S, SDV
*END STEP

How to run

ccx sdv_file

Expected

The job finishes and the .frd file holds an SDV block with SDV1 and SDV2 = 0 at all 8 nodes. That is what the same deck gives with *STEP, NLGEOM:

 -4  SDV         2    1
 -5  SDV1        1    1    0    0
 -5  SDV2        1    1    0    0
 -1         1 0.00000E+00 0.00000E+00
 ...

With *EL PRINT instead of *EL FILE, the .dat file lists the 2 state variables as 0 at the 8 integration points.

Actual

ccx is killed by SIGSEGV (exit status 139) after the solve. The end of stdout is:

 Factoring the system of equations using the symmetric spooles solver
 Using 1 cpu for spooles.

 Using up to 1 cpu(s) for the stress calculation.

The .frd file then holds only its first two lines.

Where it goes wrong

src/linstatic.c declares *xstaten=NULL (line 100) and passes it to results() and frd(), but never allocates it. Its two output blocks (lines 568-572 and 797-802) allocate the other nodal output fields only:

    if(strcmp1(&filab[261],"E   ")==0) NNEW(een,double,6**nk);
    if(strcmp1(&filab[2697],"ME  ")==0) NNEW(emn,double,6**nk);
    if(strcmp1(&filab[522],"ENER")==0) NNEW(enern,double,*nk);
    if(strcmp1(&filab[2175],"CONT")==0) NNEW(cdn,double,6**nk);

src/resultsprint.f then writes into it when SDV is in filab:

      if(filab(8)(1:4).eq.'SDV ') then
        nfield=nstate_
        ...
        call extrapolate(xstate,xstaten,ipkon,inum,kon,lakon,nfield,nk,

src/nonlingeo.c (line 3790 and line 3949) allocates it:

      if(strcmp1(&filab[609],"SDV ")==0) NNEW(xstaten,double,*nstate_**nk);

Without *DEPVAR, nstate_ is 0 and nothing is written, which is why the crash needs *DEPVAR.

Fix

In both output blocks of linstatic.c, allocate xstaten like nonlingeo.c does, and free it with the others:

    if(strcmp1(&filab[609],"SDV ")==0) NNEW(xstaten,double,*nstate_**nk);
    ...
    if(strcmp1(&filab[609],"SDV ")==0) SFREE(xstaten);

Workaround: request SDV on *EL PRINT, or leave it off *EL FILE in linear steps.

Confirmed (using official build of ccx 2.23 on Windows), needs a GitHub ticket.

CSC Conversion Time: 0.001909
Init Time: 0.060336
Factorize Time: 0.009885
Solve Time: 0.016083
Clean up Time: 0.000000
---------------------------------
Sum: 0.088213

Total PaStiX Time: 0.088213
CCX without PaStiX Time: 0.044418
Share of PaStiX Time: 0.665098
Total Time: 0.132631
Reusability: 0 : 1
________________________________________

 Using up to 1 cpu(s) for the stress calculation.
1 Like

Reported: Linear *STATIC step: *EL FILE with SDV segfaults when the model has *DEPVAR (xstaten is never allocated in linstatic.c) · Issue #221 · Dhondtguido/CalculiX · GitHub

1 Like