KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sch_rule_area_destruction.cpp File Reference

Regression test for issue 22822: crash when closing eeschema while background library loading is in progress. More...

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (RuleAreaDestroyedBeforeContainedItems)
 Verify that destroying a rule area before its contained items does not crash.
 
 BOOST_AUTO_TEST_CASE (ContainedItemsDestroyedBeforeRuleArea)
 Verify that destroying contained items before the rule area also works.
 

Detailed Description

Regression test for issue 22822: crash when closing eeschema while background library loading is in progress.

The crash occurs in SCH_RULE_AREA::RemoveItem() because FreeDrawList() deletes items in arbitrary order. If a rule area is destroyed before items it contains, those items' destructors call RemoveItem() on freed memory.

Definition in file test_sch_rule_area_destruction.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( ContainedItemsDestroyedBeforeRuleArea )

Verify that destroying contained items before the rule area also works.

The reverse ordering should also be safe since SCH_ITEM::~SCH_ITEM calls RemoveItem on still-valid rule areas.

Definition at line 81 of file test_sch_rule_area_destruction.cpp.

References BOOST_CHECK_EQUAL(), and LAYER_WIRE.

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( RuleAreaDestroyedBeforeContainedItems )

Verify that destroying a rule area before its contained items does not crash.

This reproduces the exact destruction ordering that caused the issue 22822 segfault in FreeDrawList().

Definition at line 46 of file test_sch_rule_area_destruction.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), and LAYER_WIRE.