Thread overview
[Issue 6085] New: The filename part of a thrown core.exception.UnicodeException is incomprehensible
Jun 01, 2011
kennytm@gmail.com
Jun 01, 2011
kennytm@gmail.com
Jun 01, 2011
kennytm@gmail.com
Jun 01, 2011
kennytm@gmail.com
Jun 06, 2011
kennytm@gmail.com
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6085

           Summary: The filename part of a thrown
                    core.exception.UnicodeException is incomprehensible
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-06-01 01:57:56 PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6085



--- Comment #1 from kennytm@gmail.com 2011-06-01 02:00:01 PDT ---
Argh, the Unicode seems to make the post disappeared. Let me try again.



Test case:

==================================
void main() {
    string s = "\xff\xff\xff\0\0\0";
    foreach (dchar c; s) {}
}
==================================
core.exception.UnicodeException@<hundred lines of garbage skipped>
opEqualsMFC6ObjectZb(0): invalid UTF-8 sequence
----------------
5   x                                   0x000096d6 onUnicodeError + 66
6   x                                   0x000151e1 dchar
rt.util.utf.decode(const(char[]), ref uint) + 373
7   x                                   0x00012218 _aApplycd1 + 68
<snip>
----------------
==================================

The problem seems to be that the string __FILE__ sent to onUnicodeError is corrupt. Further more, the __LINE__ displayed is always 0.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6085


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from kennytm@gmail.com 2011-06-01 02:17:14 PDT ---
The reason of corrupted output is because of a wrong signature.




diff --git a/src/rt/util/utf.d b/src/rt/util/utf.d
index d7aeac1..cdbc27c 100644
--- a/src/rt/util/utf.d
+++ b/src/rt/util/utf.d
@@ -28,7 +28,7 @@
 module rt.util.utf;


-extern (C) void onUnicodeError( string msg, size_t idx );
+extern (C) void onUnicodeError( string msg, size_t idx, string file =
__FILE__, size_t line = __LINE__ );

 /*******************************
  * Test if c is a valid UTF-32 character.




This patch, however, only gives the __FILE__ and __LINE__ of the druntime function, not the actual user code that emits the error.  But I think this can't be fixed without modifying DMD because _aApplycd1 doesn't contain the line information.



core.exception.UnicodeException@src/rt/util/utf.d(290): invalid UTF-8 sequence
----------------
5   x                                   0x000096b2 onUnicodeError + 66
6   x                                   0x000151ce dchar
rt.util.utf.decode(const(char[]), ref uint) + 390
7   x                                   0x000121f4 _aApplycd1 + 68
8   x                                   0x000027e5 _Dmain + 37

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6085



--- Comment #3 from kennytm@gmail.com 2011-06-01 12:53:20 PDT ---
druntime pull #20.

(https://github.com/D-Programming-Language/druntime/pull/20)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6085


kennytm@gmail.com changed:

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


--- Comment #4 from kennytm@gmail.com 2011-06-06 12:30:15 PDT ---
https://github.com/D-Programming-Language/druntime/commit/d1ae5aa395a5a545f48c0c92d4338de19e6f3887

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