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 261CCD2B464; Thu, 7 Nov 2024 13:51:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 261CCD2B464 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1730976700; bh=COGzAw/s2oyWiW3urD9xGDBpni1W9/l9Hx2qPuOHwjw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bTWaz1KHpzt9DHmXsbinLp+itAISQp8AIg2Zs3pe550Q12+Hz8KuX/o67syXIlzvG Ax3r75l9JyQKdayfuurYNlDuyEaHJjeuoHejBeMz0CBLDMUEXSFcvNxI0qVlO6IVYj FPQetbr4fdtRXSZk49hrP/2a0mlurpAB4Z7pPfJo= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 AAD61412EED for ; Thu, 7 Nov 2024 13:51:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AAD61412EED Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-539f84907caso728758e87.3 for ; Thu, 07 Nov 2024 02:51:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730976698; x=1731581498; 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=Q5LFKjuGh5KdKAkMEolN/hG1aZY2YypwFfFfQrJMboA=; b=M+rNVJOOtnE24WgPDhjnG2WrVJiCTHU0CPkrABUv+/0aDPWu9OFo9YPPv31PijP7Or vynjRMOPudelEFAy9lk+ANtDbUDXEGeOrEeEYI8JEvOrZCG7w4RNk8p3xb9OlGJ60gFd B6sjzDt6rFifi75aJPkr+Imr1DU+XVU7dbLss0J1IdZi3FnfjJECWogees1CvntpHKRL iDSBJ1i8PwKt3+BZN8AR5v0MLF68baZglxzU2AJEZ2RrLt6cLCs3F0dqUF1fLXxBScJX GP4sjO8ofEThZBX12DeX04uYCqEmqwP5qrIqcm49WTJagMKvLZZlBVJYFvT+VgnJk84S h8KA== X-Gm-Message-State: AOJu0YwBSZiqKPMPXk+hklsYVSzRUY+XnuUjhQOO9HjKass7aFES6jRH dEMOlDK3He/xbwGd8hkucGs3OqAcz9EcMg3gxPs178+r1qcFsOSSM1/d0l2j X-Google-Smtp-Source: AGHT+IHqSGL4L3/OsqHf/j6SjQcbOzs+xAUULsg5TNIfymdDnxKNkA23Ky1CsrDIXwFuu9nZ3QGZDw== X-Received: by 2002:a05:6512:159d:b0:539:e23a:9eaa with SMTP id 2adb3069b0e04-53b34c8db64mr22050659e87.50.1730976697459; Thu, 07 Nov 2024 02:51:37 -0800 (PST) Received: from localhost ([5.181.62.98]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53d826aefc8sm164493e87.260.2024.11.07.02.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 02:51:35 -0800 (PST) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , Maxim Kokryashkin Date: Thu, 7 Nov 2024 13:51:32 +0300 Message-Id: <76c9c163c365aec70741162ab83fdfa6385a9118.1730976041.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] Fix compilation of getmetatable() for UDTYPE_IO_FILE 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" From: Sergey Bronnikov The patch fixes a problem with recording `getmetatable()` for I/O object: recording of `getmetatable` call with a file descriptors represented by userdata object `UDTYPE_IO_FILE` (like `io.stdout`) leads to violation of assertion in `rec_check_slots`. Note, the problem was fixed upstream in different manner, see commit 5141cbc20c43 ("Fix compiliation of getmetatable() for UDTYPE_IO_FILE."). --- src/lj_record.c | 2 +- ...-incorrect-recording-getmetatable.test.lua | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua diff --git a/src/lj_record.c b/src/lj_record.c index cc97bdf9..7181b72a 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -990,7 +990,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) int udtype = udataV(&ix->tabv)->udtype; mt = tabref(udataV(&ix->tabv)->metatable); /* The metatables of special userdata objects are treated as immutable. */ - if (udtype != UDTYPE_USERDATA) { + if (udtype > UDTYPE_IO_FILE) { cTValue *mo; if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { /* Specialize to the C library namespace object. */ diff --git a/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua b/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua new file mode 100644 index 00000000..8bf22ca7 --- /dev/null +++ b/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua @@ -0,0 +1,21 @@ +local tap = require('tap') + +local test = tap.test('lj-1279-incorrect-recording-getmetatable') +test:plan(1) + +-- A test file to demonstrate an incorrect recording of +-- getmetatable() for I/O handlers. +-- https://github.com/LuaJIT/LuaJIT/issues/1279 + +jit.opt.start("hotloop=1") + +local obj = io.stdout +local getmetatable = getmetatable + +for _ = 1, 4 do + _ = getmetatable(obj) +end + +test:ok(true, 'getmetatable() recording is correct') + +test:done(true) -- 2.34.1