PostgreSQL Source Code  git master
assert.c File Reference
#include "postgres.h"
#include <unistd.h>
Include dependency graph for assert.c:

Go to the source code of this file.

Functions

void ExceptionalCondition (const char *conditionName, const char *errorType, const char *fileName, int lineNumber)
 

Function Documentation

◆ ExceptionalCondition()

void ExceptionalCondition ( const char *  conditionName,
const char *  errorType,
const char *  fileName,
int  lineNumber 
)

Definition at line 29 of file assert.c.

References buf, lengthof, PointerIsValid, and write_stderr.

Referenced by pg_re_throw().

33 {
34  if (!PointerIsValid(conditionName)
35  || !PointerIsValid(fileName)
36  || !PointerIsValid(errorType))
37  write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
38  else
39  {
40  write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
41  errorType, conditionName,
42  fileName, lineNumber);
43  }
44 
45  /* Usually this shouldn't be needed, but make sure the msg went out */
46  fflush(stderr);
47 
48 #ifdef HAVE_BACKTRACE_SYMBOLS
49  {
50  void *buf[100];
51  int nframes;
52 
53  nframes = backtrace(buf, lengthof(buf));
54  backtrace_symbols_fd(buf, nframes, fileno(stderr));
55  }
56 #endif
57 
58 #ifdef SLEEP_ON_ASSERT
59 
60  /*
61  * It would be nice to use pg_usleep() here, but only does 2000 sec or 33
62  * minutes, which seems too short.
63  */
64  sleep(1000000);
65 #endif
66 
67  abort();
68 }
#define write_stderr(str)
Definition: parallel.c:181
#define lengthof(array)
Definition: c.h:669
static char * buf
Definition: pg_test_fsync.c:67
#define PointerIsValid(pointer)
Definition: c.h:633