Bug 2480 - crash in cygwin: LANG=ja_JP ; hg showconfig
Summary: crash in cygwin: LANG=ja_JP ; hg showconfig
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-08 06:55 UTC by sharow
Modified: 2012-05-13 05:10 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments
(34 bytes, application/octet-stream)
2010-11-08 12:08 UTC, sharow
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sharow 2010-11-08 06:55 UTC
at cygwin/bash LANG=ja_JP environment

reproduce process(cygwin bash shell):
$
$ uname -a
CYGWIN_NT-5.1 MACHINE-NAME 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin
$ LANG=ja_JP
$ hg showconfig
** 予期せぬ例外が浮揚されました。
**  http://mercurial.selenic.com/wiki/BugTracker まで
**  以下の情報を報告してください。
** Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
** Mercurial Distributed SCM (version 1.7)
** Extensions loaded:
Traceback (most recent call last):
  File "hg", line 38, in <module>
  File "mercurial\dispatch.pyc", line 16, in run
  File "mercurial\dispatch.pyc", line 36, in dispatch
  File "mercurial\dispatch.pyc", line 58, in _runcatch
  File "mercurial\dispatch.pyc", line 590, in _dispatch
  File "mercurial\dispatch.pyc", line 401, in runcommand
  File "mercurial\dispatch.pyc", line 641, in _runcommand
  File "mercurial\dispatch.pyc", line 595, in checkargs
  File "mercurial\dispatch.pyc", line 588, in <lambda>
  File "mercurial\util.pyc", line 427, in check
  File "mercurial\commands.pyc", line 1081, in showconfig
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 0: ordinal
not in range(128)
$

no problem in cmd.exe.
this is bug?
Comment 1 sharow 2010-11-08 06:56 UTC
reproduce in 1.6.4
Comment 2 kiilerix 2010-11-08 07:13 UTC
What kind of Mercurial are you using? From a windows installer or something
built for cygwin?
Comment 3 sharow 2010-11-08 07:32 UTC
thanks kiilerix.
I'm using windows installer version.

Other command(commit/update/pull...) is all clear.
Just happen 'showconfig'.
Comment 4 Martin Geisler 2010-11-08 08:55 UTC
Hmm, the code in question is this:

    for f in util.rcpath():
        ui.debug(_('read config from: %s\n') % f)

I guess util.rcpath managed to return a Unicode string. The call end in
win32.system_rcpath_win32, so I guess that returned a Unicode string. I'm
not familiar with this API, though, and I cannot check it on my Linux box...

(sharow: please leave the status at "chatting" instead of resetting it to
"unread")
Comment 5 Yuya Nishihara 2010-11-08 10:49 UTC
I want the following output to see the guilty file path:

$ LC_MESSAGES=C hg showconfig --debug | head
and
$ hg showconfig --debug | head

The following code raised the same exception, so as mg pointed out, 
util.rcpath() is likely to have unicode:
>>> u'設定読み込み元: %s\n'.encode('cp932') % u'あ'
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 0: 
ordinal not in range(128)
Comment 6 sharow 2010-11-08 12:08 UTC
thanks youjah, mg.

I attached showconfig1.log.
$ LC_MESSAGES=C hg showconfig --debug > showconfig1.log


>>> print u'設定読み込み元: %s\n'.encode('cp932') % u'あ'
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 0: 
ordinal not in range(128)
>>> print u'設定読み込み元: %s\n'.encode('cp932') % u'あ'.encode('cp932')
設定読み込み元: あ

for f in util.rcpath():
    ui.debug(_('read config from: %s\n') % f.encode(encoding.encoding))

hmm... I can't build bdist_wininst.


> (sharow: please leave the status at "chatting" instead of resetting it to
"unread")
sorry. I mistook...
Comment 7 Yuya Nishihara 2010-11-09 09:08 UTC
> I attached showconfig1.log.
> $ LC_MESSAGES=C hg showconfig --debug > showconfig1.log

Could you also send the output without LC_MESSAGES=C ?
$ hg showconfig --debug

I want to know the exact point where UnicodeDecodeError raised.
Comment 8 sharow 2010-11-09 09:35 UTC
> Could you also send the output without LC_MESSAGES=C ?
> $ hg showconfig --debug

Nothing output(0 bytes).
Crush at first iteration
> for f in util.rcpath():
>       ui.debug(_('read config from: %s\n') % f)


Problem is using 'windows hg' in cygwin? (not bug?)
hmm...
Comment 9 Yuya Nishihara 2010-11-09 10:29 UTC
> Nothing output(0 bytes).

Thanks. I found it's caused by win32process.GetModuleFileNameEx(), which 
returns unicode.

http://docs.activestate.com/activepython/2.5/pywin32/win32process__GetModuleF
ileNameEx_meth.html

It doesn't matter whether on cygwin or not. I'll post a patch later.
Comment 10 HG Bot 2010-11-11 01:00 UTC
Fixed by http://hg.intevation.org/mercurial/crew/rev/5f80f44d23c5
Yuya Nishihara <yuya@tcha.org>
win32: remove try-catch block of GetModuleFileNameEx (issue2480)
Comment 11 sharow 2010-11-19 18:44 UTC
I confirm this issue.

$ uname -a
CYGWIN_NT-5.1 MACHINE-NAME 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin
$ which hg
/cygdrive/c/Program Files/Mercurial/hg
$ LANG=en hg --version
Mercurial Distributed SCM (version 1.7.1)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2010 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ LANG=ja_JP hg showconfig
extensions.hgext.bookmarks=
....

$


Thanks!
Comment 12 Bugzilla 2012-05-12 09:14 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:14 EDT  ---

This bug was previously known as _bug_ 2480 at http://mercurial.selenic.com/bts/issue2480
Imported an attachment (id=1479)