codelldb icon indicating copy to clipboard operation
codelldb copied to clipboard

Python ValueError: source code string cannot contain null bytes

Open jiannanya opened this issue 3 years ago • 4 comments

Got an error when launching debugging

OS: Windows 10 x64 19042.1586 VSCode version: 1.70.0 CodeLLDB version: 1.7.4 Compiler: clang 14.0.6 Debuggee: x86_64-pc-windows-msvc

I installed the extension CodeLLDB and configed it as below but got an error when intializing debugging.And got a warning message from VS Code The debug adapter has terminated abnormally.

After that I opened the log and it showed the information below and it reported an error ValueError: source code string cannot contain null bytes.

I dont know what I can do to fix it right now and appreciate for any help.

Maybe a Python runtime error?

My tasks file is and the launch configs can be seen in the verbose log:


{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: clang++.exe build task",
			"command": "F:\\cc\\programs\\LLVM\\bin\\clang.exe",
			"args": [
				"-g",
				"${file}",
				"-o",
				"${workspaceFolder}\\build\\${fileBasenameNoExtension}.exe",

			],
			"options": {
				
			},
			"problemMatcher": [
				"$msCompile"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

Verbose log
  

Initial debug configuration: { name: '(lldb) Launch', preLaunchTask: 'C/C++: clang++.exe build task', type: 'lldb', request: 'launch', program: '${fileDirname}\build\${fileBasenameNoExtension}.exe', args: [], cwd: '${workspaceFolder}', __configurationTarget: 6 } Resolved debug configuration: { name: '(lldb) Launch', preLaunchTask: 'C/C++: clang++.exe build task', type: 'lldb', request: 'launch', program: '${fileDirname}\build\${fileBasenameNoExtension}.exe', args: [], cwd: '${workspaceFolder}', __configurationTarget: 6, relativePathBase: 'f:\cc\src\test', _adapterSettings: { displayFormat: 'auto', showDisassembly: 'auto', dereferencePointers: true, suppressMissingSourceFiles: true, evaluationTimeout: 5, consoleMode: 'commands', sourceLanguages: null, terminalPromptClear: null, evaluateForHovers: true, commandCompletions: true, reproducer: false } } liblldb: c:\Users\Administrator.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\liblldb.dll environment: {} params: { evaluateForHovers: true, commandCompletions: true } Python path configuration: PYTHONHOME = 'c:\Users\Administrator.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin..' PYTHONPATH = (not set) program name = 'python' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\adapter\codelldb.exe' sys.base_prefix = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..' sys.base_exec_prefix = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..' sys.platlibdir = 'lib' sys.executable = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\adapter\codelldb.exe' sys.prefix = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..' sys.exec_prefix = 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..' sys.path = [ 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\python39.zip', 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..\DLLs', 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\lldb\bin\..\lib', 'c:\Users\Administrator\.vscode\extensions\vadimcn.vscode-lldb-1.7.4\adapter', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ValueError: source code string cannot contain null bytes

Current thread 0x000116e0 (most recent call first): <no Python frame> Debug adapter exit code=1 (0x1), signal=null.

jiannanya avatar Aug 15 '22 09:08 jiannanya

Are you setting "PYTHONHOME" somewhere?

vadimcn avatar Aug 15 '22 17:08 vadimcn

Are you setting "PYTHONHOME" somewhere?

yes, I have tried it, but still not work.

jiannanya avatar Aug 16 '22 02:08 jiannanya

In PYTHONHOME that python reports, it seems that a backslash is missing after bin. I was wondering if you set it manually somewhere.
Otherwise this is a very bizzarre failure, haven't seen anything like this before.

vadimcn avatar Aug 17 '22 18:08 vadimcn