This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING][PATCH] Segfault while unwinding an invalid function pointer


Jakub Jelinek wrote on 10/29/2007 03:41:53 PM:
This should only happen for a signal frame or a garbage address.

Or a function without unwind info. Something that happens quite often. E.g. even with -fasynchronous-unwind-tables built glibc, the outermost stack frame is always without unwind info and so every backtrace(3) will hit your tmpfile/write/fclose at least once. This is too costly.

Would a single call to tmpfile be acceptable for the duration of the program? I'm thinking something like this:


  static FILE* tmp_file = NULL;
  static int tmp_offset = 0;

  if (!tmp_file) {
    tmp_file = tmpfile();
  }
  if (tmp_file)
    {
      if (tmp_offset + len > 4096)
        {
	  rewind(tmp_file);
	  tmp_offset = 0;
	}
      rc = write (fileno(tmp_file), addr, len);
      tmp_offset += rc;
      result = (rc == len);
    }

This way tmp_file is only called once, write is called each time, and rewind is called when the file would exceed 4k.

Is this still too costly? Or should I stop asking?

--
Pete Eberlein
IBM Linux Technology Center
Linux on Power Toolchain


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]