Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gcc] -freport-bug doesn't work on ICEs #20894

Open
lazka opened this issue May 13, 2024 · 1 comment
Open

[gcc] -freport-bug doesn't work on ICEs #20894

lazka opened this issue May 13, 2024 · 1 comment

Comments

@lazka
Copy link
Member

lazka commented May 13, 2024

As pointed out in #20864 passing -freport-bug to GCC when it triggers an ICE leads to another error:

Please submit a full bug report, with preprocessed source.
See <https://github.com/msys2/MINGW-packages/issues> for instructions.
gcc: fatal error: cannot execute 'C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/cc1.exe': open temporary output file: No such file or directory

I don't know what it's supposed to do and if that is worth looking into, since I don't know how to make it do anything without knowing a way to crash gcc.

@lazka lazka changed the title gcc: -freport-bug doesn't work on ICEs [gcc] -freport-bug doesn't work on ICEs May 14, 2024
@ssbssa
Copy link

ssbssa commented May 15, 2024

I did a quick grep of the gcc sources for "open temporary output file" and found the likely reason for this.

In gcc/gcc.cc do_report_bug() calls run_attempt(append=1), this append flag gets through pex_run/pex_run_in_environment in libiberty/pex-common.c, which ends in a call of pex_win32_open_write(append=1) in libiberty/pex-win32.c.
The function looks like this:

static int
pex_win32_open_write (struct pex_obj *obj ATTRIBUTE_UNUSED, const char *name,
		      int binary, int append)
{
  /* Note that we can't use O_EXCL here because gcc may have already
     created the temporary file via make_temp_file.  */
  if (append)
    return -1;
  return _open (name,
		(_O_WRONLY | _O_CREAT | _O_TRUNC
		 | (binary ? _O_BINARY : _O_TEXT)),
		_S_IREAD | _S_IWRITE);
}

So it immediately returns -1, which results in this error in pex_run_in_environment():

      out = obj->funcs->open_write (obj, outname,
				    (flags & PEX_BINARY_OUTPUT) != 0,
				    (flags & PEX_STDOUT_APPEND) != 0);
      if (out < 0)
	{
	  *err = errno;
	  errmsg = "open temporary output file";
	  goto error_exit;
	}

No clue how to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants