From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 7D19C4765E2 for ; Wed, 30 Dec 2020 01:23:52 +0300 (MSK) From: Sergey Kaplun Date: Wed, 30 Dec 2020 01:22:58 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 3/3] core: remove excess assertion inside memprof List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich , Igor Munkin Cc: tarantool-patches@dev.tarantool.org lj_debug_frameline() may return -1 for Lua functions on top. In this case assertion inside memprof_write_lfunc() that returned line is not negative is incorrect. This patch removes this assertion. For negative returned line value profiler is reported zero frameline. Follows up tarantool/tarantool#5442 --- I have not thought of any more correct check than: | -- Check alocations for Lua function on top. | -- This is not the best test case but the most simple. | -- Trace allocation on top leads to assertion. | jit.on() | for _ = 1, 100 do | local _ = tostring(_) | end | jit.off() | jit.flush() But this is not very fair: here we have tail call to cpcall() (with trace_state() as an argument) without creating a new guest stack frame. Also test looks redundant -- assertion obviously can't fail as far as it doesn't exist. But I can add this test case if you want. src/lj_memprof.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lj_memprof.c b/src/lj_memprof.c index c4d2645..0568049 100644 --- a/src/lj_memprof.c +++ b/src/lj_memprof.c @@ -90,15 +90,15 @@ static void memprof_write_lfunc(struct lj_wbuf *out, uint8_t aevent, cTValue *nextframe) { const BCLine line = lj_debug_frameline(L, fn, nextframe); + lj_wbuf_addbyte(out, aevent | ASOURCE_LFUNC); + lj_wbuf_addu64(out, (uintptr_t)funcproto(fn)); /* - ** Line is always >= 0 if we are inside a Lua function. + ** Line is >= 0 if we are inside a Lua function. + ** An exception may be when the Lua function is on top. ** Equals to zero when LuaJIT is built with the ** -DLUAJIT_DISABLE_DEBUGINFO flag. */ - lua_assert(line >= 0); - lj_wbuf_addbyte(out, aevent | ASOURCE_LFUNC); - lj_wbuf_addu64(out, (uintptr_t)funcproto(fn)); - lj_wbuf_addu64(out, (uint64_t)line); + lj_wbuf_addu64(out, line >= 0 ? (uint64_t)line : 0); } static void memprof_write_cfunc(struct lj_wbuf *out, uint8_t aevent, -- 2.28.0