#41070: Please include libgccjit with MinGW GCC distribution Open Date: 2020-12-23 17:28 Last Update: 2021-01-05 23:56 URL for this Ticket: https://osdn.net//projects/mingw/ticket/41070 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41070 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2021-01-05 23:56 Updated by: keith Comment: After a rebuild with -g -O0, GDB yields a more meaningful backtrace: (gdb) bt #0 0x01765861 in pp_format (pp=0x0, text=0x22fcac) at ../../src/gcc-9.2.0/gcc/pretty-print.c:1016 #1 0x0175bb77 in diagnostic_report_diagnostic ( context=0x238bfa0 <global_diagnostic_context>, diagnostic=0x22fcac) at ../../src/gcc-9.2.0/gcc/diagnostic.c:1015 #2 0x0175bfe7 in diagnostic_impl (richloc=0x22fd00, opt=-1, gmsgid=0x1eee273 <trim_filename(char const*)::this_file+211> "in %s, at %s:%d", ap=0x22fd68, kind=DK_ICE) at ../../src/gcc-9.2.0/gcc/diagnostic.c:1159 #3 0x0175cc66 in internal_error ( gmsgid=0x1eee273 <trim_filename(char const*)::this_file+211> "in %s, at %s:%d") at ../../src/gcc-9.2.0/gcc/diagnostic.c:1540 #4 0x0175cdbd in fancy_abort ( file=0x19aa0dc <NUM_GCC_JIT_TYPES+64> "../../src/gcc-9.2.0/gcc/jit/jit-tempdir.c", line=54, function=0x19aa0be <NUM_GCC_JIT_TYPES+34> "make_tempdir_path_template") at ../../src/gcc-9.2.0/gcc/diagnostic.c:1607 #5 0x00459c9f in make_tempdir_path_template () at ../../src/gcc-9.2.0/gcc/jit/jit-tempdir.c:54 #6 0x00459dc3 in gcc::jit::tempdir::create (this=0xd2084b0) at ../../src/gcc-9.2.0/gcc/jit/jit-tempdir.c:109 #7 0x004553f1 in gcc::jit::playback::context::compile (this=0x22fe9c) at ../../src/gcc-9.2.0/gcc/jit/jit-playback.c:1784 #8 0x004474da in gcc::jit::recording::context::compile (this=0xd207db0) at ../../src/gcc-9.2.0/gcc/jit/jit-recording.c:1379 #9 0x00443e32 in gcc_jit_context_compile (ctxt=0xd207db0) at ../../src/gcc-9.2.0/gcc/jit/libgccjit.c:2698 #10 0x0040163a in main (argc=1, argv=0xd201470) at /z/jit/tut01-hello-world.c:103 (gdb) The segmentation fault is due to that pp = 0x0 argument in pp_format(): it is supposed to be a (non-NULL) pointer to a pretty_printer object, and is immediately dereferenced, to acquire a pointer to the associated output buffer. Since the pretty_printer object pointer is itself NULL, which it clearly isn't expected to be, the segmentation fault is inevitable. It appears that, wherever it should have been initialized, that pretty_printer object pointer has not been; I have no idea where that initialization should have occurred, nor how to fix it. Where I *can* identify a clear defect is at the origin of the diagnostic call, at line 54 of jit-tempdir.c, where I see gcc_assert (tmpdir_buf[tmpdir_len - 1] == DIR_SEPARATOR); in which gcc_assert is a macro, invoking fancy_abort(), and where DIR_SEPARATOR has been explicitly defined as '/'. This follows assignment of tmpdir_buf, and tmpdir_len, within the code fragment: /* The result of choose_tmpdir is a cached buffer within libiberty, so we must *not* free it. */ tmpdir_buf = choose_tmpdir (); /* choose_tmpdir aborts on malloc failure. */ gcc_assert (tmpdir_buf); tmpdir_len = strlen (tmpdir_buf); /* tmpdir_buf should now have a dir separator as the final byte. */ gcc_assert (tmpdir_len > 0); gcc_assert (tmpdir_buf[tmpdir_len - 1] == DIR_SEPARATOR); in which choose_tmpdir() returns a path with Windows-style '\\' directory name separators, and thus, the assertion tests an invalid assumption. This I can fix, but the potential for some other assertion triggering a segmentation fault would remain. --------------------------------------------------------------------- Ticket Status: Reporter: eliz Owner: keith Type: Feature Request Status: Open [Owner assigned] Priority: 5 - Medium MileStone: (None) Component: GCC Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Please add libgccjit to the binaries included in the MinGW GCC distributions. This is required to be able to build projects that use libgccjit for JIT compilation of code. One example of this is "gccemacs", a branch of GNU Emacs development (soon to land on the master branch of Emacs) that compiles Emacs Lisp programs into native x86 code for faster runtime performance. Thank you. -- Ticket information of MinGW - Minimalist GNU for Windows project MinGW - Minimalist GNU for Windows Project is hosted on OSDN Project URL: https://osdn.net/projects/mingw/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/mingw/ticket/41070 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41070