[PATCH uci] uci: decrease the n_section when section is freed

Leon Busch-George leon at georgemail.eu
Thu Sep 14 14:36:10 PDT 2023

Hi Jan,

On Thu,  7 Sep 2023 18:12:56 +0200
Jan Venekamp <jan at venekamp.net> wrote:

> Could you provided a example / test case for this behaviour?

Before finding and applying Jeff's patch I had written a small test application that creates a few random sections in the 'dhcp' UCI package and deletes them again (uci_set).
Afterwards, it iterates all packages (uci_list_configs), prints a line if there is a delta (ptr.p->has_delta), and calls uci_save.
Basically, there were erroneous 'has_delta' entries for all packages.
It was set up like that because, at the time, I thought the problem had to do with packages.

If enough sections were created and deleted, I would reliably segfault when iterating sections (e.g. uci_foreach_element_safe(&u_ptr.p->sections, tmp, e)).
That is how I discovered the bug.

Here's the output I had saved for a submission to this mailing list:

[root at wpj428 ~] $ /tmp/delta-test 20 # <- the amount of sections to be created and deleted
has delta: dhcp
has delta: dropbear
has delta: fastd
has delta: fstab
has delta: network
has delta: radius
has delta: system
has delta: ubootenv
has delta: wireless
[root at wpj428 ~] $ uci changes | grep fastd
[root at wpj428 ~] $ uci changes ubootenv
[root at wpj428 ~] $ 

I abandonded and deleted the test app and the report since, at least to me, Jeff's patch appears to be a valid solution.
If you want, I could recreate it. Let me know!

kind regards,

More information about the openwrt-devel mailing list