[BUG]: Segmentation fault when running C benchmarks
- 主要語言
- JavaScript
- 星號
- 6k
- 分支
- 1.3k
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 611
描述
## Checklist
> Please ensure the following tasks are completed before filing a bug report.
- [x] Read and understood the [Code of Conduct][code-of-conduct].
- [x] Searched for existing issues and pull requests.
## Description
> Description of the issue.
Am encountering a `Segmentation fault (core dumped)` error when running C benchmarks of mathematical functions.
## Questions
> Any questions for reviewers?
No.
## Other
> Any other information relevant to this issue? This may include screenshots, references, stack traces, sample output, and/or implementation notes.
The issue seems to be due to the benchmarks overflowing the default maximum stack size of 8 MB.
Increasing the stack size via e.g. `ulimit -s 32767` causes the benchmarks to run properly.
We might want to rethink whether to allocate memory with `malloc`.
#### Reproduction
> What steps are required to reproduce the unexpected output?
In order to reproduce this bug, do the following:
- From the top-level `stdlib` directory, run
```
make benchmark-c BENCHMARKS_FILTER=.*/dsqrt/.*
```
#### Expected Results
> What are the expected results?
The benchmarks should run without issues.
#### Actual Results
> What are the actual results?
The following are the actual results:
```text
(...)
ok 14 benchmark finished
# c::dsqrt:len=100000
---
iterations: 1000
elapsed: 0.429753065
rate: 2326.917667814
...
ok 15 benchmark finished
# c::dsqrt:len=1000000
Makefile:133: recipe for target 'run' failed
make[1]: *** [run] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/philipp/git/stdlib/lib/node_modules/@stdlib/math/strided/special/dsqrt/benchmark/c'
/home/philipp/git/stdlib/tools/make/lib/benchmark/c.mk:48: recipe for target 'benchmark-c' failed
make: *** [benchmark-c] Error 1
```
#### Environments
> What environments are affected (e.g., `Node v0.4.x`, `Chrome`, `IE 11`)? If Node.js, include the `npm` version, operating system, and any other potentially relevant platform information.
The following environments are affected:
- Linux Ubuntu
[code-of-conduct]: https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md
貢獻指南
研究方向
Start by running `make benchmark-c BENCHMARKS_FILTER=.*/dsqrt/.*` from the top-level stdlib directory. Inspect the C benchmark path under `lib/node_modules/@stdlib/math/strided/special/dsqrt/benchmark/c`, along with `Makefile:133` and `tools/make/lib/benchmark/c.mk:48`, to trace the failure. Done means the benchmark completes without a segmentation fault under the default stack limit.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c
- 領域
- performance
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100