Project

General

Profile

Bug #18053 ยป 0001-Add-assertions-for-bad-backtrace-locations.patch

Patch with additional assertions - jhawthorn (John Hawthorn), 07/29/2021 11:08 PM

View differences:

vm_backtrace.c
191 191
	return calc_lineno(loc->body.iseq.iseq, loc->body.iseq.pc);
192 192
      case LOCATION_TYPE_CFUNC:
193 193
	if (loc->body.cfunc.prev_loc) {
194
	    return location_lineno(loc->body.cfunc.prev_loc);
195
	}
196
	return 0;
194
        VM_ASSERT(loc->body.cfunc.prev_loc != loc);
195
        return location_lineno(loc->body.cfunc.prev_loc);
196
    }
197
    return 0;
197 198
      default:
198
	rb_bug("location_lineno: unreachable");
199
	UNREACHABLE;
199
    rb_bug("location_lineno: unreachable");
200
    UNREACHABLE;
200 201
    }
201 202
}
202 203

  
......
294 295
	return rb_iseq_path(loc->body.iseq.iseq);
295 296
      case LOCATION_TYPE_CFUNC:
296 297
	if (loc->body.cfunc.prev_loc) {
298
        VM_ASSERT(loc->body.cfunc.prev_loc != loc);
297 299
	    return location_path(loc->body.cfunc.prev_loc);
298 300
	}
299 301
	return Qnil;
......
358 360
	return rb_iseq_realpath(loc->body.iseq.iseq);
359 361
      case LOCATION_TYPE_CFUNC:
360 362
	if (loc->body.cfunc.prev_loc) {
363
		VM_ASSERT(loc->body.cfunc.prev_loc != loc);
361 364
	    return location_realpath(loc->body.cfunc.prev_loc);
362 365
	}
363 366
	return Qnil;
......
411 414
	break;
412 415
      case LOCATION_TYPE_CFUNC:
413 416
	if (loc->body.cfunc.prev_loc) {
417
			  VM_ASSERT(loc->body.cfunc.prev_loc != loc);
414 418
	    file = rb_iseq_path(loc->body.cfunc.prev_loc->body.iseq.iseq);
415 419
	    lineno = location_lineno(loc->body.cfunc.prev_loc);
416 420
	}
......
764 768
    loc->type = LOCATION_TYPE_CFUNC;
765 769
    loc->body.cfunc.mid = mid;
766 770
    if (arg->prev_loc) {
771
		VM_ASSERT(loc != arg->prev_loc);
767 772
        loc->body.cfunc.prev_loc = arg->prev_loc;
768 773
    }
769 774
    else if (arg->prev_cfp) {
......
772 777
        arg->init_loc->type = LOCATION_TYPE_ISEQ;
773 778
        arg->init_loc->body.iseq.iseq = iseq;
774 779
        arg->init_loc->body.iseq.pc = pc;
780
		VM_ASSERT(loc != arg->init_loc);
775 781
        loc->body.cfunc.prev_loc = arg->prev_loc = arg->init_loc;
776 782
    }
777 783
    else {