Fix: missing include can cause structures to not be packed
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Mar 2019 15:50:41 +0000 (11:50 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 29 Mar 2019 15:47:56 +0000 (11:47 -0400)
commitf79a92e2660c031e8ed4c209114dbd5e65095925
treec1de55cca52f31a13ac3140a98c6f032a85d75fc
parent33ea3a3ca3356ea35a2b85fd089e0e422e1d3d82
Fix: missing include can cause structures to not be packed

A number of files declaring "packed" structures (using the LTTNG_PACKED
macro) do not include common/macros.h, which defines this macro.

This results in structures being used in their "unpacked" form, or
under both packed and unpacked forms, depending on the other files
included at the point of definition and use of these structures.

It is unclear which of the users of these structures were actually
affected by the bug. Most of these structures are used for IPC
over a UNIX socket. In these cases, it is reasonable to assume that
lttng-tools will be rebuilt completely to take this change into
account.

However, the structures declared in common/sessiond-comm/relayd.h are
more worrying as they are part of the relay daemon's network protocol.

Fortunately, adding the following directive to
common/sessiond-comm/relayd.h confirms that the header is included
transitively where those structures are used.

> #ifndef LTTNG_PACKED
> #error Not defined!
> #endif

Instances of this issue were found using the following script.

for file in $(ag -l LTTNG_PACKED); do
    ag "#include \<common/macros\.h\>" -l ${file} > /dev/null
    if [ $? -ne 0 ]; then
       echo "Missing include in" $file
    fi
done

Running this script produces the following output (annotated):

Missing include in include/lttng/channel-internal.h
Missing include in include/lttng/condition/buffer-usage-internal.h
Missing include in include/lttng/condition/session-consumed-size-internal.h
Missing include in include/lttng/condition/session-rotation-internal.h
Missing include in src/common/sessiond-comm/sessiond-comm.h
Missing include in src/common/sessiond-comm/relayd.h
Missing include in src/common/sessiond-comm/agent.h

> LTTNG_PACKED mentioned in comments
Missing include in src/common/optional.h

> Unneeded.
Missing include in src/common/macros.h

> lttng-ust-abi.h defines its own version of LTTNG_PACKED
> and is included by lttng-ust-ctl.h
Missing include in src/bin/lttng-sessiond/lttng-ust-ctl.h
Missing include in src/bin/lttng-sessiond/lttng-ust-abi.h
Missing include in src/lib/lttng-ctl/filter/filter-bytecode.h

> False positives (not source files)
Missing include in packed.sh
Missing include in ChangeLog

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/channel-internal.h
include/lttng/condition/buffer-usage-internal.h
include/lttng/condition/session-consumed-size-internal.h
include/lttng/condition/session-rotation-internal.h
src/common/sessiond-comm/agent.h
src/common/sessiond-comm/relayd.h
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/filter/filter-bytecode.h
This page took 0.026568 seconds and 4 git commands to generate.