Skip to content

Fix test-char reference counting bug

Eduardo Habkost qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2test-char: Destroy chardev correctly at char_file_test_internal()tests/test-char.c+1 -12 replies
2/2qom: Assert that objects being destroyed have no parentqom/object.c+1 -05 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchMarc-André LureauAlex Bennée
1/2R-b R-b T-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] Fix test-char reference counting bug

This series addresses a bug that seems to be the cause of the following crash, that is reported by Patchew and other CI systems once in a while:

Running test test-char
Unexpected error in object_property_try_add() at ../qom/object.c:1220: attempt to add duplicate property 'serial-id' to object (type 'container') ERROR test-char - too few tests run (expected 38, got 9)
make: *** [run-test-86] Error 1

This is what seems to be happening:

- char_file_test_internal() creates chr using qemu_chardev_new().
- qemu_chardev_new() automatically assigns ID, adds chardev to the QOM tree.
- char_file_test_internal() does _not_ own the reference to the created object.
- char_file_test_internal() incorrectly calls object_unref().
- object is freed but, but /containers now has a dangling pointer.
- char_serial_test() creates a chardev with ID "serial-id", and it ends up being allocated at the same address as the old object.
- char_serial_test() correctly calls object_unparent().
- object_property_del_child() looks for the right child property in the hashtable, finds the dangling pointer with the same address, removes the wrong property, leaves a dangling "serial-id" property.
- New object is created by char_serial_test() with ID "serial-id".
- object_property_try_add_child() will fail because of the dangling "serial-id" property.

Eduardo Habkost (2):
test-char: Destroy chardev correctly at char_file_test_internal()
qom: Assert that objects being destroyed have no parent

 qom/object.c      | 1 +
 tests/test-char.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.28.0