Vscode-cpptools: Stopping due to Debug session failure: fatal error: NullReferenceException: Object reference not set to an instance of an object

Created on 12 Mar 2019  路  10Comments  路  Source: microsoft/vscode-cpptools

Type: Debugger
I get "Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object" in the debug console when trying to debug using MIEngine. This is happening on Windows but not Mac.

I thought this was the same as https://github.com/Microsoft/vscode-cpptools/issues/2922, but maybe not. I'm not sure how to tell, but the error is the same, and both happen when trying to start an MIEngine debug session.

I'm using the exact same vscode/cpptools versions on Windows and Mac, and the exact same project with the same launch.json.

Describe the bug

  • OS and Version: Windows 10 Pro v1803
  • VS Code Version: 1.32.1
  • C/C++ Extension Version: 0.21.0

Additional context
I enabled logging in my launch.json but still only see "Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object" in the debug console.

        "logging": {
            "trace": true,
            "traceResponse": true,
            "engineLogging": true
         },
debugger investigate

Most helpful comment

@Nitori That is most likely a duplicate of https://github.com/microsoft/vscode-cpptools/issues/4125 , that should be fixed in our pending 0.25.1.

All 10 comments

Some people said in #2922 that setting externalConsole to false worked around that issue, but I have it set already.

"externalConsole": false,

Interesting twist. Setting externalConsole to true makes it work. I guess that's why it works on Mac as externalConsole only applies to Windows and Linux. Also, I get all of the trace data now in the debug console, so with externalConsole set to false whatever is happening is happening before any trace data is captured.

That said, there is a workaround, but it is a bug. As it stands anyone using our extension on Windows (and probably Linux) will have this problem as we set externalConsole to false by default when creating projects.

Please let me know if there's anything we can do to help.

Could you get to the version of the extension that was not working and kept erroring with NullReferenceException and zip it up?

Extensions are usually installed in %USER%/.vscode/extensions and you want to zip up ms.vscode-cpptools

I have the same issue during debugging an embedded esp32 application using the ms-arduino-extension with 0.22.0-insider3 cpptools on vscode-insider
Version: 1.33.0-insider (user setup) Commit: 5a88160c7dc5db820a564e3872e0de087ff3563d Date: 2019-03-15T15:54:09.237Z Electron: 3.1.6 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17763

as well as with 0.22.0-insider3 and 0.21.0 cpptools on regular vscode

Version: 1.32.3 (user setup) Commit: a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4 Date: 2019-03-14T23:43:35.476Z Electron: 3.1.6 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17763

Debug Console output for externalConsole:false ...
--> E (stopped): {"event":"stopped","body":{"reason":"exception","threadId":-2,"text":"","allThreadsStopped":true,"source":{"name":"main.cpp","path":"c:\\Users\\tillm\\GDrive\\Dev\\arduino\\portable\\packages\\esp32\\hardware\\esp32\\1.0.2-rc1\\cores\\esp32\\main.cpp","sources":[],"checksums":[]},"line":30,"column":1},"seq":579,"type":"event"} <-- C (threads-8): {"command":"threads","type":"request","seq":8} --> R (threads-8): {"request_seq":8,"success":true,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"},{"id":1073457244,"name":"Thread #1073457244"},{"id":1073454676,"name":"Thread #1073454676"},{"id":1073445320,"name":"Thread #1073445320"},{"id":1073456088,"name":"Thread #1073456088"},{"id":1073467756,"name":"Thread #1073467756"},{"id":1073463652,"name":"Thread #1073463652"},{"id":1073465064,"name":"Thread #1073465064"}]},"seq":582,"type":"response"} <-- C (stackTrace-9): {"command":"stackTrace","arguments":{"threadId":-2,"startFrame":0,"levels":20},"type":"request","seq":9} --> E (output): {"event":"output","body":{"category":"console","output":"1: (3411) <-1023-stack-list-arguments 0 0 2\r\n"},"seq":585,"type":"event"} 1: (3411) <-1023-stack-list-arguments 0 0 2 --> E (output): {"event":"output","body":{"category":"console","output":"1: (3415) ->1023^error,msg=\"Target is executing.\"\r\n"},"seq":587,"type":"event"} 1: (3415) ->1023^error,msg="Target is executing." --> E (output): {"event":"output","body":{"category":"console","output":"1: (3415) 1023: elapsed time 3\r\n"},"seq":589,"type":"event"} 1: (3415) 1023: elapsed time 3 --> E (output): {"event":"output","body":{"category":"console","output":"1: (3416) ->(gdb)\r\n"},"seq":591,"type":"event"} 1: (3416) ->(gdb) --> E (output): {"event":"output","body":{"category":"console","output":"1: (3417) ->&\"\\n\"\r\n"},"seq":593,"type":"event"} 1: (3417) ->&"\n" Stopping due to fatal error: NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

Debug Console output for externalConsole:true ...
--> E (output): {"event":"output","body":{"category":"console","output":"1: (2397) <-1023-stack-list-arguments 0 0 2\r\n"},"seq":584,"type":"event"} 1: (2397) <-1023-stack-list-arguments 0 0 2 --> E (output): {"event":"output","body":{"category":"console","output":"1: (2400) ->1023^error,msg=\"Target is executing.\"\r\n"},"seq":586,"type":"event"} 1: (2400) ->1023^error,msg="Target is executing." --> E (output): {"event":"output","body":{"category":"console","output":"1: (2400) ->(gdb)\r\n"},"seq":588,"type":"event"} 1: (2400) ->(gdb) --> E (output): {"event":"output","body":{"category":"console","output":"1: (2400) 1023: elapsed time 2\r\n"},"seq":590,"type":"event"} 1: (2400) 1023: elapsed time 2 --> E (output): {"event":"output","body":{"category":"console","output":"1: (2401) ->&\"\\n\"\r\n"},"seq":592,"type":"event"} 1: (2401) ->&"\n" --> E (output): {"event":"output","body":{"category":"console","output":"1: (2401) ->^done\r\n"},"seq":594,"type":"event"} 1: (2401) ->^done --> E (output): {"event":"output","body":{"category":"console","output":"1: (2402) ->(gdb)\r\n"},"seq":596,"type":"event"} 1: (2402) ->(gdb) Stopping due to fatal error: NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

Using cpptools 0.19.1-insider3 seems to work without the NullReferenceException but still the debug session does not run through - but could have other reasons.

Version: 1.33.0-insider (user setup)
Commit: 5a88160c7dc5db820a564e3872e0de087ff3563d
Date: 2019-03-15T15:54:09.237Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17763

Debug Console output:
=breakpoint-deleted,id="1" Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger) Note: automatically using hardware breakpoints for read-only addresses. @"Target halted. PRO_CPU: PC=0x400D1825 (active) APP_CPU: PC=0x4020853A \n" [New Thread 1073592968]

and with logging:
--> E (output): {"event":"output","body":{"category":"console","output":"1: (7778) ->(gdb)\r\n"},"seq":677,"type":"event"} 1: (7778) ->(gdb) --> E (output): {"event":"output","body":{"category":"console","output":"1: (7778) ->&\"\\n\"\r\n"},"seq":679,"type":"event"} 1: (7778) ->&"\n" --> E (output): {"event":"output","body":{"category":"console","output":"1: (7779) ->^done\r\n"},"seq":681,"type":"event"} 1: (7779) ->^done --> E (output): {"event":"output","body":{"category":"console","output":"1: (7779) ->(gdb)\r\n"},"seq":683,"type":"event"} 1: (7779) ->(gdb)

I started getting this "Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object" when starting a debugging session of an ARM application via GDB after updating to 0.25.0. Works fine with 0.24.1

On 0.24.1 I can see it launch the debugging session in the Terminal, but in 0.25.0 I only get that error in the Debug Console tab.

This is on Windows 10
Version: 1.37.1 (system setup)
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

We're also seeing the NullReferenceException error while doing GDB remote debugging (x86_64 host to x86_64 target) with 0.25.0. Downgrading to 0.24.1 alleviates the issue. Setting externalConsole to true or false seems to make no difference, so I'm guessing it's an unrelated issue.

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:17:25.463Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 5.0.0-25-generic

@Nitori That is most likely a duplicate of https://github.com/microsoft/vscode-cpptools/issues/4125 , that should be fixed in our pending 0.25.1.

Fixed with 0.25.1.

Was this page helpful?
0 / 5 - 0 ratings