From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Some issues with the tree-sitter branch Date: Mon, 17 Oct 2022 02:12:13 -0700 Message-ID: <6164C2B0-B0D0-4AEB-B76C-7588D643DBBB@gmail.com> References: <83o7ub51yd.fsf@gnu.org> <6F240F48-E29C-4E75-B5D5-30C7CF7956C9@gmail.com> <83y1tf2be6.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38178"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 17 11:18:10 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okMGA-0009if-Bl for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Oct 2022 11:18:10 +0200 Original-Received: from localhost ([::1]:41882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okMG8-0001uv-RX for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Oct 2022 05:18:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okMAV-0003G6-4l for emacs-devel@gnu.org; Mon, 17 Oct 2022 05:12:19 -0400 Original-Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:47016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okMAT-0000jC-Dm; Mon, 17 Oct 2022 05:12:18 -0400 Original-Received: by mail-pg1-x529.google.com with SMTP id 78so9895029pgb.13; Mon, 17 Oct 2022 02:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PU6InvCsbAQlMeidvjOsgSedcUTcH1YS0RKseUPYHWw=; b=WqhKqnxUzQUhv/9IJ5R0neUB0foSerutVl6KzAk16aL8A0ZetWtnscFqlWIk7X/pMI l2n4Bu86kvxnmS/7hdkLl4wDGL9oXSSeXTo1X4PzJzVR2cKEK3WY3zMsmRvAv1c6pfwj cBylwGzNVl+2x1cVCBBU7mCNoHXOW4J3GKe0DlQ5CfElgcss4ujK7/MO35NRdfP9Acnz vWTy47uGjjM0lq3suCjqPUfGebapNq6qZ4d6TCk1+bQtJ266luqO04e4PyGEqEZB4msb j7clRooHGLoPWPMb9S13ciBl0fUWVYWkBz8HQ8VaffmfjZINifvVwxWpmTQvRxk7xRcp dGoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PU6InvCsbAQlMeidvjOsgSedcUTcH1YS0RKseUPYHWw=; b=o14P5357ARNBfpZFH6qbGmKQXDQP6xTp+OwgyLHA4NxKDUP1TFcnMWotFBJkZ13ojL h85H7ohoZNiSVBGVckTrDQMRBEl+7yC5xCEc0Gk/0SGVzZKcsZQ+ffgwNkTrmJhTiDfw eukLxbUQVK4a2IhnxR2QvIFbtNr20cOt7c0jFUAlgoQP8Qb1Kfk6o8vn1vDf/l0zYmMv XLly1EVpWTocIBncMFDnwKGFG6YDEFvdd/rlVW47LGlhm+nAfTxr5SUXZCtgGLk7ln1T /kZ2JnMmpX2agGG/VDkV6z7Nx2XK+SoNiUmKUnVSURidTptb3hMNg9v90yaOx/kwbcJN 09Ug== X-Gm-Message-State: ACrzQf33lZkqNt5M1rjwWcn0W66LLmk0VxxTWGLb2c6u3pR7o2+p3DfR pkzZAy1swGg5KvTz7mV/pZsaWZ5CEOU= X-Google-Smtp-Source: AMsMyM7Z164sl6jsYHV5OSgJg2AOesbuVBqIrb/8SFyz4mqh8yfWcRAg8SgO9F5s02rlU4ddvO9sgA== X-Received: by 2002:a65:6849:0:b0:461:8779:2452 with SMTP id q9-20020a656849000000b0046187792452mr9606319pgt.383.1665997935256; Mon, 17 Oct 2022 02:12:15 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id i31-20020a17090a3da200b0020ad7678ba0sm5819867pjc.3.2022.10.17.02.12.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Oct 2022 02:12:14 -0700 (PDT) In-Reply-To: <83y1tf2be6.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=casouri@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:297943 Archived-At: >=20 >> I added buffer size check at parser creation time, and used casts to = uint32_t liberally, assuming the values never overflows and, so we = don=E2=80=99t need to handle the error at a million places. But I should = have added checks in ts_after_chang and other places where buffer size = could change. I=E2=80=99ll add checks in ts_after_change and other = places, and if the argumetns overflows uint32, it will set a flag (say, = buffer_too_large) in the parser object, and next time any lisp function = tries to use that parser, an buffer-too-large error will be signaled. = WDYT? >=20 > That sounds fine to me, but I think we also should do something when > some value that can be larger than UINT_MAX is passed to tree-sitter > functions, because doing so might cause tree-sitter do something for a > completely unrelated portion of the buffer. At the very least add > eassert there, so that at least a build with --enable-checking will > detect such cases. IIUC you don=E2=80=99t want to hide and delay the error, right? That = makes sense. I can add assertions, those assertions shouldn=E2=80=99t = interfere with normal usage. Yuan=