[Issue 12183] New: using std.algorithm.sort makes valgrind abort

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 16 06:32:13 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12183

           Summary: using std.algorithm.sort makes valgrind abort
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: pro.mathias.lang at gmail.com
        Depends on: 10054


--- Comment #0 from Mathias LANG <pro.mathias.lang at gmail.com> 2014-02-16 06:32:06 PST ---
Hi,
Valgrind currently doesn't support 80-bits x87 operation, and is unlikely to do
so (http://www.valgrind.org/docs/manual/manual-core.html#manual-core.limits).
So everytime it'll encounter one, it'll choke on it and abort.

By default, std.algorithm.sort will use the unstable SwapStrategy to sort,
which will emit an x87 80 bits instruction (there's a cast(real)r.lengh). So by
default, we will by slightly more optimized, but one of the most popular
debugging tool on linux will stop to work, and force users (possibly newbies)
to look into valgrind's implementation details to understand why it's not
working.

That's why I think we should change the default from unstable to stable. I'll
submit a PR soon.

NB: Example of code:

import std.algorithm, std.string;
void    main()
{
    string  names = "alex|jake|mat";
    auto    sn = names.split("|").sort();
}

Result in:
geod at Barsoom:~$ valgrind ./test
==19592== Memcheck, a memory error detector
==19592== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==19592== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==19592== Command: ./test
==19592== 
Boom ?
vex amd64->IR: unhandled instruction bytes: 0x48 0xDF 0x6D 0xF0 0xEB 0x1A 0x48
0xB9
vex amd64->IR:   REX=1 REX.W=1 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=0
==19592== valgrind: Unrecognised instruction at address 0x4326dd.
==19592==    at 0x4326DD:
_D3std9algorithm62__T4sortVAyaa5_61203c2062VE3std9algorithm12SwapStrategy0TAAyaZ4sortFAAyaZS3std5range39__T11SortedRangeTAAyaVAyaa5_61203c2062Z11SortedRange
(in /home/geod/test)
[...]

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list