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

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