Blame SOURCES/rsyslog-8.24.0-rhbz1778841-serialize-crash-race.patch

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