www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12419] New: assertion failure in std.utf

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

           Summary: assertion failure in std.utf
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-03-20
02:19:24 PDT ---
Test code:

import std.utf;

void main()
{
    char[4] val;
    val[0] = 0b1111_0111;
    val[1] = 0b1011_1111;
    val[2] = 0b1011_1111;
    val[3] = 0b1011_1111;
    size_t i = 0;
    dchar ch = decode(val[], i); //must have thrown exception
}

Instead:
core.exception.AssertError std.utf(950): Assertion failure

The trick is that encoded value (0x1FFFFF) is way beyond the standard range
[0,0x10FFFF] and then the out contract of decode fails.

std.utf.decode must throw on 4 byte sequence with values above 0x10_FFFF.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 20 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12419



--- Comment #1 from github-bugzilla puremagic.com 2014-03-24 11:51:35 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/0f0511f81bcafb11488087c7d68cf1bb45ad4c21
fix issue 12419

Test that UTF-8 decoding yields a value in the valid range.
UTF-8 may encode values beyond these covered by [0, 0x10FFFF].

https://github.com/D-Programming-Language/phobos/commit/3c92edeb3bab2bc60cbdb3f307e3fd8ca1d2f9bb
Merge pull request #2038 from blackwhale/issue-12419

Fix issue 12419: assertion failure in std.utf

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 24 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12419


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

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


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