View Issue Details

IDProjectCategoryView StatusLast Update
0004823ardourbugspublic2020-04-19 20:16
Reporterahurst Assigned Tocth103  
PrioritynormalSeveritymajorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.0-beta3 
Target Version3.0 
Summary0004823: Invalidated iterator used
DescriptionMedium impact static analysis bug:

An iterator is invalidated and then subsequently used at gtk2_ardour/tempo_lines.cc:242.

Need to keep a copy of next valid iterator before erasing current.
Additional Information*** "erase" invalidates iterator "steal".
233 _lines.erase(steal);
234 line->property_color_rgba() = color;
235 line->property_x1() = xpos;
236 line->property_x2() = xpos;
237 _lines.insert(make_pair(xpos, line));
238 inserted_last_time = true; // search next time
239 invalidated = true;
240
241 // Shift clean range right
*** Using invalid iterator "steal".
242 _clean_left = max(_clean_left, steal->first);
TagsNo tags attached.

Activities

epitech_user

2012-04-09 14:03

reporter   ~0013094

Last edited: 2012-04-09 14:09

I am not sure for this patch but it can be a solution.
Sorry for the name of the patch.

2012-04-09 14:06

 

bug4823 (735 bytes)   
Index: tempo_lines.cc
===================================================================
--- tempo_lines.cc	(révision 11787)
+++ tempo_lines.cc	(copie de travail)
@@ -229,6 +229,7 @@
 			//cout << "*** STEALING FROM LEFT" << endl;
 			assert(_lines.find(xpos) == _lines.end());
 			Lines::iterator steal = _lines.begin();
+			Lines::iterator save_steal = _lines.begin();
 			line = steal->second;
 			_lines.erase(steal);
 			line->property_color_rgba() = color;
@@ -239,8 +240,9 @@
 			invalidated = true;
 			
 			// Shift clean range right
-			_clean_left = max(_clean_left, steal->first);
+			_clean_left = max(_clean_left, save_steal->first);
 			_clean_right = max(_clean_right, xpos);
+			_lines.erase(save_steal);
 		}
 	}
 
bug4823 (735 bytes)   

2012-04-09 14:08

 

bug4823.patch (735 bytes)   
Index: tempo_lines.cc
===================================================================
--- tempo_lines.cc	(révision 11787)
+++ tempo_lines.cc	(copie de travail)
@@ -229,6 +229,7 @@
 			//cout << "*** STEALING FROM LEFT" << endl;
 			assert(_lines.find(xpos) == _lines.end());
 			Lines::iterator steal = _lines.begin();
+			Lines::iterator save_steal = _lines.begin();
 			line = steal->second;
 			_lines.erase(steal);
 			line->property_color_rgba() = color;
@@ -239,8 +240,9 @@
 			invalidated = true;
 			
 			// Shift clean range right
-			_clean_left = max(_clean_left, steal->first);
+			_clean_left = max(_clean_left, save_steal->first);
 			_clean_right = max(_clean_right, xpos);
+			_lines.erase(save_steal);
 		}
 	}
 
bug4823.patch (735 bytes)   

ahurst

2012-04-09 22:31

reporter   ~0013100

The element pointed to by "save_steal" will be erased when "steal" is erased.

2012-04-10 14:37

 

bug_4823_v2.patch (710 bytes)   
Index: gtk2_ardour/tempo_lines.cc
===================================================================
--- gtk2_ardour/tempo_lines.cc	(révision 11860)
+++ gtk2_ardour/tempo_lines.cc	(copie de travail)
@@ -230,6 +230,7 @@
 			//cout << "*** STEALING FROM LEFT" << endl;
 			assert(_lines.find(xpos) == _lines.end());
 			Lines::iterator steal = _lines.begin();
+			double		save = steal->first;
 			line = steal->second;
 			_lines.erase(steal);
 			line->property_color_rgba() = color;
@@ -240,7 +241,7 @@
 			invalidated = true;
 			
 			// Shift clean range right
-			_clean_left = max(_clean_left, steal->first);
+			_clean_left = max(_clean_left, save);
 			_clean_right = max(_clean_right, xpos);
 		}
 	}
bug_4823_v2.patch (710 bytes)   

epitech_user

2012-04-10 14:38

reporter   ~0013103

Certainly better like that :).

cth103

2012-04-11 10:08

administrator   ~0013108

Patch applied to SVN 11889, thanks!

system

2020-04-19 20:16

developer   ~0023032

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.

Issue History

Date Modified Username Field Change
2012-04-05 00:34 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 14:03 epitech_user Note Added: 0013094
2012-04-09 14:06 epitech_user File Added: bug4823
2012-04-09 14:08 epitech_user File Added: bug4823.patch
2012-04-09 14:09 epitech_user Note Edited: 0013094
2012-04-09 22:31 ahurst Note Added: 0013100
2012-04-10 14:37 epitech_user File Added: bug_4823_v2.patch
2012-04-10 14:38 epitech_user Note Added: 0013103
2012-04-11 10:08 cth103 Note Added: 0013108
2012-04-11 10:08 cth103 Status new => resolved
2012-04-11 10:08 cth103 Resolution open => fixed
2012-04-11 10:08 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: 0023032
2020-04-19 20:16 system Status resolved => closed