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 5C33C6AFDC4; Wed, 25 Oct 2023 14:40:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5C33C6AFDC4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1698234053; bh=LYuPA4ZUv3xnBA5Q9TTMJhpjSf5oKDDlQte/p0pGarU=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dwwuonusN762YXWxeNq1XKLHh9uGkPfUANUTkWjAWRXf0NkmiqfRrjC0sx/Kwodjc bJodNFlkUWn4cum8ZXId55tWhj8q+B5Qk0B3Z0JuQTacAQtrwuWSlUAlVzb5CRK/Ln tR33A0+EDBivvoeY935XPfq3QlgWhisjb4ypn3mg= Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 80C8465341F for ; Wed, 25 Oct 2023 14:40:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 80C8465341F Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-507cee17b00so8174013e87.2 for ; Wed, 25 Oct 2023 04:40:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698234051; x=1698838851; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AD7p/DpDu1lv5SIMKwYRk9p6BDaHolcLA7RT1mdw0Eo=; b=bkYb+A+p6GuKCB/HnkocYJmOGzAxYKlqxQ2NobqJ6fYJstnsqrF9X167RYJ3sQljbg ASvQ7M2xrvn/E8xje9eFQVJ+pe6u4NUde43WXqXHaTGsgGJ/8esetXEIhbcjpcrCNu3E 9wIjhlVLfjiOYDfC8m51CygnVs834MDLMHwPOC/pUWPDEA2EdwY52nhZ/qkapB3x7SaH UUrVR/lpADHcyqezVxSz32kRlJ/6YmVCfLcvfQZTKqhAmlw8qeExXISsvpKO/ZfcowSN Vk8LU98TqyU9EH30MfTP5vtVxizLS4PZtTCfeBM7PGGCUKO/NJWNBugf94Mzh37pSMNn BY+g== X-Gm-Message-State: AOJu0Yw6dPsEvVCj2hITG5bkpS0gkqggUx6ZMSWfKp9U5RAA388C5MwC VhBFzLNmPZkj+E/KOx3uEwjK9ZSBJIrhRA== X-Google-Smtp-Source: AGHT+IHkMqqJ8d51t+wq0gY0WeasKrQsPVM1+9qxJeRA0wjUv3DluzwgN3F9/csq3NOPmGMLFTIThw== X-Received: by 2002:a05:6512:250e:b0:508:19d6:d520 with SMTP id be14-20020a056512250e00b0050819d6d520mr627391lfb.44.1698234051201; Wed, 25 Oct 2023 04:40:51 -0700 (PDT) Received: from localhost.localdomain ([185.205.79.42]) by smtp.gmail.com with ESMTPSA id dw10-20020a0565122c8a00b004fe28e3841bsm2524992lfb.267.2023.10.25.04.40.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 25 Oct 2023 04:40:50 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, sergeyb@tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org Date: Wed, 25 Oct 2023 14:40:45 +0300 Message-Id: <20231025114047.55743-1-max.kokryashkin@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] Prevent compile of __concat with tailcall to fast function. 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" From: Mike Pall E.g. __concat = function() return setmetatable(...) end Reported by Fezile Manana. (cherry-picked from commit 75ee3a6159f1831fa57992df3caf5a2c303c281a) During the recording of concat with tailcall to fast function, the fast function recording is postponed. This implementation may lead to the absence of side effects from fast-function and incorrect behavior as a result. For a comprehensive example, see the comment in the test. Maxim Kokryashkin: * added the description and the test for the problem Part of tarantool/tarantool#9145 --- Branch: https://github.com/tarantool/luajit/tree/fckxorg/lj-690-concat-tail-call PR: https://github.com/tarantool/tarantool/pull/9304 Issue: https://github.com/LuaJIT/LuaJIT/issues/690 src/lj_record.c | 3 ++ .../lj-690-concat-tail-call.test.lua | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/tarantool-tests/lj-690-concat-tail-call.test.lua diff --git a/src/lj_record.c b/src/lj_record.c index 48a5481b..3189a7c3 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -918,6 +918,9 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) TRef tr = gotresults ? J->base[cbase+rbase] : TREF_NIL; if (bslot != J->maxslot) { /* Concatenate the remainder. */ TValue *b = J->L->base, save; /* Simulate lower frame and result. */ + /* Can't handle MM_concat + CALLT + fast func side-effects. */ + if (J->postproc != LJ_POST_NONE) + lj_trace_err(J, LJ_TRERR_NYIRETL); J->base[J->maxslot] = tr; copyTV(J->L, &save, b-(2<