Mercury Bugs - mercury
View Issue Details
0000269mercuryBugpublic2012-12-07 06:272012-12-07 14:24
Reportergloomdemon 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformwindowsOSwindows 32/64OS Versionany
Product Version 
Target VersionFixed in Version 
Summary0000269: unicode path handling in dir module
Descriptiondir.recursive_foldl2 failed on directory with unicode name QQ菜单

Uncaught Mercury exception:
Software Error: string.unsafe_index: illegal sequence
Stack dump not available in this grade.

This problem is possible in dir.make_path_name function with incorrect work of function string.length or string.unsafe_index
Steps To Reproduceunpack utf_dir_small.rar with rar, compile and run 'bugu' program in dir with 'yjkj' directory
Additional Information
:- module bugu.
:- interface.

:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.

:- import_module require, dir, list, bool.

main(!IO) :-
    Ps = (
        pred(DN::in, BN::in, FT::in, C::out, Di::in, Do::out, !.IO::di, !:IO::uo) is det :-
            C = yes,
            io.write_strings([DN, " ", BN, "\n"], !IO),
            Do = Di
    ),
    dir.recursive_foldl2(Ps, ".", no, [], MaybeResult, !IO),
    (
        MaybeResult = error(_, Err),
        error(io.error_message(Err)) % exception
    ;
        MaybeResult = ok(_)
    ).
TagsNo tags attached.
Attached Filesrar utf_dir_small.rar (696,633) 2012-12-07 06:27
https://bugs.mercurylang.org/file_download.php?file_id=165&type=bug

Notes
(0000482)
gloomdemon   
2012-12-07 06:35   
compilers versions:

$ mmc --version
Mercury Compiler, version rotd-2012-02-17, configured for i686-pc-mingw32
Copyright (C) 1993-2012 The University of Melbourne

$ gcc --version
gcc.exe (GCC) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
(0000483)
wangp   
2012-12-07 14:23   
Thanks, fixed committed.

Issue History
2012-12-07 06:27gloomdemonNew Issue
2012-12-07 06:27gloomdemonFile Added: utf_dir_small.rar
2012-12-07 06:35gloomdemonNote Added: 0000482
2012-12-07 10:33wangpAssigned To => wangp
2012-12-07 10:33wangpStatusnew => assigned
2012-12-07 14:23wangpNote Added: 0000483
2012-12-07 14:24wangpStatusassigned => resolved
2012-12-07 14:24wangpResolutionopen => fixed