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

--- Comment #1 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Continuing to debug, I've added a darwin-specific implementation of
getexecname() with this patch:

diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c
index cc1011e8b5d..3e4161e47c6 100644
--- a/libbacktrace/fileline.c
+++ b/libbacktrace/fileline.c
@@ -47,8 +47,23 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "internal.h"

 #ifndef HAVE_GETEXECNAME
+#if __APPLE__
+#include <mach-o/dyld.h>
+
+char execname_buf[10240];
+
+static const char *
+getexecname (void)
+{
+  unsigned size = sizeof(execname_buf);
+
+  _NSGetExecutablePath(execname_buf, &size);
+  return execname_buf;
+}
+#else
 #define getexecname() NULL
 #endif
+#endif

 #if !defined (HAVE_KERN_PROC_ARGS) && !defined (HAVE_KERN_PROC)

@@ -192,6 +207,7 @@ fileline_initialize (struct backtrace_state *state,
          abort ();
        }

+      printf("libbacktrace filename = %s\n", filename ? filename : "NULL");
       if (filename == NULL)
        continue;



Sadly, this is not enough. This is leading to another error:

rmeur /tmp/ibin/gcc $ ./f951 ../../z1.f90
 p main
Analyzing compilation unit
f951: internal compiler error: in record_reference, at cgraphbuild.c:64
libbacktrace filename = NULL
libbacktrace filename = /private/tmp/ibin/gcc/./f951

f951: internal compiler error: Bus error: 10
libbacktrace filename = NULL
libbacktrace filename = /private/tmp/ibin/gcc/./f951

Internal compiler error: Error reporting routines re-entered.
libbacktrace filename = NULL
libbacktrace filename = /private/tmp/ibin/gcc/./f951


The backtrace (provided by lldb) for this new error is:

  * frame #0: 0x00000001013c1fff
f951`backtrace_free_locked(state=0x0000000142fd3000, addr=0x0000000144e94410,
size=5450529520) at mmap.c:104:15
    frame #1: 0x00000001013c21f4 f951`backtrace_alloc(state=0x0000000142fd3000,
size=25872, error_callback=(f951`::bt_err_callback(void *, const char *, int)
at diagnostic.c:552:3), data=0x00007ffeefbff26c) at mmap.c:152:3
    frame #2: 0x00000001013c1572 f951`macho_add(state=0x0000000142fd3000,
filename="/usr/local/opt/isl/lib/libisl.22.dylib", descriptor=5, offset=0,
match_uuid=0x0000000000000000, base_address=5415538688, skip_symtab=0,
error_callback=(f951`::bt_err_callback(void *, const char *, int) at
diagnostic.c:552:3), data=<unavailable>, fileline_fn=0x00007ffeefbfe858,
found_sym=0x00007ffeefbfe854) at macho.c:575:6
    frame #3: 0x00000001013c1d11
f951`backtrace_initialize(state=0x0000000142fd3000,
filename="/tmp/ibin/gcc/f951", descriptor=5,
error_callback=(f951`::bt_err_callback(void *, const char *, int) at
diagnostic.c:552:3), data=0x00007ffeefbff26c, fileline_fn=0x00007ffeefbfe8b8)
at macho.c:1259:12
    frame #4: 0x00000001013c015f
f951`fileline_initialize(state=0x0000000142fd3000,
error_callback=(f951`::bt_err_callback(void *, const char *, int) at
diagnostic.c:552:3), data=0x00007ffeefbff26c) at fileline.c:241:12

Reply via email to