Fix a crash in jit.c

A user at Mozilla pointed out a crash in jit.c.  In his situation, an
inferior using the JIT API exec'd an executable that did not use it.
This caused an assertion failure when jit.c:free_objfile_data called
delete_breakpoint with NULL.

This patch fixes the problem in the obvious way.  New test case
included.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* jit.c (free_objfile_data): Only delete breakpoint if non-null.

gdb/testsuite/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>
	    Simon Marchi <simark@simark.ca>

	* gdb.base/jit-exec.exp: New file.
	* gdb.base/jit-exec.c: New file.
	* gdb.base/jit-execd.c: New file.
This commit is contained in:
Tom Tromey 2018-12-19 11:44:28 -07:00
parent 140a4bc099
commit 2cd8cc0b66
6 changed files with 115 additions and 1 deletions

View file

@ -1464,7 +1464,8 @@ free_objfile_data (struct objfile *objfile, void *data)
if (ps_data != NULL && ps_data->objfile == objfile)
{
ps_data->objfile = NULL;
delete_breakpoint (ps_data->jit_breakpoint);
if (ps_data->jit_breakpoint != NULL)
delete_breakpoint (ps_data->jit_breakpoint);
ps_data->cached_code_address = 0;
}
}