qemu-e2k/qom
Michael S. Tsirkin e36828787f qom: assert integer does not overflow
QOM reference counting is not designed with an infinite amount of
references in mind, trying to take a reference in a loop without
dropping a reference will overflow the integer.

It is generally a symptom of a reference leak (a missing deref, commonly
as part of error handling - such as one fixed here:
https://lore.kernel.org/r/20220228095058.27899-1-sgarzare%40redhat.com ).

All this can lead to either freeing the object too early (memory
corruption) or never freeing it (memory leak).

If we happen to dereference at just the right time (when it's wrapping
around to 0), we might eventually assert when dereferencing, but the
real problem is an extra object_ref so let's assert there to make such
issues cleaner and easier to debug.

Some micro-benchmarking shows using fetch and add this is essentially
free on x86.

Since multiple threads could be incrementing in parallel, we assert
around INT_MAX to make sure none of these approach the wrap around
point: this way we get a memory leak and not a memory corruption, the
former is generally easier to debug.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-03-04 05:40:58 -05:00
..
container.c qom/container: remove .instance_size initializer from container_info 2020-06-10 12:09:59 -04:00
meson.build qom: Move the creation of the library to the main meson.build 2020-10-12 11:50:20 -04:00
object.c qom: assert integer does not overflow 2022-03-04 05:40:58 -05:00
object_interfaces.c qom: Reduce use of error_propagate() 2021-10-15 16:06:11 +02:00
qom-hmp-cmds.c qobject: Change qobject_to_json()'s value to GString 2020-12-19 10:38:43 +01:00
qom-qmp-cmds.c qom: Factor out user_creatable_process_cmdline() 2021-03-19 10:17:14 +01:00
qom-qobject.c error: Eliminate error_propagate() manually 2020-07-10 15:18:08 +02:00
trace-events docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00