Description
Description
When running the benchmark ./benchmark.length.out
for @stdlib/math/strided/special/dfloor
on Fedora 42, the benchmark crashes with a segmentation fault at the largest tested length (1,000,000). Smaller lengths (up to 100,000) complete successfully without error.
To Reproduce this error:
cd /lib/node_modules/@stdlib/math/strided/special/dfloor/benchmark/c
Run:
./benchmark.length.out
Last few line of output:
---
iterations: 1000
elapsed: 0.221682072
rate: 4510.964700011
...
ok 14 benchmark finished
# c::dfloor:len=100000
---
iterations: 1000
elapsed: 0.184779882
rate: 5411.844551710
...
ok 15 benchmark finished
# c::dfloor:len=1000000
[1] 98416 segmentation fault (core dumped) ./benchmark.length.out
Reason for this issue non-dynamic implementation of:
/lib/node_modules/@stdlib/math/strided/special/dfloor/src/dfloor.c
Temporally can be fixed by increasing stack memory limit to unlimited using:
ulimit -s unlimited
Potential Permanent fix:
Dynamic implementation of dfloor.c
using malloc
Related issue
Any similar C file with non dynamic implementation can cause similar issue on other systems
Questions
Can we refactor all C files to use dynamic memory allocation wherever necessary to improve scalability and prevent issues similar segmentation faults?