public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug jit/98586] New: libgccjit crashes with segmentation fault on failed gcc_assert
@ 2021-01-07 18:12 keith.marshall at mailinator dot com
  2021-01-07 23:35 ` [Bug jit/98586] " dmalcolm at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: keith.marshall at mailinator dot com @ 2021-01-07 18:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98586

            Bug ID: 98586
           Summary: libgccjit crashes with segmentation fault on failed
                    gcc_assert
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: keith.marshall at mailinator dot com
  Target Milestone: ---

In response to a feature request by Eli Zaretskii, with my follow-up as
detailed at https://osdn.net/projects/mingw/ticket/41070, I have been
evaluating the feasibility of providing a libgccjit.dll implementation for
mingw32.  Since GCC-9.2.0 is the most recent version, for which I have a
successful build of GCC itself, my initial efforts have been focussed on a
libgccjit implementation for that version.

With a series of patches, as attached to the OSDN ticket, I have successfully
compiled the shared library, as libgccjit-0.dll; I am even able to successfully
compile, and link, the tut01-hello-world.c example from your own online manual,
at https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html.  Unfortunately
however, when attempting to run this program, it crashes with a segmentation
fault, and no useful diagnostic message.

I have traced the origin of the crash to a failing assertion, at line 54 in
gcc/jit/jit-tempdir.c.  The failure of the assertion, as explained in the OSDN
ticket, is due to it testing an invalid assumption — on MS-Windows, both '/'
and '\\' are valid directory name separator characters, but the assertion
requires '/', whereas the libiberty.a choose_tmpdir() function returns a path
containing, and ending with, only '\\'.

While I can easily, and will, correct the invalid assumption, on which the
assertion fails, that the failed assertion terminates in a segmentation fault,
rather than a graceful termination, with an appropriate diagnostic message,
indicates that there is a deeper seated underlying defect.  The segmentation
fault actually occurs in function pp_format(), from gcc/pretty-print.c, when it
attempts to dereference a NULL pointer, passed as the printer member of the
global_dc structure.  I guess that this structure has not been initialized;
perhaps a call to diagnostic_initialize() has been omitted, but I have no idea
where to insert it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-16 14:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 18:12 [Bug jit/98586] New: libgccjit crashes with segmentation fault on failed gcc_assert keith.marshall at mailinator dot com
2021-01-07 23:35 ` [Bug jit/98586] " dmalcolm at gcc dot gnu.org
2021-01-08 11:18 ` keith.marshall at mailinator dot com
2021-01-11 22:09 ` dmalcolm at gcc dot gnu.org
2021-01-14 22:03 ` cvs-commit at gcc dot gnu.org
2021-01-14 22:04 ` dmalcolm at gcc dot gnu.org
2021-01-16 14:16 ` keith.marshall at mailinator dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).