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 086E113101AA; Thu, 6 Mar 2025 19:21:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 086E113101AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1741278075; bh=LUPXd/eRzOjaOZLf58Oe7dSQjUdA1Fs+GjEFSxMh60Q=; 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=bEStyJ3+pHHdj7UP6gXjT8kjmMbUeenipsGTbdazHLvBykGw0BEBsFvq/UBHE96MH 3c08rsa6yjNHlAtrUmoooq60sDBFiITGuDfHk3c5AWtzJXeuSHyDGil/+hnyg1LppK YTWGwyGhANTV1q2KmoElgcMgAIjCcSEa8S+8T2lU= Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 814CA13101AA for ; Thu, 6 Mar 2025 19:20:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 814CA13101AA Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-3061513d353so9037361fa.2 for ; Thu, 06 Mar 2025 08:20:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741278022; x=1741882822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KrpUVTViHmqXF4BkODEN/prxyJbpi4qvMN7/9InDFwY=; b=nWKjyGjgaW5hGDPG6InZrSl9YsIqPL7wlbkMmF0g6UAx1xj4Y+r1Zid6sSd+KvVmAL k9Kisb27jZGEeUQCo3Hgl0UWfPZuJBBLudwI5YrAVIQOJtD64ONCXp8jE7zcpRt/jB3v 2LJTtOyoQAM0T6w8pYFLwZUQ0ofKcVHM9SeHDv9yaeSPsPHTAbfMzawv8sdPbzK465Dt UZAG7LZIrPXX9nUNKqvBiB298IFnj4n2xens63D9A9Qzo3BUCVphf7C+rTQq7stlstc3 OPmGFNWR/0/8gJ3tEiWHXso0rMS9oDNq+R1NcQ4sUV/qf0iRp3zlg+rFSN7kpqDvi39D hW9g== X-Gm-Message-State: AOJu0YwKvSb5/JyXA9U/ei3yrHMqb2OhXXPkTPI4lsz8w1WB+CVQjudn npsmD4iI+DywHiWA3rcFHSvqcYNtEt7SQG4a5+7JSuAWIx88zyP2ZYOEkX8c X-Gm-Gg: ASbGncsVT5Zvghdo/nwHYHdm6MyKZwf0bN/WQHYJWKMT9aAWBsrFAWQ3hRWCQpG8VhZ qNYLlOh7BsEIjyGqY5UCcKL1ocZvY2wnL/Plec6Gfs0UAcwdhYWImXH/nHrS0vwnJh+oIC4gkbk uLpbBeBLg1Aqt4VoQ68S9+AzAT3CNstE140voc1NzCyIl/o0cB4B4wLBevRx+LwmXRztdt+3wSW 9IoqPgn5uAxE2qCaQxrjW2XWAjMNGIqAZ0xTFr1iFkN2V1nuGTKU+c0Eob+dzqxApp2WD6qiy+x ybyeV6s1NDVrQWLsG/BLO3Fyn0pWRT4SEP9psw== X-Google-Smtp-Source: AGHT+IGsbho5ubr+Qas+MaBVjX2qnAD3qRz+sUaLe9pMvJkRHxwG40wQbR7+nuAdMUf2D7kdxcIlGQ== X-Received: by 2002:a05:651c:544:b0:30b:c83e:720f with SMTP id 38308e7fff4ca-30bd7a1e060mr28218031fa.7.1741278021354; Thu, 06 Mar 2025 08:20:21 -0800 (PST) Received: from localhost ([79.164.223.111]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30be98f2f9bsm2490991fa.35.2025.03.06.08.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Mar 2025 08:20:20 -0800 (PST) X-Google-Original-From: Sergey Bronnikov To: tarantool-patches@dev.tarantool.org, Sergey Kaplun Date: Thu, 6 Mar 2025 19:19:00 +0300 Message-ID: <99f54bbebab5e38184294664a944b3cc314cb140.1741277815.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run 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" When sysprof is not started the function `misc.sysprof.stop()` reports that the profiler is already running: | $ ./src/luajit -e 'print(misc.sysprof.stop())' | nil profiler is running already 22 The patch fixes that: | $ ./src/luajit -e 'print(misc.sysprof.stop())' | nil profiler is not running 22 Follows up tarantool/tarantool#781 --- src/lib_misc.c | 6 ++++++ .../tarantool-tests/profilers/misclib-sysprof-lapi.test.lua | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib_misc.c b/src/lib_misc.c index 1c81fd80..88ae9e10 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -336,6 +336,12 @@ LJLIB_CF(misc_sysprof_stop) return prof_error(L, PROFILE_ERRUSE, err_details); #else int status = luaM_sysprof_stop(L); + if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) { + lua_pushnil(L); + lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING)); + lua_pushinteger(L, EINVAL); + return 3; + } if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) return prof_error(L, status, NULL); diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua index 91ea461b..f316c390 100644 --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua @@ -10,7 +10,7 @@ local test = tap.test("misclib-sysprof-lapi"):skipcond({ ["Disabled due to #10803"] = os.getenv("LUAJIT_TEST_USE_VALGRIND"), }) -test:plan(43) +test:plan(44) jit.off() -- XXX: Run JIT tuning functions in a safe frame to avoid errors @@ -123,7 +123,8 @@ assert(res, err) -- Not running. res, err, errno = misc.sysprof.stop() -test:ok(res == nil and err, "result status and error with not running") +test:is(res, nil, "result status with not running") +test:ok(err:match("profiler is not running"), "error with not running") test:ok(type(errno) == "number", "errno with not running") -- Bad path. -- 2.43.0