qsharp-compiler
qsharp-compiler copied to clipboard
Deeply nested scopes causes QIR generation crash on Mac (TEST ONLY)
The QIR Generation tests trigger a crash on macOS that shows up as a stack overflow if any scopes are nested beyond depth 8. After some initial investigation, we found that it only affects the test case. Using the same program in a stand-alone project does not crash, nor in the development project using the project references instead of package references, and even having the debugger launch the compiler dll directly with the exact same parameters as the test still did not trigger the crash. Somehow it only gets triggered when run via our F# test infrastructure. Using VSTEST_HOST_DEBUG environment variable to make dotnet test wait for a debugger connection before running the test, I found that the stack overflow happens sometime after the QIR has been generated and written out (both bitcode and .ll), which seems to indicate that it's something happening during garbage collection of objects used by the QIR Generation step.
To capture this failure for investigation but avoid blocking the pipeline, we have a "skipped" test that triggers the crash but can be enabled to experiment further. It's not clear what the next step in investigation would be, as neither the dotnet debugger nor the LLVM debugger (lldb) have identified a specific stack for the crash.