MCPcopy Create free account
hub / github.com/apache/cloudberry / CdbProgramErrorHandler

Function CdbProgramErrorHandler

src/backend/tcop/postgres.c:3852–3898  ·  view source on GitHub ↗

CDB: Signal handler for program errors */

Source from the content-addressed store, hash-verified

3850
3851/* CDB: Signal handler for program errors */
3852static void
3853CdbProgramErrorHandler(SIGNAL_ARGS)
3854{
3855 int save_errno = errno;
3856 char *pts = "process";
3857
3858 if (!pthread_equal(main_tid, pthread_self()))
3859 {
3860#ifndef _WIN32
3861 write_stderr("\nUnexpected internal error: Master %d received signal %d in worker thread %lu (forwarding signal to main thread)\n\n",
3862 MyProcPid, postgres_signal_arg, (unsigned long)pthread_self());
3863#else
3864 write_stderr("\nUnexpected internal error: Master %d received signal %d in worker thread %lu (forwarding signal to main thread)\n\n",
3865 MyProcPid, postgres_signal_arg, (unsigned long)pthread_self().p);
3866#endif
3867 /* Only forward if the main thread isn't quick-dying. */
3868 if (!in_quickdie)
3869 pthread_kill(main_tid, postgres_signal_arg);
3870
3871 /*
3872 * Don't exit the thread when we reraise SEGV/BUS/ILL signals to the OS.
3873 * This thread will die together with the main thread after the OS reraises
3874 * the signal. This is to ensure that the dumped core file contains the call
3875 * stack on this thread for later debugging.
3876 */
3877 if (!(gp_reraise_signal &&
3878 (postgres_signal_arg == SIGSEGV ||
3879 postgres_signal_arg == SIGILL ||
3880 postgres_signal_arg == SIGBUS)))
3881 {
3882 pthread_exit(NULL);
3883 }
3884
3885 return;
3886 }
3887
3888
3889 if (Gp_role == GP_ROLE_DISPATCH)
3890 pts = "Master process";
3891 else if (Gp_role == GP_ROLE_EXECUTE)
3892 pts = "Segment process";
3893 else
3894 pts = "Process";
3895
3896 errno = save_errno;
3897 StandardHandlerForSigillSigsegvSigbus_OnMainThread(pts, PASS_SIGNAL_ARGS);
3898}
3899
3900/* signal handler for floating point exception */
3901void

Callers

nothing calls this directly

Calls 3

pthread_selfFunction · 0.85
write_stderrFunction · 0.50

Tested by

no test coverage detected