Bug 12848 – [REG2.061] crash in _d_run_main() on some unicode command line argument (Win32)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-06-03T23:24:00Z
Last change time
2014-07-12T16:31:34Z
Keywords
pull
Assigned to
nobody
Creator
mk

Comments

Comment #0 by mk — 2014-06-03T23:24:56Z
I get a crash in Druntime in _d_run_main() function when I supply a command line argument like 'ěě' (several same accented characters). This is on Windows (XP 32bit), dmd 2.065. The crash or exception occurs in alloca function here: https://github.com/D-Programming-Language/druntime/blob/2.065/src/rt/dmain2.d#L345 Console codepage settings (chcp 852 or 65001) doesn't matter; Program source code doesn't matter, empty main() is enough. I know there are problems with Unicode support in Windows console, but this needs some workaround.
Comment #1 by mk — 2014-06-04T23:05:58Z
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L303 Actually this assert fails, because argc contains wrong number of arguments (wargc is right). argc is set before C main(), where startup code calls GetCommandLineA and then _setargv, which fails to recognize correctly number of arguments. Also argv string is in the Windows charset at this stage. So the solution seem to be either to fix the startup code or to "fix" argc and argv later using windows API W functions.
Comment #2 by mk — 2014-06-05T01:25:15Z
Comment #3 by mk — 2014-06-05T17:50:58Z
This is also a regression against v2.060
Comment #4 by github-bugzilla — 2014-06-06T21:42:11Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/aafddb4232e51f0f401c7440e8333e471dc2c35c Fix Issue 12848 - crash in _d_run_main() on some Unicode command line argument (Windows) https://github.com/D-Programming-Language/druntime/commit/ea801f5d47a33ea0e991416af44f7f7230f8a531 Merge pull request #827 from tramker/issue_12848 Fix Issue 12848 - crash in _d_run_main() on some Unicode command line