# How to generate a minidump and backtrace for a hanging Julia program on Appveyor/Windows?

**URL:** https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451
**Category:** General Usage
**Tags:** question, windows, debug, debugging
**Created:** [January 16, 2020, 7:11pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451 "2020-01-16T19:11:14Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 16, 2020, 7:11pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/1 "2020-01-16T19:11:14Z")

</div>

Hello all,

I have what appears to be a deadlock(?) bug in my Julia package that is exposed _only_ on Appveyor, and only when I test through the CI – if I enter the Appveyor VM through RDP and manually run tests, they pass…weird. Also, FWIW, this only happens on Julia 1.3. It all works for Julia 1.2. Please see [this github issue](https://github.com/Circuitscape/Omniscape.jl/issues/13) for context.

Essentially, because the bug is only exposed through the CI, I need a way to generate a minidump or other debugging info via commands in the appveyor.yml, _or_ I can RDP into the VM while my program is hanging and run commands manually from another terminal session (that might be the best option?).

I’m pretty new to debugging at this level, so any help (especially suggesting specific commands to run to generate the info I need) would be very much appreciated.

Thanks!  
Vincent

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [January 18, 2020, 3:24am UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/2 "2020-01-18T03:24:37Z")

</div>

Since you have RDP access it is probably easiest to do this manually:

- download and install msys2 ([https://www.msys2.org/](https://www.msys2.org/))
- install gdb (probably `gdb` or `mingw-w64-gdb`)
- run gdb
- at the `(gdb)` prompt, type `attach <pid>` where `<pid>` is the process ID of the deadlocked process (visible in the task manager)
- at the `(gdb)` prompt, type `bt`, which should (hopefully) give you a backtrace hinting toward the problem

See also

- [gdb debugging tips · The Julia Language](https://docs.julialang.org/en/v1/devdocs/debuggingtips/)
- [https://github.com/JuliaLang/julia/blob/master/doc/build/windows.md#windows-build-debugging](https://github.com/JuliaLang/julia/blob/master/doc/build/windows.md#windows-build-debugging) (especially the note about viewing and switching threads w/ `info threads`…)

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 18, 2020, 5:49pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/3 "2020-01-18T17:49:06Z")

</div>

Thanks so much @ihnorton! I will look into all of this.

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 21, 2020, 9:09pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/4 "2020-01-21T21:09:19Z")

</div>

Hmm, when trying to run the above, I’m getting some errors (I think)

```julia
# gdb
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) attach 1316
Attaching to process 1316
[New Thread 1316.0x2e4]
[New Thread 1316.0x60c]
[New Thread 1316.0x500]
[New Thread 1316.0x34c]
warning: "C:\julia\bin\julia.exe": not in executable format: no symbols
warning: `C:\julia\bin\julia.exe': can't read symbols: no symbols.
(gdb) bt
#0 0x00000000 in ?? ()

```

I get a similar result for both of the PIDs named julia.exe

---

<div class="post-metadata">

### Author: ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)
#### Post date: [January 21, 2020, 10:06pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/5 "2020-01-21T22:06:23Z")

</div>

I don’t know why this has been happening, since I thought older versions used to work, but type `sharedlibrary` and (nearly) everything may start working again (of things that worked before).

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 21, 2020, 10:33pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/6 "2020-01-21T22:33:15Z")

</div>

Hmm, still getting the same error. I ran `sharedlibrary` at the gdb prompt. Is that what you meant?

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 21, 2020, 10:37pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/7 "2020-01-21T22:37:06Z")

</div>

Tried again and ran `sharedlibrary` after `attach` and got a lot of output, but the backtrace was still empty upon running `bt`

This appeared quite a lot in the output of `sharedlibrary`:

```julia
Shared library architecture i386:x86-64 is not compatible with target architecture i386.

```

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [January 30, 2020, 11:32pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/8 "2020-01-30T23:32:50Z")

</div>

Just bumping this. Anyone have any advice on how to get a backtrace or minidump from a hanging Julia process? I think this will help resolve a bug in Julia 1.3 as well (as this issue does not occur in 1.2) if that provides any additional motivation 🙂

Thanks again!

---

<div class="post-metadata">

### Author: ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)
#### Post date: [February 3, 2020, 3:59am UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/9 "2020-02-03T03:59:05Z")

</div>

Ah, you’re also using the wrong build of gdb. I recommend getting it from mingw64 directly.

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [February 3, 2020, 6:06pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/10 "2020-02-03T18:06:06Z")

</div>

Ah, thanks!! I’ll try that.

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [February 3, 2020, 9:11pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/11 "2020-02-03T21:11:01Z")

</div>

I’m using the 64 bit version of MinGW provided on the appveyor VM, and running gdb.exe directly. Appveyor has several versions of MinGW (64 and 32 bit) installed, and I’ve tried all of them with no luck (I’m getting the same error as above about incompatible architecture).

---

<div class="post-metadata">

### Author: ![adrpo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adrpo/32/11384_2.png) [@adrpo](https://discourse.julialang.org/u/adrpo)
#### Post date: [February 14, 2020, 11:18am UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/12 "2020-02-14T11:18:03Z")

</div>

In gdb do:  
`gdb > file C:\julia\bin\libjulia.dll`

That will load the symbols and the backtrace will work fine. Do  
`gdb > thread 1`  
to switch to the main thread before bt

---

<div class="post-metadata">

### Author: ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)
#### Post date: [February 14, 2020, 4:56pm UTC](https://discourse.julialang.org/t/how-to-generate-a-minidump-and-backtrace-for-a-hanging-julia-program-on-appveyor-windows/33451/13 "2020-02-14T16:56:34Z")

</div>

Thank you so much!!! It worked!!

Posting the entire process here to have it in one post, which I will mark as the solution.

Step 1: open the 64 bit version of gdb (navigated to C:\mingw-w64\x86\_64-8.1.0-posix-seh-rt\_v6-rev0\mingw64\bin\gdb.exe on appveyor)

Step 2: `gdb > sharedlibrary`

Step 3: `gdb > file C:\julia\bin\libjulia.dll`

Step 4: `gdb > attach <pid>` The PID be found in the resource monitor through task manager

Step 4: `gdb > thread 1` to switch to the main thread

Step 5: `gdb > bt` to print the back trace.

Thank you @ihnorton, @adrpo, and @jameson for taking the time to help me figure this out.

**EDIT**  
And since this post was originally about creating a mindump, here’s how to do that:  
Step 1: Open an internet browser  
Step 2: go to [Process Explorer - Windows Sysinternals | Microsoft Docs](https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer)  
Step 3: click run now from Sysinternals Live  
Step 4: Right click on the Julia process and select create dump \> create minidump
