ruby-changes:51262
From: yui-knk <ko1@a...>
Date: Sat, 19 May 2018 12:43:06 +0900 (JST)
Subject: [ruby-changes:51262] yui-knk:r63468 (trunk): iseq.c: Fix segfault when debug is not 0
yui-knk 2018-05-19 12:43:00 +0900 (Sat, 19 May 2018) New Revision: 63468 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63468 Log: iseq.c: Fix segfault when debug is not 0 * iseq.c (get_insn_info_succinct_bitvector): If VM_CHECK_MODE is 0, `body->insns_info.positions` is freed in `rb_iseq_insns_info_encode_positions`. Print `position` only when VM_CHECK_MODE is set. Modified files: trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 63467) +++ iseq.c (revision 63468) @@ -1503,13 +1503,19 @@ get_insn_info_succinct_bitvector(const r https://github.com/ruby/ruby/blob/trunk/iseq.c#L1503 const struct rb_iseq_constant_body *const body = iseq->body; size_t size = body->insns_info.size; const struct iseq_insn_info_entry *insns_info = body->insns_info.body; - const unsigned int *positions = body->insns_info.positions; const int debug = 0; if (debug) { - printf("size: %"PRIuSIZE"\n", size); - printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n", - (size_t)0, positions[0], insns_info[0].line_no, pos); +#if VM_CHECK_MODE > 0 + const unsigned int *positions = body->insns_info.positions; + printf("size: %"PRIuSIZE"\n", size); + printf("insns_info[%"PRIuSIZE"]: position: %d, line: %d, pos: %"PRIuSIZE"\n", + (size_t)0, positions[0], insns_info[0].line_no, pos); +#else + printf("size: %"PRIuSIZE"\n", size); + printf("insns_info[%"PRIuSIZE"]: line: %d, pos: %"PRIuSIZE"\n", + (size_t)0, insns_info[0].line_no, pos); +#endif } if (size == 0) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/