Skip to content

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Nov 16, 2021

Closes #10612. Some of the code is taken from there, some other from JochenKalmbach/StackWalker.

  • Uses the StackWalk64 API. Column numbers are omitted because DbgHelp doesn't seem to expose it, short of parsing the PDB ourselves (apparently it is also problematic for most Windows tools, including the Visual Studio debugger).
  • Always generates a PDB file unless --no-debug is specified. Also no longer emits DWARF debug information on Windows.
  • Renames the environment variable CRYSTAL_LOAD_DWARF to CRYSTAL_LOAD_DEBUG_INFO to be platform-independent.
> type test.cr
[1, 2, 3][5]

> crystal test.cr
Unhandled exception: Index out of bounds (IndexError)
  from src\indexable.cr:903 in '[]'
  from test.cr:1 in '__crystal_main'
  from src\crystal\main.cr:110 in 'main_user_code'
  from src\crystal\main.cr:96 in 'main'
  from src\crystal\main.cr:119 in 'main'
  from d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in '__scrt_common_main_seh'
  from C:\WINDOWS\System32\KERNEL32.DLL +94260 in 'BaseThreadInitThunk'
  from C:\WINDOWS\SYSTEM32\ntdll.dll +337489 in 'RtlUserThreadStart'

Note that this doesn't catch access violation (0xC0000005) and stack overflow (0xC00000FD) yet.

Related: #5430

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:runtime labels Nov 16, 2021
@straight-shoota straight-shoota mentioned this pull request Nov 16, 2021
22 tasks
@HertzDevil HertzDevil requested a review from oprypin November 18, 2021 16:49
@straight-shoota straight-shoota added this to the 1.3.0 milestone Nov 22, 2021
@straight-shoota straight-shoota merged commit 90218d9 into crystal-lang:master Nov 24, 2021
@HertzDevil HertzDevil deleted the feature/msvc-call-stack branch November 29, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stacktrace on win32

4 participants