From 1b706ac02858aee4c960331dc7100f8c14312848 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Thu, 27 Oct 2011 11:48:58 +0200 Subject: Enable exceptions raising on assert on Win32 This patch changes the Win32 version to call RaiseException instead of abort (which eventually calls TerminateProcess). This allows crash dumps to be sent correctly instead of the process disappearing. Signed-off-by: Paul Betts --- src/err.hpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/err.hpp') diff --git a/src/err.hpp b/src/err.hpp index 9558a10..7c7a9d8 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -42,6 +42,7 @@ namespace zmq { const char *errno_to_string (int errno_); + void zmq_abort (const char *errmsg_); } #ifdef ZMQ_HAVE_WINDOWS @@ -51,7 +52,7 @@ namespace zmq const char *wsa_error (); const char *wsa_error_no (int no_); void win_error (char *buffer_, size_t buffer_size_); - void wsa_error_to_errno (); + void wsa_error_to_errno (); } // Provides convenient way to check WSA-style errors on Windows. @@ -62,7 +63,7 @@ namespace zmq if (errstr != NULL) {\ fprintf (stderr, "Assertion failed: %s (%s:%d)\n", errstr, \ __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort (errstr);\ }\ }\ } while (false) @@ -74,7 +75,7 @@ namespace zmq if (errstr != NULL) {\ fprintf (stderr, "Assertion failed: %s (%s:%d)\n", errstr, \ __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort (errstr);\ }\ } while (false) @@ -86,7 +87,7 @@ namespace zmq zmq::win_error (errstr, 256);\ fprintf (stderr, "Assertion failed: %s (%s:%d)\n", errstr, \ __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort (errstr);\ }\ } while (false) @@ -100,7 +101,7 @@ namespace zmq if (unlikely (!(x))) {\ fprintf (stderr, "Assertion failed: %s (%s:%d)\n", #x, \ __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort (#x);\ }\ } while (false) @@ -108,9 +109,9 @@ namespace zmq #define errno_assert(x) \ do {\ if (unlikely (!(x))) {\ - perror (NULL);\ - fprintf (stderr, "%s (%s:%d)\n", #x, __FILE__, __LINE__);\ - abort ();\ + const char *errstr = strerror (errno);\ + fprintf (stderr, "%s (%s:%d)\n", errstr, __FILE__, __LINE__);\ + zmq::zmq_abort (errstr);\ }\ } while (false) @@ -118,8 +119,9 @@ namespace zmq #define posix_assert(x) \ do {\ if (unlikely (x)) {\ - fprintf (stderr, "%s (%s:%d)\n", strerror (x), __FILE__, __LINE__);\ - abort ();\ + const char *errstr = strerror (x);\ + fprintf (stderr, "%s (%s:%d)\n", errstr, __FILE__, __LINE__);\ + zmq::zmq_abort (errstr);\ }\ } while (false) @@ -129,7 +131,7 @@ namespace zmq if (unlikely (x)) {\ const char *errstr = gai_strerror (x);\ fprintf (stderr, "%s (%s:%d)\n", errstr, __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort (errstr);\ }\ } while (false) @@ -139,7 +141,7 @@ namespace zmq if (unlikely (!x)) {\ fprintf (stderr, "FATAL ERROR: OUT OF MEMORY (%s:%d)\n",\ __FILE__, __LINE__);\ - abort ();\ + zmq::zmq_abort ("FATAL ERROR: OUT OF MEMORY");\ }\ } while (false) -- cgit v1.2.3 From ac7717b7b35f441fc3aeeb1528e63f147c00913a Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Mon, 31 Oct 2011 16:20:30 +0100 Subject: 250bpm copyrights added Signed-off-by: Martin Sustrik --- src/err.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/err.hpp') diff --git a/src/err.hpp b/src/err.hpp index 7c7a9d8..3a27dc4 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -1,4 +1,5 @@ /* + Copyright (c) 2009-2011 250bpm s.r.o. Copyright (c) 2007-2011 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file -- cgit v1.2.3 From 8e21d64c974344b5b2b83cac85d12c51392fe74b Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 1 Nov 2011 18:06:11 +0100 Subject: Copyright dates adjusted to reflect reality Signed-off-by: Martin Sustrik --- src/err.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/err.hpp') diff --git a/src/err.hpp b/src/err.hpp index 3a27dc4..53a6569 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -1,6 +1,6 @@ /* Copyright (c) 2009-2011 250bpm s.r.o. - Copyright (c) 2007-2011 iMatix Corporation + Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file This file is part of 0MQ. -- cgit v1.2.3