From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 628A96EFF1; Mon, 2 Nov 2026 16:14:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 628A96EFF1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1793625244; bh=8fj3s1K6p3yehLz/40KlH4PKWsHjthFs64IjBSF/iK8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AF40+ZLZlUdLZva1H/r112hcHVJpGuTK/LTOis9Cn0qwHb2Vnz52u08VCVxQXIDkI mmboVUr+s5rcpAj0RLrbulDtOz78AOY+ipPbUnpBuPMGr+QrHtrLUlctcogfghavSA NmRCe+CNRpbAN9XbNK/bbKnJvT89UzfRHw0cCQCk= Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2FA996EFF1 for ; Mon, 2 Nov 2026 16:12:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2FA996EFF1 Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-3a98f260f85so28537361fa.0 for ; Mon, 02 Nov 2026 05:12:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793625175; x=1794229975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=IEiEXaUU47z9Zd8oCn8PKc4PTasfAJZ/0OclTx6F8nU=; b=Ext9MkCAQmga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5oAc7r9mlkfrl/8TQB2s+ooY5nXoTMmcse5bBCXuOj4= X-Received: by 2002:a2e:be26:0:b0:3aa:ee7a:546a with SMTP id 38308e7fff4ca-3acb7ac3856mr24542051fa.25.1793625175025; Mon, 02 Nov 2026 05:12:55 -0800 (PST) Received: from localhost ([79.164.223.111]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3acbbebea30sm20097731fa.8.2026.11.02.05.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 05:12:54 -0800 (PST) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , e.temirgaleev@tarantool.org Date: Mon, 2 Nov 2026 16:12:51 +0300 Message-ID: X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 3/3] sysprof: release resources on a halted profiler X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Sergey Bronnikov If the stream fails (e.g., because of ENOSPC), the profiler moves to the SPS_HALT state. `lj_sysprof_stop()` returns PROFILE_ERRIO but does not call the `on_stop` callback, so the profile context and the output file descriptor are leaked. Call `on_stop` when the halted profiler is stopped, as it is already done when starting fails or when the stream is stopped in a regular way. Preserve the saved errno because `on_stop` may change it. Follows up tarantool/tarantool#11620 --- src/lj_sysprof.c | 4 +++- test/tarantool-c-tests/gh-11620-sysprof-enospc-crash.test.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lj_sysprof.c b/src/lj_sysprof.c index 99bcc088..667c93a8 100644 --- a/src/lj_sysprof.c +++ b/src/lj_sysprof.c @@ -509,9 +509,11 @@ int lj_sysprof_stop(lua_State *L) lj_profile_timer_stop(&sp->timer); if (SPS_HALT == sp->state) { - errno = sp->saved_errno; + const int saved_errno = sp->saved_errno; sp->state = SPS_IDLE; /* wbuf was terminated when error occurred. */ + sp->on_stop(sp->opt.ctx, sp->out.buf); + errno = saved_errno; return PROFILE_ERRIO; } diff --git a/test/tarantool-c-tests/gh-11620-sysprof-enospc-crash.test.c b/test/tarantool-c-tests/gh-11620-sysprof-enospc-crash.test.c index 0f5ffe53..3c9ac05d 100644 --- a/test/tarantool-c-tests/gh-11620-sysprof-enospc-crash.test.c +++ b/test/tarantool-c-tests/gh-11620-sysprof-enospc-crash.test.c @@ -120,6 +120,8 @@ static int sysprof_enospc_during_sampling(void *test_state) errno = 0; assert_int_equal(luaM_sysprof_stop(L), PROFILE_ERRIO); assert_int_equal(errno, ENOSPC); + /* The error path releases the profiler resources. */ + assert_int_equal(ctx.on_stop_calls, 1); /* Counters are still available. */ assert_true(luaM_sysprof_report(&counters) == PROFILE_SUCCESS); -- 2.56.0