From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by gnuweeb.org (Postfix) with ESMTPSA id 8EDE880FF1 for ; Mon, 3 Oct 2022 23:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664839563; bh=BGsowUXiU2TN6tl7dSo98umY2238P5FnogY3/QyJ4yE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nbPKc01Y6iwO73Xr21hmp9ukK0HZpJK1n32O9ntK51jJCC8BzY+dox2EgseXG9P9I LpnfCOLa9XooEYPrrK1mf4oyAMyv32f24mldKclEz88R3thk7VmzIoglbgi06jbORS GxtQT1n1IYHl3ru3feFf46gQv0VHPRJ0OF4VMqlNgjlt313TBgaCEhas2U1PDdhLjg N5TJ1EMXiYJ6JB+IdxBS0FF57J2TaGBmnx+R7vXRsLXN5La6VMBW2iJ895zOxlXxiH 53hnWcSHNUOqAp1KwgiBfb3BXMG78vMSjBWZzoKT8Zfnsz8K87ViCNr8z8jGmLlxEr jFSRFytWKhkIA== Received: by mail-lf1-f48.google.com with SMTP id d6so4618880lfs.10 for ; Mon, 03 Oct 2022 16:26:03 -0700 (PDT) X-Gm-Message-State: ACrzQf3BHIFy/kgJS0XFcFjjFDelpQEKasTegG7Sp0S9BSwwzVbQyx1Y AZ+GqE8HtVJ4jOAyNfFm9GCT7k12rkjAmIYfS+g= X-Google-Smtp-Source: AMsMyM7NdF6I1xK1L7d9DtdpjH0jxXuFqaT0buPoBoPo0xcQvnbu3fiKLGc0wqB0bbSCGdW90TRiFzJTCYnUtxCm4Hk= X-Received: by 2002:ac2:495c:0:b0:4a2:2d6e:4a39 with SMTP id o28-20020ac2495c000000b004a22d6e4a39mr3901511lfi.233.1664839561661; Mon, 03 Oct 2022 16:26:01 -0700 (PDT) MIME-Version: 1.0 References: <768fb0d7-24e2-ea51-778a-d0bae19ed306@gnuweeb.org> In-Reply-To: <768fb0d7-24e2-ea51-778a-d0bae19ed306@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Tue, 4 Oct 2022 06:25:50 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] chnet updates To: Ammar Faizi Cc: Muhammad Rizki , Kanna Scarlet , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" List-Id: On Mon, Oct 3, 2022 at 6:55 PM Ammar Faizi wrote: > Hi Al, > > Various chnet updates. Mostly just general updates, the most noticable > change is the recent memory leak bug fix. > > The previous Node JS ring wrapper design has a memory leak issue. It > is not clear how to avoid memory leak issue when we are attaching a > function or a class with user data to a Napi::Object. I have reported > the issue to the Node JS team. They said they are going to fix it from > the Node JS core side. > > Link: https://github.com/nodejs/node-addon-api/issues/1213 > Link: https://github.com/nodejs/node-addon-api/issues/1212 > > In short, we can't rely on the GC calling the registered finalizers. > > For now, redesign the Node JS wrapper to avoid this issue. Use > a Napi::Number to save the C++ pointer and pass the number as a Node > JS function argument, then internally cast the number back to C++ > pointer each function call that requires a CHNet pointer interaction. > > This design is unsafe, because if the given number argument is not a > valid pointer, it will lead to undefined behavior. Create a class > wrapper written in JavaScript to make it safer. The class wrapper also > adapts the previous object design to minimize breaking changes. > > This has been tested with the current unit tests and the result is > all green. > > Please pull! very good, pulled tq -- Viro