On 11/27/17 20:39, Jiří Činčura wrote:
I've reproduced an issue. Somewhere between catching error in looper and
rethrowing it again when leaving looper tdbb_status_vector is cleaned
Great to know, you found it.


Jiří, can you try with this patch? I'm 99% sure it will help you to but if you can check it will be great.


diff --git a/src/jrd/CryptoManager.cpp b/src/jrd/CryptoManager.cpp
index 7aaca51d78..2e37752cf6 100644
--- a/src/jrd/CryptoManager.cpp
+++ b/src/jrd/CryptoManager.cpp
@@ -1047,10 +1047,14 @@ namespace Jrd {
 				return FAILED_CRYPT;
 			}
 
-			cryptPlugin->decrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag),
+			FbLocalStatus ls;
+			cryptPlugin->decrypt(&ls, dbb.dbb_page_size - sizeof(Ods::pag),
 				&page[1], &page[1]);
 			if (sv->getState() & IStatus::STATE_ERRORS)
+			{
+				ERR_post_nothrow(&ls, sv);
 				return FAILED_CRYPT;
+			}
 		}
 
 		return SUCCESS_ALL;
@@ -1132,11 +1136,15 @@ namespace Jrd {
 				return FAILED_CRYPT;
 			}
 
+			FbLocalStatus ls;
 			to[0] = page[0];
-			cryptPlugin->encrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag),
+			cryptPlugin->encrypt(&ls, dbb.dbb_page_size - sizeof(Ods::pag),
 				&page[1], &to[1]);
 			if (sv->getState() & IStatus::STATE_ERRORS)
+			{
+				ERR_post_nothrow(&ls, sv);
 				return FAILED_CRYPT;
+			}
 
 			to->pag_flags |= Ods::crypted_page;		// Mark page that is going to be written as encrypted
 			page->pag_flags |= Ods::crypted_page;	// Set the mark for page in cache as well
diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp
index 0f428ac2d4..4c6291bcf7 100644
--- a/src/jrd/err.cpp
+++ b/src/jrd/err.cpp
@@ -55,6 +55,7 @@ using namespace Firebird;
 
 
 static void internal_error(ISC_STATUS status, int number, const TEXT* file = NULL, int line = 0);
+static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector);
 
 
 void ERR_bugcheck(int number, const TEXT* file, int line)
@@ -204,14 +205,45 @@ void ERR_post_nothrow(const Arg::StatusVector& v, FbStatusVector* statusVector)
  *
  **************************************/
 {
-	// calculate length of the status
-	unsigned lenToAdd = v.length();
+	post_nothrow(v.length(), v.value(), statusVector);
+}
+
+
+void ERR_post_nothrow(const IStatus* v, FbStatusVector* statusVector)
+/**************************************
+ *
+ *	E R R _ p o s t _ n o t h r o w
+ *
+ **************************************
+ *
+ * Functional description
+ *	Populate a status vector.
+ *
+ **************************************/
+{
+	const ISC_STATUS* toAdd = v->getErrors();
+	post_nothrow(fb_utils::statusLength(toAdd), toAdd, statusVector);
+}
+
+
+static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector)
+/**************************************
+ *
+ *	E R R _ p o s t _ n o t h r o w
+ *
+ **************************************
+ *
+ * Functional description
+ *	Populate a status vector.
+ *
+ **************************************/
+{
+	// check status to add
 	if (lenToAdd == 0)	// nothing to do
 		return;
-	const ISC_STATUS* toAdd = v.value();
     fb_assert(toAdd[0] == isc_arg_gds);
 
-	// Use default from tdbb when no vector specified
+	// use default from tdbb when no vector specified
 	if (!statusVector)
 		statusVector = JRD_get_thread_data()->tdbb_status_vector;
 
diff --git a/src/jrd/err_proto.h b/src/jrd/err_proto.h
index c5964b6592..7ee27bb3bd 100644
--- a/src/jrd/err_proto.h
+++ b/src/jrd/err_proto.h
@@ -54,6 +54,7 @@ void	ERR_corrupt(int);
 void	ERR_error(int);
 void	ERR_post(const Firebird::Arg::StatusVector& v);
 void	ERR_post_nothrow(const Firebird::Arg::StatusVector& v, Jrd::FbStatusVector* statusVector = NULL);
+void	ERR_post_nothrow(const Firebird::IStatus* v, Jrd::FbStatusVector* statusVector = NULL);
 void	ERR_punt();
 void	ERR_warning(const Firebird::Arg::StatusVector& v);
 void	ERR_log(int, int, const TEXT*);
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to