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

            Bug ID: 124211
           Summary: Poor error-handling when jobserver token acquisition
                    fails
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
                CC: amonakov at gcc dot gnu.org, arsen at gcc dot gnu.org,
                    mgorny at gentoo dot org
  Target Milestone: ---

In opts-common.cc:

bool
jobserver_info::get_token ()
{
  int fd = pipe_path.empty () ? rfd : pipefd;
  char c;
  unsigned n = read (fd, &c, 1);
  if (n != 1)
    {
      gcc_assert (errno == EAGAIN);
      return false;
    }
  else
    return true;
}

We've had cases where that errno is something else. This leads to an ICE if the
jobserver (from MAKEFLAGS="--jobserver-auth=fifo:/dev/foo") is in any way
unreadable (e.g. doesn't exist or bad permissions).

Unfortunately, connect doesn't check for an error on open either which makes
this worse (the assert would probably be okay otherwise):

void
jobserver_info::connect ()
{
  if (!pipe_path.empty ())
    {
#if HOST_HAS_O_NONBLOCK
      pipefd = open (pipe_path.c_str (), O_RDWR | O_NONBLOCK);
      is_connected = true;
#else
      is_connected = false;
#endif
    }
  else
    is_connected = true;
}

Reply via email to