Bug 21599 – std.digest.crc : crc32Of fails with SegFault on array of 4MB or larger

Status
NEW
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-01-31T19:13:32Z
Last change time
2024-12-01T16:38:21Z
Assigned to
No Owner
Creator
Igor Stojkovic
Moved to GitHub: phobos#9816 →

Comments

Comment #0 by stojkovic.igor — 2021-01-31T19:13:32Z
Following code fails with SegFault: ``` module test.main; private __gshared ubyte[4096 * 1024] buffer; int main(string[] args) { import std.digest.crc : crc32Of; ubyte[4] pcrc = buffer.crc32Of(); // SegFault reported here return pcrc[0]; } ``` Tried with DMD 2.095.0 and LDC 1.24.0.
Comment #1 by apz28 — 2021-02-04T00:55:06Z
This construct will cause the function to pass fixed length array ubyte[4194304] and construct struct CRC(uint N, ulong P) with N=64u & P=15564440312192434176LU hence stack overflow. Change to dynamic array construct should fix the problem ubyte[4] pcrc = buffer[].crc32Of();
Comment #2 by robert.schadek — 2024-12-01T16:38:21Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9816 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB