assfail.c revision 883492d5a933deb34cd27521e7f2756773cd27af
316N/A * The contents of this file are subject to the terms of the 316N/A * Common Development and Distribution License (the "License"). 316N/A * You may not use this file except in compliance with the License. 316N/A * See the License for the specific language governing permissions 316N/A * and limitations under the License. 316N/A * When distributing Covered Code, include this CDDL HEADER in each 316N/A * If applicable, add the following below this CDDL HEADER, with the 316N/A * fields enclosed by brackets "[]" replaced with your own identifying 316N/A * information: Portions Copyright [yyyy] [name of copyright owner] 316N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 316N/A * Use is subject to license terms. 316N/A#
pragma ident "%Z%%M% %I% %E% SMI" 684N/A * Called from __assert() to set panicstr and panic_thread. 316N/A * Called from exit() (atexit function) to give precedence 316N/A * to assertion failures and a core dump over _exit(). 723N/A /* to help with core file debugging */ 723N/A /* set SIGABRT signal handler to SIG_DFL w/o grabbing any locks */ 316N/A /* delete SIGABRT from the signal mask */ 723N/A * Write a panic message w/o grabbing any locks other than assert_lock. 723N/A * We have no idea what locks are held at this point. 723N/A char msg[
400];
/* no panic() message in the library is this long */ 684N/A * Utility function for converting a long integer to a string, avoiding stdio. 684N/A * 'base' must be one of 10 or 16 684N/A char lbuf[
24];
/* 64 bits fits in 16 hex digits, 20 decimal */ 684N/A * Report application lock usage error for mutexes and condvars. * Not called if _THREAD_ERROR_DETECTION=0. * Continue execution if _THREAD_ERROR_DETECTION=1. * Dump core if _THREAD_ERROR_DETECTION=2. /* take a snapshot of the mutex before it changes (we hope!) */ /* avoid recursion deadlock */ "\n*** _THREAD_ERROR_DETECTION: lock usage error detected ***\n");
(
void)
strcat(
buf,
": calling thread does not own the lock");
(
void)
strcat(
buf,
": calling thread already owns the lock");
* Report application lock usage error for rwlocks. * Not called if _THREAD_ERROR_DETECTION=0. * Continue execution if _THREAD_ERROR_DETECTION=1. * Dump core if _THREAD_ERROR_DETECTION=2. /* take a snapshot of the rwlock before it changes (we hope) */ /* avoid recursion deadlock */ "\n*** _THREAD_ERROR_DETECTION: lock usage error detected ***\n");
(
void)
strcat(
buf,
"\nthe writer lock owner is ");
(
void)
strcat(
buf,
"\nthe reader lock is held by ");
(
void)
strcat(
buf,
"\nand the lock appears to have waiters");
* Report a thread usage error. * Not called if _THREAD_ERROR_DETECTION=0. * Writes message and continues execution if _THREAD_ERROR_DETECTION=1. * Writes message and dumps core if _THREAD_ERROR_DETECTION=2. /* avoid recursion deadlock */ (
void)
strcpy(
buf,
"\n*** _THREAD_ERROR_DETECTION: " "thread usage error detected ***\n*** ");
(
void)
strcat(
buf,
"\n*** calling thread is ");
* We use __assfail() because the libc __assert() calls * gettext() which calls malloc() which grabs a mutex. * We do everything without calling standard i/o. * assfail() and _assfail() are exported functions; * __assfail() is private to libc. char buf[
800];
/* no assert() message in the library is this long */ /* avoid recursion deadlock */ (
void)
strcpy(
buf,
"assertion failed for thread ");
* We could replace the call to Abort() with the following code * if we want just to issue a warning message and not die. * _private_lwp_mutex_unlock(&assert_lock); * We define and export this version of assfail() just because libaio * used to define and export it, needlessly. Now that libaio is folded * into libc, we need to continue this for ABI/version reasons. * We don't use "#pragma weak assfail __assfail" in order to avoid * warnings from the check_fnames utility at build time for libraries * that define their own version of assfail().