Esempio n. 1
0
void lock(lock_t *_lock)
{
	pid_t pid = getpid();

	while (_lock->lock != UNLOCKED) {
		if (_lock->owner == pid) {
			debugf("lol, already have lock!\n");
			show_backtrace();
			panic(EXIT_LOCKING_CATASTROPHE);
			_exit(EXIT_FAILURE);
		}

		/* This is pretty horrible. But if we call lock()
		 * from stuck_syscall_info(), and a child is hogging a lock
		 * (or worse, a dead child), we'll deadlock, because main won't
		 *  ever get back, and subsequently check_lock().
		 * So we add an extra explicit check here.
		 */
		if (pid == mainpid) {
			check_lock(_lock);
		} else {
			/* Ok, we're a child pid.
			 * if something bad happened, like main crashed,
			 * we don't want to spin forever, so just get out.
			 */
			if ((shm->exit_reason != STILL_RUNNING) &&
			    (shm->exit_reason != EXIT_REACHED_COUNT)) {
				_exit(EXIT_FAILURE);
			}
		}

		usleep(1);
	}
	__lock(_lock);
}
Esempio n. 2
0
void
sys_exit (int code)
{
  /* Show error backtrace if possible.  */
  if (code != 0 && code != 4
      && (options.backtrace == 1
	  || (options.backtrace == -1 && compile_options.backtrace == 1)))
    show_backtrace ();

  /* Dump core if requested.  */
  if (code != 0
      && (options.dump_core == 1
	 || (options.dump_core == -1 && compile_options.dump_core == 1)))
    {
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
      /* Warn if a core file cannot be produced because
	 of core size limit.  */

      struct rlimit core_limit;

      if (getrlimit (RLIMIT_CORE, &core_limit) == 0 && core_limit.rlim_cur == 0)
	st_printf ("** Warning: a core dump was requested, but the core size"
		   "limit\n**          is currently zero.\n\n");
#endif
      
      
#if defined(HAVE_KILL) && defined(HAVE_GETPID) && defined(SIGQUIT)
      kill (getpid (), SIGQUIT);
#else
      st_printf ("Core dump not possible, sorry.");
#endif
    }

  exit (code);
}
Esempio n. 3
0
int func2(int a, int b)
{
	int c = a * b;
	printf("%s: c = %d\n", __FUNCTION__, c);
	show_backtrace();
	return c;
}
Esempio n. 4
0
File: main.c Progetto: guwu/trinity
/* exit() wrapper to clear the pid before exiting, so the
 * watchdog doesn't spin forever on a dead pid.
 */
void exit_main_fail(void)
{
	if (getpid() != shm->mainpid) {
		show_backtrace();
		BUG("wtf, exit_main_fail called from non main pid!\n");
	}

	shm->mainpid = 0;
	exit(EXIT_FAILURE);
}
void	err_free(unsigned int error, void *addr_chunk)
{
  if (error == F_DBFREE)
    fprintf(stderr, "*** Error: " DBFREE, addr_chunk);
  else if (error == F_INVFREE)
    fprintf(stderr, "*** Error: " INVFREE, addr_chunk);
  show_backtrace();
  show_mem_map();
  abort();
}
Esempio n. 6
0
/* method mdoc#MDoc#content for (self: MDoc): Array[String] */
val* mdoc__MDoc__content(val* self) {
val* var /* : Array[String] */;
val* var1 /* : Array[String] */;
var1 = self->attrs[COLOR_mdoc__MDoc___content].val; /* _content on <self:MDoc> */
if (unlikely(var1 == NULL)) {
PRINT_ERROR("Runtime error: %s", "Uninitialized attribute _content");
PRINT_ERROR(" (%s:%d)\n", "model/mdoc.nit", 22);
show_backtrace(1);
}
var = var1;
RET_LABEL:;
return var;
}
Esempio n. 7
0
/* method c_tools#ExternFile#filename for (self: ExternFile): String */
val* c_tools__ExternFile__filename(val* self) {
val* var /* : String */;
val* var1 /* : String */;
var1 = self->attrs[COLOR_c_tools__ExternFile___filename].val; /* _filename on <self:ExternFile> */
if (unlikely(var1 == NULL)) {
PRINT_ERROR("Runtime error: %s", "Uninitialized attribute _filename");
PRINT_ERROR(" (%s:%d)\n", "c_tools.nit", 104);
show_backtrace(1);
}
var = var1;
RET_LABEL:;
return var;
}
Esempio n. 8
0
File: error.c Progetto: Lao16/gcc
void
sys_abort (void)
{
  /* If backtracing is enabled, print backtrace and disable signal
     handler for ABRT.  */
  if (options.backtrace == 1
      || (options.backtrace == -1 && compile_options.backtrace == 1))
    {
      show_backtrace ();
      signal (SIGABRT, SIG_DFL);
    }

  abort();
}
Esempio n. 9
0
/* method mdoc#MDoc#content for (self: Object): Array[String] */
val* VIRTUAL_mdoc__MDoc__content(val* self) {
val* var /* : Array[String] */;
val* var1 /* : Array[String] */;
val* var3 /* : Array[String] */;
{ /* Inline mdoc#MDoc#content (self) on <self:Object(MDoc)> */
var3 = self->attrs[COLOR_mdoc__MDoc___content].val; /* _content on <self:Object(MDoc)> */
if (unlikely(var3 == NULL)) {
PRINT_ERROR("Runtime error: %s", "Uninitialized attribute _content");
PRINT_ERROR(" (%s:%d)\n", "model/mdoc.nit", 22);
show_backtrace(1);
}
var1 = var3;
RET_LABEL2:(void)0;
}
var = var1;
RET_LABEL:;
return var;
}
Esempio n. 10
0
/* method c_tools#ExternFile#filename for (self: Object): String */
val* VIRTUAL_c_tools__ExternFile__filename(val* self) {
val* var /* : String */;
val* var1 /* : String */;
val* var3 /* : String */;
{ /* Inline c_tools#ExternFile#filename (self) on <self:Object(ExternFile)> */
var3 = self->attrs[COLOR_c_tools__ExternFile___filename].val; /* _filename on <self:Object(ExternFile)> */
if (unlikely(var3 == NULL)) {
PRINT_ERROR("Runtime error: %s", "Uninitialized attribute _filename");
PRINT_ERROR(" (%s:%d)\n", "c_tools.nit", 104);
show_backtrace(1);
}
var1 = var3;
RET_LABEL2:(void)0;
}
var = var1;
RET_LABEL:;
return var;
}
Esempio n. 11
0
void __BUG(const char *bugtxt, const char *filename, const char *funcname, unsigned int lineno)
{
	printf("BUG!: %s%s%s\n", ANSI_RED, bugtxt, ANSI_RESET);
	printf("BUG!: %s\n", VERSION);
	printf("BUG!: [%d] %s:%s:%u\n", getpid(), filename, funcname, lineno);

	show_backtrace();

	/* Now spin indefinitely (but allow ctrl-c) */

	set_dontkillme(getpid(), TRUE);

	while (1) {
		if (shm->exit_reason == EXIT_SIGINT) {
			set_dontkillme(getpid(), FALSE);
			exit(EXIT_FAILURE);
		}
		sleep(1);
	}
}
Esempio n. 12
0
void die_if_kernel(const char *str, ...)
{
	char buffer[256];
	va_list va;

	if (user_mode(__frame))
		return;

	va_start(va, str);
	vsprintf(buffer, str, va);
	va_end(va);

	console_verbose();
	printk("\n===================================\n");
	printk("%s\n", buffer);
	show_backtrace(__frame, 0);

	__break_hijack_kernel_event();
	do_exit(SIGSEGV);
}
/* A signal handler to allow us to output a backtrace.  */
void
backtrace_handler (int signum)
{
  /* Since this handler is established for more than one kind of signal, 
     it might still get invoked recursively by delivery of some other kind
     of signal.  Use a static variable to keep track of that. */
  if (fatal_error_in_progress)
    raise (signum);
  fatal_error_in_progress = 1;

  show_backtrace();

  /* Now reraise the signal.  We reactivate the signal's
     default handling, which is to terminate the process.
     We could just call exit or abort,
     but reraising the signal sets the return status
     from the process correctly. */
  signal (signum, SIG_DFL);
  raise (signum);
}
Esempio n. 14
0
void lock(lock_t *_lock)
{
	pid_t pid = getpid();

	while (_lock->lock == LOCKED) {
		if (_lock->owner == pid) {
			debugf("lol, already have lock!\n");
			show_backtrace();
			panic(EXIT_LOCKING_CATASTROPHE);
			_exit(EXIT_FAILURE);
		}

		/* This is pretty horrible. But if we call lock()
		 * from the watchdog code, and a child is hogging a lock
		 * (or worse, a dead child), we'll never call check_lock()
		 * from the watchdog loop because we'll be stuck here.
		 */
		if (pid == watchdog_pid) {
			check_lock(_lock);
		} else {
			/* Ok, we're a child pid.
			 * if something bad happened, like main/watchdog crashed,
			 * we don't want to spin forever, so just get out.
			 */
			if ((shm->exit_reason != STILL_RUNNING) &&
			    (shm->exit_reason != EXIT_REACHED_COUNT)) {
				_exit(EXIT_FAILURE);
			}
		}

		_lock->contention++;
		usleep(1);
	}

	_lock->lock = LOCKED;
	_lock->contention = 0;
	_lock->owner = pid;
}
Esempio n. 15
0
void smp_show_backtrace_all_cpus(void)
{
	xc0((smpfunc_t) show_backtrace);
	show_backtrace();
}