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 334276ECE3; Sun, 12 Jun 2022 21:52:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 334276ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1655059947; bh=GNLXguxclvZYu6HlnmuTKmCFRyheQfmc/oJYJw8tz3c=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LRiSyb4OLiXvYzpEimvCpsIZuriSUgEANw/atoDEj0JcWRVMMz4nhL/5y/FVmwt+i KjX0xP9zdMPScLBtuuIa6FiyGNmdNdLtsOzzmMB7GZOqhS12I68ox1i2GGONuvJrIZ RXuUQV+UA5hbKt8NOeRIzetq8Z0xTXmUmY4V4nUk= Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 CCB646ECE3 for ; Sun, 12 Jun 2022 21:52:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CCB646ECE3 Received: by mail-lf1-f43.google.com with SMTP id 20so5787600lfz.8 for ; Sun, 12 Jun 2022 11:52:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GIvsoXKHlfZBtNgEGnIwWz9l15RRZhIQeW3lm0bQYyU=; b=2YwOoGbIG/j0WCKMiQn0fY42KqgV9ABOlUaoc6TTmEtzBkC3xpi+ddRZB7QDVIl3d+ Q4dL4IfM4sm47mYf9Aq3gfm7QVvXfoJBetsvHFemZdRgcE9RGny3QuD1XNRcBZn6JeIQ 0i6xL/6XFontMX2pnG2rC3wNrffMPdEMa1b7E7o2NsKNEFMuZ6YmufkJ1t9NNFP1W6Ms 3Ij9vwavizoUCmDZlpJSVKw3NZqhpk/3M2ZA6SWizqMaHbl4yT8/JGvjweQKa1RBmw6G qx8B4tlz95FonG/gHRo/6bb/LW+dB5wU/wlmL8sIMT1/rER8QibPV4Kv5btaOATJRFhz xA5w== X-Gm-Message-State: AOAM533NdfPCOrkyWwSiJbIlUTtkK2vqXU00GRkJJ6m36Kfhnyw7BctC bXZ1wrry84XoTQZO+vsH9YrC9dNj7S9Apg== X-Google-Smtp-Source: ABdhPJwKhNcXYHAkAYeiIZFW+Uwqbz6GH4y6xAUr7UhG8rgAJb+YNLb1zu6XCmk1hpRnkTugPPB17w== X-Received: by 2002:a05:6512:25a3:b0:479:1928:b7a6 with SMTP id bf35-20020a05651225a300b004791928b7a6mr28841681lfb.385.1655059944827; Sun, 12 Jun 2022 11:52:24 -0700 (PDT) Received: from localhost.localdomain (109-252-140-49.dynamic.spd-mgts.ru. [109.252.140.49]) by smtp.gmail.com with ESMTPSA id s16-20020a056512215000b004790cba2883sm692293lfr.186.2022.06.12.11.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 11:52:24 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Sun, 12 Jun 2022 21:52:20 +0300 Message-Id: <20220612185220.502537-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] sysprof: disable proto and trace dumps in default 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" There is no need to dump proto or trace information for sysprof in the default mode. Moreover, attempts to do so will lead to segmentation fault due to uninitialized buffer. This commit disables proto and trace dumps in the default mode. Resolves tarantool/tarantool#7264 --- PR: https://github.com/tarantool/tarantool/pull/7265 Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-7264-dump-proto-default-mode src/lj_sysprof.c | 4 +- ...4-add-proto-trace-sysprof-default.test.lua | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua diff --git a/src/lj_sysprof.c b/src/lj_sysprof.c index a4a70146..2e9ed9b3 100644 --- a/src/lj_sysprof.c +++ b/src/lj_sysprof.c @@ -524,7 +524,7 @@ void lj_sysprof_add_proto(const struct GCproto *pt) { struct sysprof *sp = &sysprof; - if (sp->state != SPS_PROFILE) + if (sp->state != SPS_PROFILE || sp->opt.mode == LUAM_SYSPROF_DEFAULT) return; /* @@ -543,7 +543,7 @@ void lj_sysprof_add_trace(const struct GCtrace *tr) { struct sysprof *sp = &sysprof; - if (sp->state != SPS_PROFILE) + if (sp->state != SPS_PROFILE || sp->opt.mode == LUAM_SYSPROF_DEFAULT) return; /* See the comment about the sysprof state above. */ diff --git a/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua b/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua new file mode 100644 index 00000000..2d2a756a --- /dev/null +++ b/test/tarantool-tests/gh-7264-add-proto-trace-sysprof-default.test.lua @@ -0,0 +1,58 @@ +-- Sysprof is implemented for x86 and x64 architectures only. +local ffi = require("ffi") +require("utils").skipcond( + jit.arch ~= "x86" and jit.arch ~= "x64" or jit.os ~= "Linux" + or ffi.abi("gc64"), + jit.arch.." architecture or "..jit.os.. + " OS is NIY for sysprof" +) + +local tap = require("tap") +local jit = require("jit") + +local test = tap.test("gh-7264-add-proto-trace-sysprof-default.test.lua") +test:plan(2) + +jit.off() +jit.flush() + +local function allocate() + local a = {} + for _ = 1, 1e4 do table.insert(a, "teststring") end + return a +end + +local chunk = [[ +function lua_global_f() + local a = 'teststring' +end +]] + +-- Trace creation during the sysprof runtime. +jit.on() + +local _ = nil +local res, err = misc.sysprof.start({ mode = "D" }) +assert(res, err) +allocate() +res, _ = misc.sysprof.stop() +test:ok(res) + +jit.off() + +-- Proto creation during the sysprof runtime. +res, err = misc.sysprof.start({ mode = "D" }) +assert(res, err) + +res, err = loadstring(chunk) +assert(res, err) +res() + +-- luacheck: globals lua_global_f +lua_global_f() +collectgarbage() +res, _ = misc.sysprof.stop() +test:ok(res) + +jit.on() +os.exit(test:check() and 0 or 1) -- 2.36.1