An Address Sanitizer error causes the CodeLLDB extension to show binary code. The issue applies to macOS.
I expected it to show the line where the error was identified. EDIT: If you use the stack trace, you can find the line that caused the problem. It would just be nice for the debugger to stop and highlight the line that caused the problem.
Replicate
Run macOS with the CodeLLDB extension.
Example program with use-after-free bug.
#include <iostream>
using namespace std;
int main() {
int * p = new int;
delete p;
cout << *p << endl;
}
Compile and run, see use-after-free problem identified by ASAN.
$ g++ -Wall -Werror -pedantic -g --std=c++11 -Wno-sign-compare -Wno-comment -fsanitize=address -fsanitize=undefined main.cpp -o main.exe
$ ./main.exe
=================================================================
==84387==ERROR: AddressSanitizer: heap-use-after-free on address 0x000106f006f0 at pc 0x000104af2fa0 bp 0x00016b30f180 sp 0x00016b30f178
...
Here's what we get with the Microsoft C++ extension with the optional ASAN_OPTIONS set. This is on macOS with LLDB.
The VS Code debugger hangs due to the undefined behavior. This is a known bug in the VS Code MS C++ extension. We chose to recommend CodeLLDB on macOS due to known bugs when code under test contains undefined behavior.
MS extension launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "ASAN_OPTIONS",
"value": "abort_on_error=1:detect_leaks=0"
}
],
"externalConsole": false,
"MIMode": "lldb"
}
]
}
An Address Sanitizer error causes the CodeLLDB extension to show binary code. The issue applies to macOS.
I expected it to show the line where the error was identified. EDIT: If you use the stack trace, you can find the line that caused the problem. It would just be nice for the debugger to stop and highlight the line that caused the problem.
Replicate
Run macOS with the CodeLLDB extension.
Example program with use-after-free bug.
Compile and run, see use-after-free problem identified by ASAN.
VSCode
launch.json
with CodeLLDB extension.Run in VSCode, here's what you see.
Comparison: Microsoft extension
Here's what we get with the Microsoft C++ extension with the optional
ASAN_OPTIONS
set. This is on macOS with LLDB.The VS Code debugger hangs due to the undefined behavior. This is a known bug in the VS Code MS C++ extension. We chose to recommend CodeLLDB on macOS due to known bugs when code under test contains undefined behavior.
MS extension
launch.json
: