digitalmars.D.bugs - [Issue 7762] New: Possible bug in std.algorithm.sort(ubyte[])
- d-bugmail puremagic.com (49/49) Mar 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7762
http://d.puremagic.com/issues/show_bug.cgi?id=7762 Summary: Possible bug in std.algorithm.sort(ubyte[]) Product: D Version: unspecified Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2012-03-24 09:39:41 PDT --- This program causes a segfault about 30-50% of the times it is run, on Windows 32 bit dmd 2.059head: Compile with: dmd -property -g -wi test.d import std.stdio, std.algorithm, std.random; void main() { immutable digits = "0123456789"; enum nLoops = 5_000_000; enum maxLen = 20; char[maxLen] items; auto rnd = Xorshift(); rnd.seed(0); foreach (i; 0 .. nLoops) { immutable len = uniform(0, maxLen, rnd); foreach (j; 0 .. len) items[j] = digits[uniform(0, digits.length, rnd)]; string ns = items[0 .. len].idup; ns = cast(string)(cast(ubyte[])ns.dup).sort().release(); } } The stack trace: object.Error: Access Violation ---------------- ...\dmd2\src\phobos\std\algorithm.d(7283): bool std.algorithm.__T8isSortedS593std10functional31__T9binaryFunVAyaa5_61203c2062Z9binaryFunTAhZ.isSorted(ubyte[]) ...\dmd2\src\phobos\std\algorithm.d(6744): D3std9algorithm60__T4sortVAyaa5_61203cÙ62VE€Ž«12SwapStrategy0TAhZ€…¹F€ƒ‰S€„«5range37€ƒÒ11S€ƒšedR€„’€ƒª€‘ÝZ€¢ ...\test.d(14): _Dmain ---------------- The bug disappears if you remove ".sort().release()". Maybe it doesn't crash wi ldc2 linux 64, dmd-front-end 2.058 (I don't know what compilation switches). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 24 2012