View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004822 | ardour | bugs | public | 2012-04-05 00:30 | 2020-04-19 20:16 |
Reporter | ahurst | Assigned To | cth103 | ||
Priority | normal | Severity | major | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 3.0-beta3 | ||||
Target Version | 3.0 | ||||
Summary | 0004822: Invalidated iterator used | ||||
Description | Medium impact static analysis bug: An iterator is invalidated and then subsequently used at libs/ardour/region_factory:623. Need to keep a copy of next valid iterator before erasing current. | ||||
Additional Information | 618void 619RegionFactory::remove_regions_using_source (boost::shared_ptr<Source> src) 620{ 621 Glib::Mutex::Lock lm (region_map_lock); 622 *** Using invalid iterator "i" (on repeating the loop after the events below). 623 for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) { *** Condition "i->second->uses_source(boost::shared_ptr<ARDOUR::Source const>(src, boost::detail::sp_empty({})))", taking true branch 624 if (i->second->uses_source (src)) { *** "erase" invalidates iterator "i". 625 region_map.erase (i); 626 } *** Jumping back to the beginning of the loop 627 } 628} | ||||
Tags | No tags attached. | ||||
2012-04-09 15:11
|
bug_4822 (609 bytes)
Index: libs/ardour/region_factory.cc =================================================================== --- libs/ardour/region_factory.cc (revision 11846) +++ libs/ardour/region_factory.cc (working copy) @@ -619,10 +619,13 @@ RegionFactory::remove_regions_using_source (boost::shared_ptr<Source> src) { Glib::Mutex::Lock lm (region_map_lock); + RegionMap::iterator save; for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) { + save = region_map.upper_bound(i->first); if (i->second->uses_source (src)) { region_map.erase (i); + i = save; } } } |
|
Here is a patch, but i'm not sure of the correction! |
|
Yeah, these are tricky. Two things: you need to increment before erase, so that save doesn't also point to the erased element. Also, the increment inside the for statement mustn't applied to the end() element. A compact solution: Index: libs/ardour/region_factory.cc =================================================================== --- libs/ardour/region_factory.cc (revision 11846) +++ libs/ardour/region_factory.cc (working copy) @@ -619,10 +619,13 @@ RegionFactory::remove_regions_using_source (boost::shared_ptr<Source> src) { Glib::Mutex::Lock lm (region_map_lock); - for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) { + RegionMap::iterator i = region_map.begin(); + while(i != region_map.end()) { if (i->second->uses_source (src)) { - region_map.erase(i); + region_map.erase(i++); + } else { + ++i; } } } |
|
Fixed in SVN 11893. |
|
Issue has been closed automatically, by Trigger Close Plugin. Feel free to re-open with additional information if you think the issue is not resolved. |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-04-05 00:30 | ahurst | New Issue | |
2012-04-05 01:05 | cth103 | cost | => 0.00 |
2012-04-05 01:05 | cth103 | Target Version | => 3.0 beta4 |
2012-04-09 15:11 | epitech_user | File Added: bug_4822 | |
2012-04-09 15:11 | epitech_user | Note Added: 0013096 | |
2012-04-09 22:27 | ahurst | Note Added: 0013098 | |
2012-04-11 10:43 | cth103 | Note Added: 0013111 | |
2012-04-11 10:43 | cth103 | Status | new => resolved |
2012-04-11 10:43 | cth103 | Resolution | open => fixed |
2012-04-11 10:43 | cth103 | Assigned To | => cth103 |
2012-05-23 15:08 | cth103 | Target Version | 3.0 beta4 => 3.0 |
2020-04-19 20:16 | system | Note Added: 0023031 | |
2020-04-19 20:16 | system | Status | resolved => closed |