Bug 13711 – Optimizer bug (yet another one, with test case)

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-11-11T08:47:04Z
Last change time
2020-08-10T05:20:26Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Marco Leise

Attachments

IDFilenameSummaryContent-TypeSize
1452main.dtest case source codetext/plain2683
1453640x480-16bit-RLE.tga.tga for test caseimage/x-tga493725

Comments

Comment #0 by Marco.Leise — 2014-11-11T08:47:04Z
Created attachment 1452 test case source code I get a segmentation fault with -O -release for the read of *src in the following partial function: --------8<-------- ubyte* src = …; uint c; final switch (pixelSize) { case 16: foreach (w; 0 .. count) { c = *src & 0b000_11111; c |= (*src++ & 0b111_00000) << (8-5); src++; c |= (*src & 0b0_00000_11) << (8+3); c |= (*src & 0b0_11111_00) << (16-2); src++; // *** problematic instruction (dst++).color = 0xFF000000 | (c << 3); } break; case 24: foreach (w; 0 .. count) { c = 0xFF000000 | *(src++) | (*(src++) << 8) | (*(src++) << 16); (dst++).color = c; } break; case 32: foreach (w; 0 .. count) { c = 0xFF000000 | *(src++) | (*(src++) << 8) | (*(src++) << 16); src++; (dst++).color = c; } break; } -------->8-------- If I change the location of the problematic instruction from: c |= (*src & 0b0_11111_00) << (16-2); src++; to: c |= (*src++ & 0b0_11111_00) << (16-2); I get no crash and the function completes. I was also able to fix it with a function call right before the snippet, so it is likely to be affected by CPU register allocation(?) When I created a test case and removed some files the crash with the -O -release switches disappeared but could be reproduced again with `dmd -O -release -inline main.d && ./main`. The test case requires the .tga file to work.
Comment #1 by Marco.Leise — 2014-11-11T08:48:18Z
Created attachment 1453 .tga for test case
Comment #2 by 4burgos — 2017-01-13T16:56:34Z
Looks like this is fixed. Perhaps it's related to https://issues.dlang.org/show_bug.cgi?id=16225?
Comment #3 by Marco.Leise — 2017-04-06T21:29:53Z
I reopened this issue, because I just downloaded the test case again and executed `dmd-2.073 -O -release -inline main.d && ./main`. It still crashes with following message: Parsing '640x480-16bit-RLE.tga' zsh: segmentation fault ./main
Comment #4 by bugzilla — 2020-08-10T05:20:13Z
Compiling it for 64 bit Linux, the latest dmd, and with: dmd main dmd main -O dmd main -O -release -inline I get the following output each time: Parsing '640x480-16bit-RLE.tga' 640x480: 68175 No seg faults.