Blame SOURCES/rsyslog-8.1911.0-rhbz1789675-serialize-crash-race.patch

94be23
From: Jiri Vymazal <jvymazal@redhat.com>
94be23
Date: Wed, 18 Dec 2019 09:48:15 +0100
94be23
Subject: [PATCH] Fix race condition related to libfastjson when using DA queue
94be23
94be23
Rsyslogd aborts when writing to disk queue from multiple workers simultaneously.
94be23
It is assumed that libfastjson is not thread-safe.
94be23
Resolve libfastjson race condition when writing to disk queue.
94be23
94be23
see also https://github.com/rsyslog/rsyslog/issues/4099
94be23
---
94be23
 runtime/msg.c | 4 ++++
94be23
 1 file changed, 4 insertions(+)
94be23
94be23
diff --git a/runtime/msg.c b/runtime/msg.c
94be23
index b5c17cfdd4..f9da40005f 100644
94be23
--- a/runtime/msg.c
94be23
+++ b/runtime/msg.c
94be23
@@ -1242,11 +1242,15 @@ static rsRetVal MsgSerialize(smsg_t *pThis, strm_t *pStrm)
94be23
 	psz = pThis->pszStrucData;
94be23
 	CHKiRet(obj.SerializeProp(pStrm, UCHAR_CONSTANT("pszStrucData"), PROPTYPE_PSZ, (void*) psz));
94be23
 	if(pThis->json != NULL) {
94be23
+		MsgLock(pThis);
94be23
 		psz = (uchar*) json_object_get_string(pThis->json);
94be23
+		MsgUnlock(pThis);
94be23
 		CHKiRet(obj.SerializeProp(pStrm, UCHAR_CONSTANT("json"), PROPTYPE_PSZ, (void*) psz));
94be23
 	}
94be23
 	if(pThis->localvars != NULL) {
94be23
+		MsgLock(pThis);
94be23
 		psz = (uchar*) json_object_get_string(pThis->localvars);
94be23
+		MsgUnlock(pThis);
94be23
 		CHKiRet(obj.SerializeProp(pStrm, UCHAR_CONSTANT("localvars"), PROPTYPE_PSZ, (void*) psz));
94be23
 	}
94be23