Fix: sessiond: crash when sending data_pending to an active session
authorKienan Stewart <kstewart@efficios.com>
Thu, 13 Jul 2023 19:13:12 +0000 (15:13 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Nov 2023 21:38:53 +0000 (16:38 -0500)
commitf0a9c004f8ee3766394e8764da85dd56f2bf5dd4
tree64544acb02d108021e70f52e8074257774da5618
parent8d82bb77bfe9cee42f8b409c5e65f9ae4c218894
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 <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iff46f87c7725d25c131a86ac3dbaed5c99b4d16b
.gitignore
configure.ac
src/bin/lttng-sessiond/client.cpp
tests/regression/tools/client/test_bug1480_assert_data_pending [new file with mode: 0755]
tests/utils/testapp/Makefile.am
tests/utils/testapp/gen-data-pending/Makefile.am [new file with mode: 0644]
tests/utils/testapp/gen-data-pending/main.cpp [new file with mode: 0644]
This page took 0.026876 seconds and 4 git commands to generate.