Thread overview
[Issue 3687] New: Array operation "slice times scalar" tramples over memory
Jan 07, 2010
Clemens
Jan 08, 2010
Clemens
Jan 08, 2010
Clemens
Jan 08, 2010
Clemens
Jan 18, 2010
Clemens
Jan 20, 2010
Don
Jan 21, 2010
Don
Jan 31, 2010
Walter Bright
January 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687

           Summary: Array operation "slice times scalar" tramples over
                    memory
           Product: D
           Version: 1.053
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: eriatarka84@gmail.com


--- Comment #0 from Clemens <eriatarka84@gmail.com> 2010-01-07 13:16:38 PST ---
The following code fails with an assertion failure when it clearly shouldn't:

====================================================

void main()
{
    float[64] array;
    int i = 42;

    auto slice = array[];
    slice[] *= 2f;

    assert(i == 42);
}

====================================================

Array bounds checking doesn't catch this. I presume that the code in the runtime to execute this array operation is buggy.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #1 from Clemens <eriatarka84@gmail.com> 2010-01-08 06:53:11 PST ---
Created an attachment (id=548)
patch against druntime to fix the problem

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #2 from Clemens <eriatarka84@gmail.com> 2010-01-08 06:55:22 PST ---
Yes, it is buggy. I've uploaded a patch to fix the routine which does float array times scalar multiplication, though probably it's a better idea to file it at druntime directly. I'll crosspost it there.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #3 from Clemens <eriatarka84@gmail.com> 2010-01-08 09:20:06 PST ---
I've realized that the other float array operations of the form "array op= scalar" suffer from the same problem. Please hold off with applying this patch, I'll provide a more general one. I hope string mixins are ok to use in druntime? There's quite a lot of code duplication in these array modules.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #4 from Clemens <eriatarka84@gmail.com> 2010-01-18 01:41:19 PST ---
I submitted the patch to Tango (since that's what I use currently), it was folded into their copy of the runtime. I would appreciate if someone merged the changes into druntime to keep them in lockstep. Patch and discussion are here:

http://www.dsource.org/projects/tango/ticket/1831

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #5 from Don <clugdbug@yahoo.com.au> 2010-01-20 06:56:52 PST ---
The original test case passes on D2, but here's a test case which fails on both D1 and D2.
------
void main()
{
    float[66] array;
    array[] = 0;
    array[64] = 42;
    array[65] = 43;
    array[0..64] *= 2f;
    assert(array[65] == 43);
    assert(array[64] == 42);
}
------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687



--- Comment #6 from Don <clugdbug@yahoo.com.au> 2010-01-21 04:00:30 PST ---
Changes checked into druntime svn 234 and D1 phobos svn 1403.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 31, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3687


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2010-01-30 22:41:36 PST ---
fixed dmd 1.056 and 2.040

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