microsoft / microsoft/vscode-cpptools
C++ debugger crashes on M2 Mac when using SDL and std::map
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Type: Bug
While working on a project using SDL, I ran into a weird issue where after setting a breakpoint, the VS Code debugger (using lldb) would stop at the breakpoint and show the stack trace, but couldn't load variables or step. The program then also froze, even after stopping the debugger and had to be force quit. I reduced it to the following minimal example:
main.cpp
#include <SDL.h>
#include <map>
int main() {
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
return -1;
}
std::map<int, int> badMap;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(LLDB Repro)
# Set the C++ standard to be used for compilation
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Define the source files to be compiled
file(GLOB_RECURSE SOURCE_FILES
main.cpp
)
# Create an executable from the source files
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
# Find the SDL2 package
find_package(SDL2 REQUIRED)
# Add the SDL2 include directories and link the SDL2 libraries
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
],
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-arm64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
If I set a breakpoint in the main function, VS Code will break there, but then something crashes internally. If you remove either the map or SDL_Init, the problem disappears. I also tried debugging manually from the command line with LLDB, but there the issue doesn't appear.
robert@RMBA LLDB Repro % lldb --version
lldb-1403.0.17.64
Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
robert@RMBA LLDB Repro % brew list --versions sdl2
sdl2 2.26.5
Extension version: 1.15.4
VS Code version: Code 1.78.2 (Universal) (b3e4e68a0bc097f0ae7907b217c1119af9e03435, 2023-05-10T14:44:45.204Z)
OS version: Darwin arm64 22.4.0
Modes:
Sandboxed: Yes
System Info
| Item | Value |
|---|---|
| CPUs | Apple M2 (8 x 24) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | 2, 2, 2 |
| Memory (System) | 8.00GB (0.08GB free) |
| Process Argv | --crash-reporter-id 87b0c4e4-4f3b-445b-9f36-34444426ed13 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vstes627:30244334
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30610679
3biah626:30602489
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
a9j8j154:30646983
showlangstatbar:30737416
vsctsb:30705553
azdwalk:30721579
pythonms35:30701012
pythonfmttext:30731395
fixhidewlkth:30730051
pythongtdpathcf:30739705
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riprodurre il crash sulla configurazione M2 segnalata usando main.cpp, CMakeLists.txt, launch.json e c_cpp_properties.json, quindi confrontare il comportamento di VS Code cppdbg con LLDB dalla riga di comando. Iniziare tracciando il percorso di avvio di LLDB e il percorso delle variabili e dell’esecuzione passo-passo dell’estensione; il lavoro è completato quando l’esempio minimo con SDL e std::map non si blocca né va più in crash e le variabili possono essere ispezionate e percorse passo-passo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cmake, cpp, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100