www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5580] New: [64-bit] String switch statements broken in 64-bit mode

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580

           Summary: [64-bit] String switch statements broken in 64-bit
                    mode
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



The following code hits the assert(0) when -release is disabled or segfaults
when -release is enabled when compiled on Linux in 64-bit mode:

void main(string[] args) {
    auto str = "foo";
    switch(str) {
        case "foo":
            break;
        default:
            assert(0);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580




This one actually looks to be related to some dynamic library or system call or
something.  I just noticed that, regardless of what computer I compile it on, I
can only reproduce it on certain computers, those with ancient Linux
distributions.  The uname -a for the two that I can reproduce it on are:


x86_64 x86_64 x86_64 GNU/Linux


EST 2009 x86_64 x86_64 x86_64 GNU/Linux

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580




Created an attachment (id=912)
Statically linked binary

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580




Not sure if this will help, but here's a statically linked binary with
debugging symbols.  This can reproduce the bug on any computer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580




My gut feeling is that this is related to Bug 5581, as both invoke calls to
memcmp() according to my reading of the disassembly and tracking down of the
function calls in the runtime.  However, 5581 seems to be reproducible
everywhere.  If you can't reproduce this, I suggest fixing 5581 first.  Once
5581 is fixed, I'll retest this bug on a machine that I was able to reproduce
it on and hopefully it will be fixed, too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



15:30:18 PST ---
I can't reproduce a problem on Ubuntu, and I examined the assembler generated
for druntime/src/rt/switch_.d and nothing obviously wrong jumped out at me.

One thing you can try on the failing machines is to copy switch_.d into a local
directory, compile it with the test case, and verify the failure. Then add some
print statements to switch_.d to try and see where it goes wrong.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580




Unfortunately this appears to be a Heisenbug.  When I put print statements in
to figure out what's going on and call the switch statement function manually,
it starts working.  However, the one hint I did get from mucking around in
switch_.d is that replacing the memcmp() call with a manual for loop and
recompiling druntime solves the problem.  Not sure if this is due to the
Heisenbug nature of this thing or if it indicates that the memcmp() call is the
culprit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5580


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



00:54:02 PST ---
https://github.com/D-Programming-Language/dmd/commit/f1c158eac6f9d1a28314c7e473c89be8b8a4f774

https://github.com/D-Programming-Language/dmd/commit/b3bb64d6ff00beddfc45c228941feedeb2e27842

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