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 2C5996EC5B; Fri, 14 May 2021 15:15:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2C5996EC5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1620994518; bh=csWbIOHPpgezRw0nEhLH6mfoIQormzDpluc9PYmABFw=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dJaPciUw6zQSGL0weV2zlwkhoqKa/HIJC2BR8R+m8nFopWTPnaWWYyfjcbqzQbmdj yEJNDFLw0noPBcmm69QTE9FG0l/elxU81f+/7kRO1MHMJoKmrqx3hVEIy5tKylLxr9 bSJmS68S11nUrbtM+RLoC55yKPWCVB8IXxFUnxeg= Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 1B2EE6EC5B for ; Fri, 14 May 2021 15:15:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1B2EE6EC5B Received: by mail-lf1-f52.google.com with SMTP id h10so2250808lfm.7 for ; Fri, 14 May 2021 05:15:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Es+Bxd1TpkQmS4jvAuMpa8Js8cOkZMj0alCFPDu+384=; b=MNskTT3OzHi5GjRft4oVb+pQBDTdChCRwcS+H4vKTbQEcQ54/D9X4n+GW6PGvLwtWv ztgrnOUawrZiSGBFQbtn/Sc5jNeuWOsmxKVp5Ir51VO9AVIn6vBAKnmgZe66IPQirNUa L5AF7/gJhmKi6jZ3EDDwAS3ZKTxx+D6Pj3IB1enAw5xZjNSC8V0sc4H0mYBCJxxeMbFr +hT4AFKop85x6ru4o80FBiG4CC13UwoIk0pPA7OZOrs3rNgeb6tfYQO5aYQawGA7JeUY NKev4PfXllFZK/mgahRcMqDZohNS9BtkfPhISQ9qLeXzMiGb8zg4Y+e4xphQmoDF+1RG YD3A== X-Gm-Message-State: AOAM531mdGi5AMZu02Oxkdc6lXMWvEtZhIbvTWgN23xt8JRD/setZ3uI ga25Zs1Nn+ma3/UPQ9TwI2qANr86lvk= X-Google-Smtp-Source: ABdhPJzTzV7QlfHZeQ+ti1pQfHAe0L9Xfd/y2ObK+mahufN2Lh0Zg5OGmnAbrl8Ig0UcenubpzL+Hg== X-Received: by 2002:a19:2483:: with SMTP id k125mr31868195lfk.331.1620994515934; Fri, 14 May 2021 05:15:15 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id q27sm1054318ljm.127.2021.05.14.05.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 05:15:14 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 3B8075A003D; Fri, 14 May 2021 15:15:14 +0300 (MSK) Date: Fri, 14 May 2021 15:15:14 +0300 To: Igor Munkin Cc: tml , Vladislav Shpilevoy Message-ID: References: <20210514101947.106581-1-gorcunov@gmail.com> <20210514104115.GI3944@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514104115.GI3944@tarantool.org> User-Agent: Mutt/2.0.6 (2021-03-06) Subject: [Tarantool-patches] [PATCH v3] lua/utils: fix fiber->fid print in cord_on_yield 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Fri, May 14, 2021 at 01:41:15PM +0300, Igor Munkin wrote: > Cyrill, > > Thanks for the fixes! Just a couple of nits. > > On 14.05.21, Cyrill Gorcunov via Tarantool-patches wrote: > > This fixes a nit in commit 6af473778 > > (fiber: use uint64_t for fiber IDs). > > If you want to mention this commit, please use the full hash and enclose I don't understand why you need a full hash? When the reference is generated the git makes sure that id being generated is long enough among existing commits to be parseble. But sure, no problem. > the commit subject into single quotes: it's the common way used in repo. > You can find an example here[1] (but GitHub strips the hash while > rendering the webpage). > > > > > Since lua_pushfstring doesn't support %llu format it > > breaks the test > > Minor: It would be nice to refer Lua Reference Manual[2] then. Sure, thanks! > > + snprintf(buf, sizeof(buf), > > + "fiber %llu is switched while running the" > > + " compiled code (it's likely a function with" > > + " a yield underneath called via LuaJIT FFI)", > > + (long long)fiber()->fid); > > Why do you cast the value to long long (i.e. signed value), but use the > unsigned %llu modifier? This might be OK, but it's not clear to me. Because only _size_ of argument does matter, and language standart guarantees that signed and unsigned arguments are counterparts. Thus instead of big "unsigned long long" specificator you can write a shorthand "long long". Force pushed an update. --- From: Cyrill Gorcunov Date: Fri, 14 May 2021 13:18:13 +0300 This fixes a nit in commit 6af4737789042b1e6673c421686bb4394a61f4a1 ("fiber: use uint64_t for fiber IDs"). Since lua_pushfstring doesn't support %llu format [1] it breaks the test app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua [1] https://www.lua.org/manual/5.1/manual.html#lua_pushfstring Signed-off-by: Cyrill Gorcunov --- src/lua/utils.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lua/utils.c b/src/lua/utils.c index 0fbe700fc..3ce821374 100644 --- a/src/lua/utils.c +++ b/src/lua/utils.c @@ -1341,6 +1341,7 @@ void cord_on_yield(void) * code misbehaviour and failures, so stop its execution. */ if (unlikely(tvref(g->jit_base))) { + char buf[256]; /* * XXX: mcode is executed only in scope of Lua * world and one can obtain the corresponding Lua @@ -1348,10 +1349,12 @@ void cord_on_yield(void) */ struct lua_State *L = fiber()->storage.lua.stack; assert(L != NULL); - lua_pushfstring(L, "fiber %llu is switched while running the" - " compiled code (it's likely a function with" - " a yield underneath called via LuaJIT FFI)", - (long long)fiber()->fid); + snprintf(buf, sizeof(buf), + "fiber %llu is switched while running the" + " compiled code (it's likely a function with" + " a yield underneath called via LuaJIT FFI)", + (long long)fiber()->fid); + lua_pushstring(L, buf); if (g->panic) g->panic(L); exit(EXIT_FAILURE); @@ -1376,11 +1379,14 @@ void cord_on_yield(void) * GC hook is active and the platform is forced to stop. */ if (unlikely(g->hookmask & HOOK_GC)) { + char buf[128]; struct lua_State *L = fiber()->storage.lua.stack; assert(L != NULL); - lua_pushfstring(L, "fiber %d is switched while running GC" - " finalizer (i.e. __gc metamethod)", - fiber()->fid); + snprintf(buf, sizeof(buf), + "fiber %llu is switched while running GC" + " finalizer (i.e. __gc metamethod)", + (long long)fiber()->fid); + lua_pushstring(L, buf); if (g->panic) g->panic(L); exit(EXIT_FAILURE); -- 2.31.1