// wrapper for exit(), calling NAError_stub_for_breakpoints() first
void NAExit(Int32 status)
{
    NAAssertMutexLock(); // Serialize termination
    releaseRTSSemaphore();
  if (status)
    NAError_stub_for_breakpoints(); // LCOV_EXCL_LINE :dpm
  if (status != 0)
    {
#ifndef _DEBUG
  char *abortOnError = getenv("ABORT_ON_ERROR");
  if (abortOnError != NULL)
     abort();
  else
  if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
     AssertException("", __FILE__, __LINE__).throwException();
   else
#endif
     abort();  // this will create core file on Linux
  }
  else
    // Calling my_mpi_fclose explicitly fixes the problem reported in bug 2243
    // for callers of NAExit(0) which is that registering it via the atexit
    // function does not guarantee that at process termination time
    // msg_mon_process_shutdown will be called before Seabed termination code
    // which requires msg_mon_process_shutdown to be called first.
    {
      my_mpi_fclose();
    }
   exit(status);
}
Example #2
0
void assert_botch_abend( const char *f, Int32 l, const char * m, const char *c)
{
#ifndef __EID
  NAAssertMutexLock(); // Assure "termination synchronization"
  int pid = (int) getpid();

  // get thread id for SeaMonster reader thread or other future
  // executor threads
  int tid = (int) syscall(__NR_gettid);

  Lng32 *tidPtr = tid == pid ? NULL : (Lng32*)&tid;
  if (tid == NAAssertMutexExTid)
    releaseRTSSemaphore(); // Semaphore is released on by main executor thread
  // log the message to the event log
  SQLMXLoggingArea::logSQLMXAssertionFailureEvent(f, l, m, c, tidPtr); // Any executor thread can log a failure

  // Log the message to stderr. On Linux stderr is mapped to a file
  // under $MY_SQROOT/logs and our output will be prefixed with a
  // timestamp and process ID.
  cerr << "Executor assertion failure in file " << f
       << " on line " << l << '\n';
  cerr << "Message: " << m << endl << flush;

#ifdef _DEBUG
  // If debug code, log the message again to the terminal
  char timeString[40] = "";
  time_t tm = time(0);
  ctime_r(&tm, timeString);
  printf("*** EXECUTOR ASSERTION FAILURE\n");
  printf("*** Time: %s", timeString);
  printf("*** Process: %d\n", pid);
  if (tid != pid)
    printf("*** Thread ID: %d\n", tid);
  printf("*** File: %s\n", f);
  printf("*** Line: %d\n", (int) l);
  if (c)
    printf("*** Condition: %s\n", c);
  printf("*** Message: %s\n", m);
  fflush(stdout);
#endif // _DEBUG

  // Cleanup the shared segment since the registered atexit function
  // will not be called
  char *envvar;
  envvar = getenv("SQL_LOOP_ON_ASSERT");
  if (envvar && *envvar == '1')
  {
    while (*envvar == '1')
          sleep(10);
  }
#ifndef _DEBUG
  char *abortOnError = getenv("ABORT_ON_ERROR");
  NAString fileName(f);
  if (abortOnError != NULL)
     abort();
  else if(((int)fileName.index("/optimizer/")) > -1 )
  {
    //throw exception if ABORT is called from optimizer dir
    AssertException(m, f, l).throwException();
  }
  else
#endif
    abort();
#else
  assert_botch_in_eid(f, l, m);
#endif
}