mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
always use our own internal assertion message symbol
Re-using glibc's __abort_msg symbol causes linking problems, since the symbol is declared private. Always use our own__glib_abort_msg symbol to store assertion messages, to avoid compatibility and linking problems. Also fix the test case to work with out of tree builds (such as "make distcheck"), and re-enable it. https://bugzilla.gnome.org/show_bug.cgi?id=594872
This commit is contained in:
parent
e84a3f8248
commit
3658727cfa
14
configure.in
14
configure.in
@ -2704,20 +2704,6 @@ int error = EILSEQ;
|
||||
], have_eilseq=yes, have_eilseq=no);
|
||||
AC_MSG_RESULT($have_eilseq)
|
||||
|
||||
dnl **********************************************************************
|
||||
dnl *** Check whether glibc has global variable for assertion messages ***
|
||||
dnl **********************************************************************
|
||||
|
||||
AC_MSG_CHECKING(if libc has __abort_msg)
|
||||
AC_LINK_IFELSE([
|
||||
extern char *__abort_msg;
|
||||
int main() { return __abort_msg == (char*) 0; }
|
||||
], [libc_has_abort_msg=yes], [libc_has_abort_msg=no])
|
||||
AC_MSG_RESULT($libc_has_abort_msg)
|
||||
if test "$libc_has_abort_msg" = "yes"; then
|
||||
AC_DEFINE(HAVE_LIBC_ABORT_MSG,1,[Whether libc defines __abort_msg])
|
||||
fi
|
||||
|
||||
dnl ******************************************************************
|
||||
dnl *** Look for glib-genmarshal in PATH if we are cross-compiling ***
|
||||
dnl ******************************************************************
|
||||
|
@ -41,18 +41,11 @@
|
||||
#include <sys/select.h>
|
||||
#endif /* HAVE_SYS_SELECT_H */
|
||||
|
||||
/* if we have a recent enough glibc, use its __abort_msg variable for storing
|
||||
* assertion messages (just like assert()). If not, declare our own variable,
|
||||
* so that platforms with older glibc or different libc implementations can use
|
||||
* this feature for debugging as well.
|
||||
*/
|
||||
#ifdef HAVE_LIBC_ABORT_MSG
|
||||
extern char *__abort_msg;
|
||||
#define ASSERT_MESSAGE_STORE __abort_msg
|
||||
#else
|
||||
/* Global variable for storing assertion messages; this is the counterpart to
|
||||
* glibc's (private) __abort_msg variable, and allows developers and crash
|
||||
* analysis systems like Apport and ABRT to fish out assertion messages from
|
||||
* core dumps, instead of having to catch them on screen output. */
|
||||
char *__glib_assert_msg = NULL;
|
||||
#define ASSERT_MESSAGE_STORE __glib_assert_msg
|
||||
#endif
|
||||
|
||||
/* --- structures --- */
|
||||
struct GTestCase
|
||||
@ -1312,13 +1305,12 @@ g_assertion_message (const char *domain,
|
||||
g_printerr ("**\n%s\n", s);
|
||||
|
||||
/* store assertion message in global variable, so that it can be found in a
|
||||
* core dump; also, use standard C allocation here for compatiblity with
|
||||
* glibc's __abort_msg variable */
|
||||
if (ASSERT_MESSAGE_STORE != NULL)
|
||||
* core dump */
|
||||
if (__glib_assert_msg != NULL)
|
||||
/* free the old one */
|
||||
free (ASSERT_MESSAGE_STORE);
|
||||
ASSERT_MESSAGE_STORE = (char*) malloc (strlen (s) + 1);
|
||||
strcpy (ASSERT_MESSAGE_STORE, s);
|
||||
free (__glib_assert_msg);
|
||||
__glib_assert_msg = (char*) malloc (strlen (s) + 1);
|
||||
strcpy (__glib_assert_msg, s);
|
||||
|
||||
g_test_log (G_TEST_LOG_ERROR, s, NULL, 0, NULL);
|
||||
g_free (s);
|
||||
|
@ -138,7 +138,7 @@ test_programs = \
|
||||
uri-test \
|
||||
regex-test
|
||||
|
||||
test_scripts = run-markup-tests.sh run-collate-tests.sh run-bookmark-test.sh
|
||||
test_scripts = run-markup-tests.sh run-collate-tests.sh run-bookmark-test.sh run-assert-msg-test.sh
|
||||
|
||||
test_script_support_programs = markup-test unicode-collate bookmarkfile-test
|
||||
|
||||
|
@ -21,7 +21,7 @@ fi
|
||||
|
||||
echo_v "Running assert-msg-test"
|
||||
OUT=$(./assert-msg-test 2>&1) && fail "assert-msg-test should abort"
|
||||
echo "$OUT" | grep -q '^ERROR:assert-msg-test.c:.*:main: assertion failed: (42 < 0)' || \
|
||||
echo "$OUT" | grep -q '^ERROR:.*assert-msg-test.c:.*:main: assertion failed: (42 < 0)' || \
|
||||
fail "does not print assertion message"
|
||||
|
||||
if ! type gdb >/dev/null 2>&1; then
|
||||
@ -29,20 +29,13 @@ if ! type gdb >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# do we use libc's or our own variable?
|
||||
if grep -q '^#define HAVE_LIBC_ABORT_MSG' $(dirname $0)/../config.h; then
|
||||
VAR=__abort_msg
|
||||
else
|
||||
VAR=__glib_assert_msg
|
||||
fi
|
||||
|
||||
echo_v "Running gdb on assert-msg-test"
|
||||
OUT=$(gdb --batch --ex run --ex "print (char*) $VAR" .libs/lt-assert-msg-test 2> $error_out) || \
|
||||
OUT=$(gdb --batch --ex run --ex "print (char*) __glib_assert_msg" .libs/lt-assert-msg-test 2> $error_out) || \
|
||||
fail "failed to run gdb"
|
||||
|
||||
echo_v "Checking if assert message is in $VAR"
|
||||
if ! echo "$OUT" | grep -q '^$1.*"ERROR:assert-msg-test.c:.*:main: assertion failed: (42 < 0)"'; then
|
||||
fail "$VAR does not have assertion message"
|
||||
echo_v "Checking if assert message is in __glib_assert_msg"
|
||||
if ! echo "$OUT" | grep -q '^$1.*"ERROR:.*assert-msg-test.c:.*:main: assertion failed: (42 < 0)"'; then
|
||||
fail "__glib_assert_msg does not have assertion message"
|
||||
fi
|
||||
|
||||
echo_v "All tests passed."
|
||||
|
Loading…
x
Reference in New Issue
Block a user