Project

General

Profile

Bug #2493 ยป rubygc.patch

barryboes (Barry Boes), 12/19/2009 01:24 AM

View differences:

../ruby-svn/ruby_1_8_7/gc.c 2009-12-17 12:05:07.581225431 -0600
1359 1359
	break;			/* no need to free iv_tbl */
1360 1360

  
1361
  /* BAB change for case T_SCOPE --
1362
 don't free anything that's not SCOPE_MALLOC.  I'm not certain this is
1363
 correct, but a thread context switch allocated info that was
1364
 SCOPE_DONT_RECYCLE but not SCOPE_MALLOC, and freeing it caused a
1365
 double free problem.  The original allocation was here :
1366
  rb_thread_start_0
1367
  blk_copy_prev
1368
  frame_dup
1369

  
1370
I think that a later copy had SCOPE_DONT_RECYCLE w/o SCOPE_MALLOC, which I'm taking to
1371
mean that it shouldn't be freed.  I don't understand everything, but I
1372
checked and SCOPE_MALLOC is almost always set when calling into here
1373
so not freeing w/o SCOPE_MALLOC should be liveable (at least for us)
1374

  
1375
*/
1376 1361
      case T_SCOPE:
1377 1362
	if (RANY(obj)->as.scope.local_vars &&
1378
            (RANY(obj)->as.scope.flags & SCOPE_MALLOC))  {
1379
	    if(!(RANY(obj)->as.scope.flags & SCOPE_CLONE)) {
1380
	      VALUE *vars = RANY(obj)->as.scope.local_vars-1;
1381
	      if(vars[0] == 0) {
1363
            RANY(obj)->as.scope.flags != SCOPE_ALLOCA) {
1364
	    VALUE *vars = RANY(obj)->as.scope.local_vars-1;
1365
	    if (!(RANY(obj)->as.scope.flags & SCOPE_CLONE) && vars[0] == 0)
1382 1366
		RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl));
1383
	      }
1384
	      RUBY_CRITICAL(free(vars));
1385
	    }
1367
	    if ((RANY(obj)->as.scope.flags & (SCOPE_MALLOC|SCOPE_CLONE)) == SCOPE_MALLOC)
1368
		RUBY_CRITICAL(free(vars));
1386 1369
	}
1387 1370
	break;