Bug 234 – dynamic arrays in combination with SSE instructions cause segment faults

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-07-02T09:09:27Z
Last change time
2021-05-27T12:58:17Z
Keywords
wrong-code
Assigned to
Walter Bright
Creator
Thomas Kühne

Comments

Comment #0 by thomas-dloop — 2006-07-02T09:09:27Z
If compiled with -version=dynamic, the code below segmentfaults. import std.stdio; int main(){ version(dynamic){ double[] a = new double[2]; double[] b = new double[2]; }else{ double[2] a; double[2] b; } a[0] = 4.0; a[1] = 2.0; b[0] = -0.5; b[1] = -0.25; writefln("a:\t%s\t%s", a[0], a[1]); writefln("b:\t%s\t%s", b[0], b[1]); asm{ movupd XMM0, a; movupd b, XMM0; emms; } writefln("-- asm finished --"); writefln("a:\t%s\t%s", a[0], a[1]); writefln("b:\t%s\t%s", b[0], b[1]); return 0; } test cases: http://dstress.kuehne.cn/run/o/odd_bug_05_A.d http://dstress.kuehne.cn/run/o/odd_bug_05_B.d http://dstress.kuehne.cn/run/o/odd_bug_05_C.d http://dstress.kuehne.cn/run/o/odd_bug_05_D.d
Comment #1 by bugzilla — 2006-12-12T04:03:14Z
It segment faults because dynamic arrays are stored differently than static arrays. When using inline asm, one must account for this. For the dynamic arrays, using the following will work: asm{ mov EAX,a+4; movupd XMM0, [EAX]; mov EAX,b+4; movupd [EAX], XMM0; emms; }
Comment #2 by dlang-bot — 2021-05-27T12:58:17Z
dlang/dlang-bot pull request #271 "Fixes so far" was merged into master: - b0d4e55c19dc65b82920751bd4d1cc54194ba24d by Vladimir Panteleev: dlangbot: Add support for draft pull requests Fixes #234. https://github.com/dlang/dlang-bot/pull/271