summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 02:44:36 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 02:44:36 +0000
commit2e24a66b883b7f14d9dd0aeffa749d68dd5d6939 (patch)
treeacc092cd4b620f77c355b13f06f6f510604e79b9 /iseq.c
parentfb6db414a199a6d2e43952413823198b69b6d1e3 (diff)
iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]
Before this change, coverage.so had failed to measure some multiple-line code fragments. This is because removing trace instructions (#14104) changed TracePoint's lineno (new lineno), and coverage counter array was based on old lineno. This change initializes coverage counter array based on new lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index 186f8622e7..f0239ccde1 100644
--- a/iseq.c
+++ b/iseq.c
@@ -350,9 +350,21 @@ finish_iseq_build(rb_iseq_t *iseq)
{
struct iseq_compile_data *data = ISEQ_COMPILE_DATA(iseq);
VALUE err = data->err_info;
+ unsigned int i;
ISEQ_COMPILE_DATA_CLEAR(iseq);
compile_data_free(data);
+ if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
+ for (i = 0; i < iseq->body->insns_info_size; i++) {
+ if (iseq->body->insns_info[i].events & RUBY_EVENT_LINE) {
+ int line_no = iseq->body->insns_info[i].line_no - 1;
+ if (0 <= line_no && line_no < RARRAY_LEN(ISEQ_LINE_COVERAGE(iseq))) {
+ RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), line_no, INT2FIX(0));
+ }
+ }
+ }
+ }
+
if (RTEST(err)) {
VALUE path = pathobj_path(iseq->body->location.pathobj);
if (err == Qtrue) err = rb_exc_new_cstr(rb_eSyntaxError, "compile error");