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 7420E6ECCD; Tue, 14 Mar 2023 18:25:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7420E6ECCD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1678807515; bh=A7qyGjikfNcx8vlz5DfPEF9ehp9zixzNx2lsd82ji8s=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=GoRxze8lvSXNS2k/tZpFCsEo2QayyImBY4WbMD9PEwo5s28m21SRjt7/pgmMPgMxZ qnRAw9CADQwO4+kaLrPgG/IvBXl98LJxontkYXRztpUNzZoJnbPu33qDS5eLQLmPHw JxWZNBaKwco3+VylaPu/iEAMrYWdYWMKR/oX5n4k= Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 B4F3D6ECCD for ; Tue, 14 Mar 2023 18:25:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B4F3D6ECCD Received: by mail-lf1-f53.google.com with SMTP id g17so20526218lfv.4 for ; Tue, 14 Mar 2023 08:25:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678807512; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0DeiEjT0+trxvHLH5Fi1D1ZgbeqmkUnxEIMI70t25SQ=; b=50oCvdszIE7PuFmb9RVtKH2DrMc0SisTlFzpv3htqSd9nDmGbDS1ZJcgQrpQbhLLcd 0mJp/el75Yh3f9HjFv0cuRgKJl9TZU72DadIJI4sat2cxyFHlEHhqs7wTokaXb149TCb yXWOxzyJfUFy4P737HBLsZDvm/7G4c08lJQYY6nctFzVkpfmYpyxKwRz4LB30k+C48Xl NAI7uCuACliUfsuddUj5c8agwhOcu3G5cfuz7RbgutrLpUX6SM+IuVd0QeKJM+ljlnPh bynIQdkl5LkRYB6NPjN2ZM2fKZS8pkZMB0qOUaNxqKpbRzS9EHexgDpoH+R2I3BgG9FW cCcA== X-Gm-Message-State: AO0yUKU7qvUkf3fN2xtkCqAQp0uKxd3KYx7SlQz6Rj9/JppNxr1TO0kR khTpvBPWKpRiSRXEMKJ9zJtipzPduY7t5bWF X-Google-Smtp-Source: AK7set/Iplty9/doW93lDjBbPMBse4VGDYc6jRmHTVoVQYonJW75fO1vdSXnuL/XTKHkJwrjBAVqNA== X-Received: by 2002:ac2:4949:0:b0:4e0:2e4e:8e74 with SMTP id o9-20020ac24949000000b004e02e4e8e74mr900183lfi.48.1678807512428; Tue, 14 Mar 2023 08:25:12 -0700 (PDT) Received: from m1book4386.mail.msk ([185.205.79.32]) by smtp.gmail.com with ESMTPSA id g15-20020a19ee0f000000b004db1cd5efcesm441000lfb.241.2023.03.14.08.25.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Mar 2023 08:25:11 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, sergos@tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org Cc: Maksim Kokryashkin Date: Tue, 14 Mar 2023 18:25:07 +0300 Message-Id: <20230314152507.37168-1-max.kokryashkin@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] codehealth: fix sign extension in sysprof counters 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: Maksim Kokryashkin via Tarantool-patches Reply-To: Maksim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The `setnumfield` function takes `int64_t` as an argument. Profile counters used to have the `uint64_t` type before this patch, which could lead to issues with sign extension. Now their type is `int64_t`, so they correspond to the `setnumfield` argument type. --- PR: https://github.com/tarantool/tarantool/pull/8440 Branch: https://github.com/tarantool/luajit/tree/fckxorg/svace-sysprof-report src/lj_sysprof.c | 2 +- src/lmisclib.h | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lj_sysprof.c b/src/lj_sysprof.c index 2e9ed9b3..4723e6f9 100644 --- a/src/lj_sysprof.c +++ b/src/lj_sysprof.c @@ -285,7 +285,7 @@ static void sysprof_record_sample(struct sysprof *sp, siginfo_t *info) lua_assert(pthread_self() == sp->thread); /* Caveat: order of counters must match vmstate order in . */ - ((uint64_t *)&sp->counters)[vmstate]++; + ((int64_t *)&sp->counters)[vmstate]++; sp->counters.samples++; diff --git a/src/lmisclib.h b/src/lmisclib.h index 9084319c..599a6ea9 100644 --- a/src/lmisclib.h +++ b/src/lmisclib.h @@ -105,21 +105,21 @@ typedef void (*luam_Sysprof_backtracer)(void *(*frame_writer)(int frame_no, void #define LUAM_SYSPROF_CALLGRAPH 2 struct luam_Sysprof_Counters { - uint64_t vmst_interp; - uint64_t vmst_lfunc; - uint64_t vmst_ffunc; - uint64_t vmst_cfunc; - uint64_t vmst_gc; - uint64_t vmst_exit; - uint64_t vmst_record; - uint64_t vmst_opt; - uint64_t vmst_asm; - uint64_t vmst_trace; + int64_t vmst_interp; + int64_t vmst_lfunc; + int64_t vmst_ffunc; + int64_t vmst_cfunc; + int64_t vmst_gc; + int64_t vmst_exit; + int64_t vmst_record; + int64_t vmst_opt; + int64_t vmst_asm; + int64_t vmst_trace; /* ** XXX: Order of vmst counters is important: it should be the same as the ** order of the vmstates. */ - uint64_t samples; + int64_t samples; }; /* Profiler options. */ -- 2.37.1 (Apple Git-137.1)