Skip to content

Commit c0c2e62

Browse files
Buristanigormunkin
authored andcommitted
core: remove excess assertion inside memprof
There are cases when the memory profiler attempts to attribute allocations triggered by JIT engine recording phase with a Lua function to be recorded. At this case lj_debug_frameline() may return BC_NOPOS (i.e. a negative value) so the assertion in the Lua writer memprof_write_lfunc() is violated. This patch removes this assertion. For negative returned line value profiler is reported zero frameline. Follows up tarantool/tarantool#5442 Reviewed-by: Igor Munkin <[email protected]> Reviewed-by: Sergey Ostanevich <[email protected]> Signed-off-by: Igor Munkin <[email protected]>
1 parent 2174958 commit c0c2e62

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lj_memprof.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ static void memprof_write_lfunc(struct lj_wbuf *out, uint8_t aevent,
9090
cTValue *nextframe)
9191
{
9292
const BCLine line = lj_debug_frameline(L, fn, nextframe);
93+
lj_wbuf_addbyte(out, aevent | ASOURCE_LFUNC);
94+
lj_wbuf_addu64(out, (uintptr_t)funcproto(fn));
9395
/*
94-
** Line is always >= 0 if we are inside a Lua function.
96+
** Line is >= 0 if we are inside a Lua function.
97+
** There are cases when the memory profiler attempts
98+
** to attribute allocations triggered by JIT engine recording
99+
** phase with a Lua function to be recorded. At this case
100+
** lj_debug_frameline() may return BC_NOPOS (i.e. a negative value).
95101
** Equals to zero when LuaJIT is built with the
96102
** -DLUAJIT_DISABLE_DEBUGINFO flag.
97103
*/
98-
lua_assert(line >= 0);
99-
lj_wbuf_addbyte(out, aevent | ASOURCE_LFUNC);
100-
lj_wbuf_addu64(out, (uintptr_t)funcproto(fn));
101-
lj_wbuf_addu64(out, (uint64_t)line);
104+
lj_wbuf_addu64(out, line >= 0 ? (uint64_t)line : 0);
102105
}
103106

104107
static void memprof_write_cfunc(struct lj_wbuf *out, uint8_t aevent,

0 commit comments

Comments
 (0)