I'm trying to use sys.argv to pass parameters to my script.
However, the values are garbage.
Here's a sample script to reproduce the issue:
```
import sys
print(sys.argv)
```
Now in windbg:
```
kd> !py C:\test\argv.py -n test
['C:\\test\\argv.py', 'test', 'test']
kd> !py C:\test\argv.py aaa bbb ccc
['C:\\test\\argv.py', 'ccc', 'ccc', 'ccc']
kd> !py C:\test\argv.py -n test.exe
['C:\\test\\argv.py', 'ⱐ䇲ȑ', 'test.exe']
```
Here is my setup:
```
kd> !pykd.info
pykd bootstrapper version: 2.0.0.10
Installed python:
Version: Status: Image:
------------------------------------------------------------------------------
* 3.6 x86-64 Loaded C:\Program Files\Python36\python36.dll
kd> !pip show pykd
Name: pykd
Version: 0.3.2.2
Summary: python windbg extension
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: c:\program files\python36\lib\site-packages
Requires:
kd> version
Windows 10 Kernel Version 14393 MP (1 procs) Free x64
Product: WinNt, suite: TerminalServer SingleUserTS
Built by: 14393.953.amd64fre.rs1_release_inmarket.170303-1614
Kernel base = 0xfffff802`08075000 PsLoadedModuleList = 0xfffff802`08374000
Debug session time: Fri Apr 7 11:25:05.880 2017 (UTC + 2:00)
System Uptime: 0 days 0:22:26.557
Remote KD: KdSrv:Server=@{<Local>},Trans=@{COM:Port=\\.\\pipe\\client,Baud=19200,Pipe,Timeout=4000}
Microsoft (R) Windows Debugger Version 10.0.10240.9 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
command line: '"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe" -k com:pipe,port=\\.\\pipe\\client,resets=0,reconnect' Debugger Process 0x199C
dbgeng: image 10.0.10240.16399, built Thu Jul 23 03:51:27 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbgeng.dll]
dbghelp: image 10.0.14321.1024, built Fri Jan 06 06:29:37 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll]
DIA version: 40116
[...]
Extension DLL chain:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\pykd: image 2.0.0.10, API 0.0.0, built Thu Mar 02 18:35:42 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\pykd.dll]
dbghelp: image 10.0.14321.1024, API 10.0.6, built Fri Jan 06 06:29:37 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll]
ext: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:50:27 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\ext.dll]
exts: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:49:59 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\exts.dll]
kext: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:49:56 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\kext.dll]
kdexts: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 04:05:16 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\kdexts.dll]
```
Comments: ** Comment from web user: kernelnet **
However, the values are garbage.
Here's a sample script to reproduce the issue:
```
import sys
print(sys.argv)
```
Now in windbg:
```
kd> !py C:\test\argv.py -n test
['C:\\test\\argv.py', 'test', 'test']
kd> !py C:\test\argv.py aaa bbb ccc
['C:\\test\\argv.py', 'ccc', 'ccc', 'ccc']
kd> !py C:\test\argv.py -n test.exe
['C:\\test\\argv.py', 'ⱐ䇲ȑ', 'test.exe']
```
Here is my setup:
```
kd> !pykd.info
pykd bootstrapper version: 2.0.0.10
Installed python:
Version: Status: Image:
------------------------------------------------------------------------------
* 3.6 x86-64 Loaded C:\Program Files\Python36\python36.dll
kd> !pip show pykd
Name: pykd
Version: 0.3.2.2
Summary: python windbg extension
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: c:\program files\python36\lib\site-packages
Requires:
kd> version
Windows 10 Kernel Version 14393 MP (1 procs) Free x64
Product: WinNt, suite: TerminalServer SingleUserTS
Built by: 14393.953.amd64fre.rs1_release_inmarket.170303-1614
Kernel base = 0xfffff802`08075000 PsLoadedModuleList = 0xfffff802`08374000
Debug session time: Fri Apr 7 11:25:05.880 2017 (UTC + 2:00)
System Uptime: 0 days 0:22:26.557
Remote KD: KdSrv:Server=@{<Local>},Trans=@{COM:Port=\\.\\pipe\\client,Baud=19200,Pipe,Timeout=4000}
Microsoft (R) Windows Debugger Version 10.0.10240.9 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
command line: '"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe" -k com:pipe,port=\\.\\pipe\\client,resets=0,reconnect' Debugger Process 0x199C
dbgeng: image 10.0.10240.16399, built Thu Jul 23 03:51:27 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbgeng.dll]
dbghelp: image 10.0.14321.1024, built Fri Jan 06 06:29:37 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll]
DIA version: 40116
[...]
Extension DLL chain:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\pykd: image 2.0.0.10, API 0.0.0, built Thu Mar 02 18:35:42 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\pykd.dll]
dbghelp: image 10.0.14321.1024, API 10.0.6, built Fri Jan 06 06:29:37 2017
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll]
ext: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:50:27 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\ext.dll]
exts: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:49:59 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\exts.dll]
kext: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 03:49:56 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext\kext.dll]
kdexts: image 10.0.10240.16399, API 1.0.0, built Thu Jul 23 04:05:16 2015
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP\kdexts.dll]
```
Comments: ** Comment from web user: kernelnet **
Confirmed
It seems this bug is reproduced only s Python 3.
0:000> !py C:\temp\test1-2.py 11 22 33 44
['C:\\temp\\test1-2.py', '11', '22', '33', '44']
0:000> !py -3 C:\temp\test1-2.py 11 22 33 44
['C:\\temp\\test1-2.py', '44', '44', '44', '44']
I will try to fix it ASAP, sorry for inconvenience