# \*DYNAMIC step after a \*STATIC step: random segfault or bus error in tempload when the step creates a knot and the deck has an \*AMPLITUDE

**URL:** <https://calculix.discourse.group/t/dynamic-step-after-a-static-step-random-segfault-or-bus-error-in-tempload-when-the-step-creates-a-knot-and-the-deck-has-an-amplitude/4247>\
**Category:** Analysis issues\
**Created:** [October 22, 2026, 7:01pm UTC](https://calculix.discourse.group/t/dynamic-step-after-a-static-step-random-segfault-or-bus-error-in-tempload-when-the-step-creates-a-knot-and-the-deck-has-an-amplitude/4247 "2026-10-22T19:01:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandervdb](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sandervdb](https://calculix.discourse.group/u/Sandervdb)\
**Post date:** [October 22, 2026, 7:01pm UTC](https://calculix.discourse.group/t/dynamic-step-after-a-static-step-random-segfault-or-bus-error-in-tempload-when-the-step-creates-a-knot-and-the-deck-has-an-amplitude/4247/1 "2026-10-22T19:01:54Z")

</div>

## Summary

The same input crashes in some runs and finishes in others. The crash comes at the start of a `*DYNAMIC` step (bus error, exit 138, sometimes a segmentation fault, exit 139). It needs three things:

1. the `*DYNAMIC` step is not the first step,
2. a beam or shell node that is not yet a knot has a rotational boundary condition (here the clamp `1, 1, 6`), so ccx creates a knot for it in that step (`a KNOT was generated in node 1` in the .12d file),
3. the deck has any `*AMPLITUDE` (used or not), or a `*STEP, AMPLITUDE=` parameter.

`knotmpc.f` adds three SPCs for every node of the new knot but never sets `iamboun` for them. From step 2 on, `iamboun` is grown with `RENEW` and its new entries are uninitialised memory. `tempload.f` then uses such a value as an amplitude number and reads `amname(iambouni)` far out of bounds.

Evidence that this is a read of uninitialised memory, not a property of the model:

- Under a debugger, the `iamboun` entries of exactly these SPCs hold values like 618792841 or -1534122498 in crashing runs and 0 in runs that finish.
- With macOS `MallocScribble=1` (fresh allocations filled with 0xAA bytes, a negative integer) the deck never crashes (0 of 20).
- On a Windows x64 build of ccx 2.23, one input crashed at the start of the `*DYNAMIC` step on every run, while a deck identical except for one unused `*NSET` solved (both decks are below). On macOS both crash at random.

## Version

ccx 2.23 (macOS arm64), OMP\_NUM\_THREADS=1; also a Windows x64 build of ccx 2.23 (see the pair below). Source: master 9ba5d76 (16 Oct 2026).

## Already reported or fixed?

Not reported: I found no matching GitHub issue (open or closed) or pull request in Dhondtguido/CalculiX, and no calculix.discourse.group topic (searched 21 Oct 2026). Not fixed: `knotmpc.f`, `gen3dboun.f`, `tempload.f` and the `RENEW(iamboun,...)` in `CalculiX.c` are unchanged on master (9ba5d76).

Related:

- [Segmentation fault with ccx\_2.19 dynamic modal analysis](https://calculix.discourse.group/t/1156:) a different segfault, in `*MODAL DYNAMIC` with shells; its cause is a NULL work array in `dyna.c` (reported separately).

## Minimal input

`knot_dyn_amp.inp`:

```auto
** Two B32R elements along x, clamped at node 1 (1, 1, 6). A *STATIC step moves nodes 2
** and 3, a *DYNAMIC step moves them further. The *AMPLITUDE is defined but not used.
*NODE, NSET=ALL
1, 0., 0., 0.
2, 1., 0., 0.
3, 2., 0., 0.
4, 0.5, 0., 0.
5, 1.5, 0., 0.
*ELEMENT, TYPE=B32R, ELSET=B
1, 1, 4, 2
2, 2, 5, 3
*BEAM SECTION, ELSET=B, MATERIAL=M, SECTION=RECT
0.1, 0.1
0., 0., 1.
*MATERIAL, NAME=M
*ELASTIC
2.1e5, 0.3
*DENSITY
7.8e-9
*BOUNDARY
1, 1, 6
*AMPLITUDE, NAME=A
0., 0., 1., 1.
*STEP
*STATIC
*BOUNDARY
2, 1, 3, 0.005
3, 1, 3, 0.01
*EL FILE
ENER
*END STEP
*STEP
*DYNAMIC
0.01, 1.
*BOUNDARY
2, 1, 3, 0.01
3, 1, 3, 0.02
*NODE PRINT, NSET=ALL
U
*END STEP

```

(The `*EL FILE, ENER` request in step 1 is only there because ccx otherwise stops with “in nonlinear calculations energy output requests, if any, must be specified in the first step”.)

## How to run

```auto
for i in $(seq 1 20); do OMP_NUM_THREADS=1 ccx knot_dyn_amp > out_$i.txt 2>&1; echo $?; done

```

## Expected

The job finishes every time. It does in these variants of the same deck (20 runs each):

| variant | crashed |
| --- | --- |
| without the `*AMPLITUDE` | 0 / 20 |
| step 1 `*DYNAMIC` too: step 1’s `*STATIC` replaced by `*DYNAMIC` / `0.01, 1.` (the knot is then created in step 1) | 0 / 20 |
| step 2 `*STATIC`: step 2’s `*DYNAMIC` / `0.01, 1.` replaced by `*STATIC` with no data line (no knot) | 0 / 20 |
| as is, run with `MallocScribble=1` | 0 / 20 |

## Actual

14 of 40 runs crashed at the start of the `*DYNAMIC` step: 13 with a bus error (exit status 138), 1 with a segmentation fault (139). The other 26 finished. Backtrace of a crashing run (lldb):

```auto
stop reason = EXC_BAD_ACCESS (code=2, address=0xcbe22ba00)
frame #0: libsystem_platform.dylib`_platform_memcmp + 148
frame #1: libgfortran.5.dylib`_gfortran_compare_string + 64
frame #2: ccx`tempload_ + 644
frame #3: ccx`nonlingeo + 16900

```

At the first `tempload` call of step 2 (`nonlingeo.c:919`, the initial acceleration of the `*DYNAMIC` step), `nboun` = 45 and `nam` = 1. Entries 1-18 are the deck’s SPCs and the SPCs ccx made in step 1; entries 19-45 are the 27 SPCs `knotmpc` added for the new knot at node 1 (nodes 49 and 51-58, DOFs 1-3, value 0). In four crashing runs `iamboun(21..42)` held values such as 618792841, 1079052435, -1589612474, 807014666; in two runs that finished they were all 0.

> **The Windows pair: one unused \*NSET decides whether the Windows build crashes**
>
> `fold_plain.inp`, an S4 strip folded 90 degrees (ccx makes the fold nodes 2, 5, 8 knots in step 1; the clamped nodes 1 and 3 become knots in the `*DYNAMIC` step). `*STEP, AMPLITUDE=STEP` makes ccx define its step ramp amplitude, which the step-2 `*BOUNDARY` names:
> 
> ```auto
> *NODE
> 1, 0, -0.5, 0
> 2, 0, 0, 0
> 3, 0, 0, 0.5
> 4, 1, -0.5, 0
> 5, 1, 0, 0
> 6, 1, 0, 0.5
> 7, 2, -0.5, 0
> 8, 2, 0, 0
> 9, 2, 0, 0.5
> *ELEMENT, TYPE=S4
> 1, 1, 4, 5, 2
> 2, 2, 5, 6, 3
> 3, 4, 7, 8, 5
> 4, 5, 8, 9, 6
> *NSET, NSET=ALLN, GENERATE
> 1, 9, 1
> *ELSET, ELSET=E, GENERATE
> 1, 4, 1
> *SHELL SECTION, ELSET=E, MATERIAL=M
> 0.05
> *MATERIAL, NAME=M
> *ELASTIC
> 1000., 0.3
> *DENSITY
> 1e-3
> *BOUNDARY
> 1, 1, 6
> 2, 1, 6
> 3, 1, 6
> *STEP
> *STATIC
> *BOUNDARY
> 8, 2, 2, 0.005
> 8, 3, 3, 0.01
> *NODE PRINT, NSET=ALLN, GLOBAL=yes
> U
> *NODE FILE
> U, RF
> *EL FILE
> S, E, ENER
> *END STEP
> *STEP, AMPLITUDE=STEP
> *DYNAMIC
> 0.05, 1.
> *BOUNDARY, AMPLITUDE=RAMP12357111317
> 8, 2, 2, 0.01
> 8, 3, 3, 0.02
> *NODE PRINT, NSET=ALLN, GLOBAL=yes, FREQUENCY=10
> U
> *NODE FILE
> U, V, RF
> *EL FILE
> S, E
> *END STEP
> 
> ```
> 
> `fold_nset.inp` is the same deck with one unused node set after the `*NSET, NSET=ALLN` lines:
> 
> ```diff
> *NSET, NSET=ALLN, GENERATE
> 1, 9, 1
> +*NSET, NSET=TR
> +8
> *ELSET, ELSET=E, GENERATE
> 
> ```
> 
> | deck | Windows x64 ccx 2.23 | macOS arm64 ccx 2.23 (20 runs) | macOS, `MallocScribble=1` (20 runs) |
> | --- | --- | --- | --- |
> | `fold_plain.inp` | crashed at the start of the `*DYNAMIC` step on every run | 5 crashed (bus error) | 0 crashed |
> | `fold_nset.inp` | solved | 7 crashed (bus error) | 0 crashed |
> 
> (The decks run on Windows carried comment lines as well; they are removed here.)

## Where it goes wrong

In a `*DYNAMIC` step, a rotational SPC on a shell or beam node that is not a knot makes ccx create a knot (`gen3dboun.f:141`):

```fortran
          if((idir.gt.3).and.((nmethod.eq.4).and.(iperturb(1).gt.1))

```

`gen3dboun.f:205` (and `gen3dforc.f:222` for moments) calls `knotmpc`, which adds one SPC per knot node and direction (`knotmpc.f:268-284`, same at 391-407):

```fortran
            nboun=nboun+1
            ...
            nodeboun(nboun)=ispcnode
            ndirboun(nboun)=j
            typeboun(nboun)='R'
            if(istep.gt.1) then
               xboun(nboun)=0.d0
            endif

```

`knotmpc` has no `iamboun` argument, so `iamboun(nboun)` is never set. `bounadd.f:152` does set it for every other new SPC: `if(nam.gt.0) iamboun(nboun)=iamplitude`.

In step 1 this is harmless: `CalculiX.c:271` allocates `iamboun` with `NNEW` (zeroed). For every later step (the block “allocating and reallocating space for subsequent steps”, `CalculiX.c:506`) line 548 grows it with `RENEW(iamboun,ITG,nboun_);` and nothing clears the new entries, while the same block clears the new parts of `vold` (line 517, `DMEMSET`) and `xbodyold` (line 543). `tempload.f:244-250` then reads them:

```fortran
        if(nam.gt.0) then
          iambouni=iamboun(i)
        ...
        if(iambouni.gt.0) then
          if(amname(iambouni).eq.'RAMP12357111317') then

```

A large positive leftover value makes the string compare read outside `amname`: bus error or segfault. A small positive one reads a wrong `ampli` entry without a crash (harmless here, since the SPC value is 0). Zero or negative values are skipped, which is why the crash is random and depends on the memory layout.

## Fix

Set the amplitude of the knot SPCs. Either pass `iamboun` and `nam` to `knotmpc` and add next to `typeboun(nboun)='R'` (both places):

```fortran
            if(nam.gt.0) iamboun(nboun)=0

```

or clear the new entries after the `RENEW` in `CalculiX.c:548`:

```c
	RENEW(iamboun,ITG,nboun_);
	for(i=nboun;i<nboun_;i++) iamboun[i]=0;

```

Workaround: no `*AMPLITUDE` and no `*STEP, AMPLITUDE=` in such a deck, or a `*DYNAMIC` first step, so that the knot is created in step 1.

---

<div class="post-metadata">

**Author:** ![Calc\_em](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Calc\_em](https://calculix.discourse.group/u/Calc_em)\
**Post date:** [October 23, 2026, 5:38am UTC](https://calculix.discourse.group/t/dynamic-step-after-a-static-step-random-segfault-or-bus-error-in-tempload-when-the-step-creates-a-knot-and-the-deck-has-an-amplitude/4247/2 "2026-10-23T05:38:36Z")

</div>

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

```auto
CSC Conversion Time: 0.001437
Init Time: 0.059099
Factorize Time: 0.003916
Solve Time: 0.022593
Clean up Time: 0.000000
---------------------------------
Sum: 0.087045

Total PaStiX Time: 0.087045
CCX without PaStiX Time: 0.047552
Share of PaStiX Time: 0.646707
Total Time: 0.134597
Reusability: 0 : 1
________________________________________

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

 STEP 2

 *INFO reading *DYNAMIC: for implicit calculations
       the calculation of the internal energy
       is activated.

 Dynamic analysis was selected

 Newton-Raphson iterative procedure is active

 Decascading the MPC's

 Determining the structure of the matrix:
 Using up to 16 cpu(s) for setting up the structure of the matrix.
 number of equations
 68
 number of nonzero lower triangular matrix elements
 1816

```

---

<div class="post-metadata">

**Author:** ![Sandervdb](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sandervdb](https://calculix.discourse.group/u/Sandervdb)\
**Post date:** [October 23, 2026, 5:44am UTC](https://calculix.discourse.group/t/dynamic-step-after-a-static-step-random-segfault-or-bus-error-in-tempload-when-the-step-creates-a-knot-and-the-deck-has-an-amplitude/4247/3 "2026-10-23T05:44:00Z")

</div>

posted: [\*DYNAMIC step after a \*STATIC step: random segfault or bus error in tempload when the step creates a knot and the deck has an \*AMPLITUDE · Issue #287 · Dhondtguido/CalculiX · GitHub](https://github.com/Dhondtguido/CalculiX/issues/287)
