Bug 7115 – sort function is broken with large arrays

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2011-12-15T13:38:00Z
Last change time
2016-12-08T16:23:39Z
Keywords
bootcamp
Assigned to
nobody
Creator
deadalnix

Comments

Comment #0 by deadalnix — 2011-12-15T13:38:40Z
See sample code : module fail; import std.algorithm; import std.random; void main() { Mt19937 gen; byte[] v; v.length = 65536 * 1024; foreach(ref byte t; v) { t = cast(byte) gen.front; gen.popFront; } v.sort; assert(isSorted(v)); }
Comment #1 by timon.gehr — 2011-12-15T13:52:00Z
This would be a great opportunity to finally deprecate that abomination. Also, I think this only happens when the element type is byte?
Comment #2 by deadalnix — 2011-12-15T13:58:57Z
(In reply to comment #1) > This would be a great opportunity to finally deprecate that abomination. > Also, I think this only happens when the element type is byte? I did put byte for performances reasons, but it is true that it works with int and short (I just checked). Anyway, not sure it will nto fail for bigger values. BTW, phobos provide nice way to sort, so this feature is not really needed and can be deprecated.
Comment #3 by clugdbug — 2011-12-16T03:51:42Z
Perhaps a duplicate of bug 2819? (I think it may be overflowing the stack, and generating wrong results instead of segfaulting).
Comment #4 by hsteoh — 2015-06-30T23:39:35Z
Can no longer reproduce this bug on git HEAD. Tested on Linux/64. I'm guessing .sort has been replaced with the Phobos sort by now (IIRC)? If so, we should resolve this bug.
Comment #5 by andrei — 2016-10-15T01:28:09Z
Can a bootcamper look into this, thanks.
Comment #6 by razvan.nitu1305 — 2016-11-30T09:37:11Z
I looked into it and it seems the built-in sort for arrays has been deprecated and the program won't compile on git HEAD (Linux/64). I don't know if there is a way to force the compilation to succeed even though deprecated functions are used, but using the phobos sort function completes the job gracefully. As for bug 2819, it seems that the code which caused the error has been removed. I suggest we close this Issue.