From: Kienan Stewart Date: Thu, 13 Jul 2023 19:13:12 +0000 (-0400) Subject: Fix: sessiond: crash when sending data_pending to an active session X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=f0a9c004f8ee3766394e8764da85dd56f2bf5dd4;hp=f0a9c004f8ee3766394e8764da85dd56f2bf5dd4;p=lttng-tools.git Fix: sessiond: crash when sending data_pending to an active session Observed Issue ============== When a data_pending command is sent to an active session, the sessiond crashes with the following assert ``` lttng-sessiond: client.cpp:2647: void* thread_manage_clients(void*): Assertion `cmd_ctx.reply_payload.buffer.size >= sizeof(*llm)' failed. Error: 1 trace chunks are leaked by lttng-consumerd. This can be caused by an internal error of the session daemon. ``` Cause ===== When a session is active, cmd.cpp:cmd_data_pending() returns LTTNG_ERR_SESSION_STARTED. In client.cpp:process_client_msg(), this return value causes the execution to go the the setup_error label. In the setup_error label, no default LLM header is added to the reply, meaning the reply has a zero size and triggering the assert above. Solution ======== When cmd_data_pending() returns a value that is neither 0 nor 1, the return code is set appropriately as follows: * when the return value is outside the range of lttng error codes, LTTNG_ERR_UNK is used * otherwise, the return value is used The execution then jumps to the error label so that the default LLM message header can be added. Known Drawbacks =============== None. Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau Change-Id: Iff46f87c7725d25c131a86ac3dbaed5c99b4d16b ---