Skip to content

Instantly share code, notes, and snippets.

@vtjnash
Last active December 17, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtjnash/5623346 to your computer and use it in GitHub Desktop.
Save vtjnash/5623346 to your computer and use it in GitHub Desktop.

Debugging Build and Running Errors

This is a collection of things to try and steps to debugging on Windows.

Have you checked the build errata?

Have you searched the Julia issues for similar issues?

The message Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks. is generated whenever Julia is about to crash. Most commonly, it will appear when the program is segfaulting due to a NULL / invalid pointer. It can be the fault of anything, so without instructions on how to reproduce, it is difficult to impossible to fix.

Debugging can be done using the MinGW gdb. However, there are some important issues to be aware of because it is much less friendly than the linux version of gdb. You may want to setup Qt to work as a graphical front-end. This assumes you have already installed MinGW per the instructions above. After installing Qt, you will need to create an empty project and configure the run button to launch usr\bin\julia-debug-readline.exe and set the PATH environment variable to also include julia\usr\bin;julia\usr\lib;julia\usr\lib\julia. Secondly, you will need to add C:/MinGW/bin/gdb.exe as a debugger for the project. Then you can click debug and using the gui to control gdb (Julia launches in a separate console window). Alternatively, if you are comfortable with using gdb from the command line, you can edit julia.bat replacing the call to julia with gdb --args "%JULIA_HOME%julia-debug-readline.exe" %*

On linux, you can use winedbg.

The Makefile is setup to run commands in the Julia environment. This ability can be accessed by typing commands such as make run-julia DEFAULT_REPL=basic, make run-julia-debug, and make run CMD="llvm-config.exe". Or you can type make wine_path to have julia output the contents of the PATH variable (although you will have difficulty pasting this into the shell because of the use of \ and ; in the paths).

When running gdb, you will likely want to put a breakpoint in jl_error and jl_errorf and jl_throw by tying b jl_error, etc. to stop on errors. Then type r for run or c for continue or s for step-in or n for step-over. When it encouters an error, you can use bt to see if the stack has any meaning. Typically on the first entry will be valid. You can also use list to see the current code. If it is julia code that is being executed, you may instead be able to use print jlbacktrace() or print gdbbacktrace() or print gdblookup( <source instruction pointer from backtrace> ).

If the build is failing while creating the sys.ji file, you will need to run the build process manually from that step. First type cd base then run -bf sys.ji (for the first run) or run -f sys.ji (for rebuilding sys.ji from existing). Below is an example debugging session:

$ make debug
$ export PATH=`pwd`/usr/lib:`pwd`/usr/lib/julia:`pwd`/usr/bin:$PATH
$ cd base
$ gdb --args ../usr/bin/julia-debug-basic -bf sysimg.jl
gdb> break jl_throw
gdb> break jl_error
gdb> break jl_errorf
gdb> run
....
# <crash>
#note you may want to do a second run here, now that the symbol table is loaded, for the following to work
gdb> bt
gdb> list
gdb> print gdblookup(0)
gdb> print gdbbacktrace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment