[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Oops! Bugfix to my bugfix.



Hi again-

Looks like I jumped the gun with the Vegas patch; it can actually cause a seg
fault itself. If ack packets for a TCP agent are still on the wire and reset()
is called, my patch deletes the memory allocated to v_sendtime_ and
v_transmits_. If another output() call is not made before the packets arrive
here, the memory is not re-allocated and when recv() accesses the variables, seg
fault.

It shouldn't happen (I shouldn't have been re-using agents while there were acks
on the wire for the prior incarnation, bug in my scripts) but it may cause
improper access under other conditions.

The fix is to move the deletes I added to reset() to just before the
reallocation in output(). Then under no conditions will we have null variables
which might get accessed.


Here's the patch from CVS version (with my first patch applied) to a correct
version.

----------------------------------Begin patch-----------------------------------
--- tcp-vegas.cc.orig	Tue Oct 31 15:26:23 2000
+++ tcp-vegas.cc	Tue Oct 31 15:27:26 2000
@@ -110,15 +110,6 @@
 	v_incr_ = 0;
 	v_inc_flag_ = 1;
 
-	if (v_sendtime_) {
-		delete []v_sendtime_;
-                v_sendtime_ = NULL;
-        }
-        if (v_transmits_) {
-                delete []v_transmits_;
-                v_transmits_ = NULL;
-        }
-
 	TcpAgent::reset();
 }
 
@@ -440,6 +431,12 @@
 	 * cases which windows get set by each different tcp flows */
 	if (seqno==0) {
 		v_maxwnd_ = int(wnd_);
+		if (v_sendtime_)
+			delete []v_sendtime_;
+		if (v_transmits_)
+			delete []v_transmits_;
+
 		v_sendtime_ = new double[v_maxwnd_];
 		v_transmits_ = new int[v_maxwnd_];
 		for(int i=0;i<v_maxwnd_;i++) {
-----------------------------------End patch------------------------------------

Sorry for the trouble!
-Eric

--------------------------------------------
 Eric H. Weigle   CCS-1, RADIANT team
 [email protected]     Los Alamos National Lab
 (505) 665-4937   http://home.lanl.gov/ehw/
--------------------------------------------