From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by sourceware.org (Postfix) with ESMTPS id 8A6BD3858D39 for ; Sun, 30 Apr 2023 22:52:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A6BD3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dvus.co.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dvus.co.uk Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-54fae5e9ec7so27153757b3.1 for ; Sun, 30 Apr 2023 15:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dvus-co-uk.20221208.gappssmtp.com; s=20221208; t=1682895171; x=1685487171; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q14HeZYY9tZRNuy7oXX++1cjfJND2R9UqF3QXG6I0FU=; b=n+7FjFBMXvHqXfEW5IYUSoYR++jlo9JeBsGnOLbX4HcKIcxTw8vJAZbORTMp1qKP1w /1zgrdCqVkNLYWhImNh37ndbtsYf+LUDg21CjK2gP1if+qS+fo3Ue2Wf6PfMBW/w3V94 NQ+1711MQ1I0dKSgSgHJzWRsgAm98SgfFpmXTTsFvIi67poDRE9sS21bOJ6H69jSCoa1 SeJ0VVw4JY4kqgsJ4f9CLdF7XCatdH8k5L1uija2a5Xs0rt5xeuuytue1wdZN6GcDOpP V+xCUzNw+aCx5gSgiU0VMTVtw3FyuuESW7mcmCLn7gcmLIquuB1S7Zo/oVt8dQeEV0IO v1SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682895171; x=1685487171; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q14HeZYY9tZRNuy7oXX++1cjfJND2R9UqF3QXG6I0FU=; b=OGTyC8TB0nWxAyPX+lhWmCGbPEUwKjW3TELxkqr5XEHK55ALveX/Tjb/d/aDJT9ani f1LUG4Byn8SkURYnCZ1/VLEAXHdufdcY0fuJYYuuy9apolO7VQGQPQJVEl9pTFeLkPit jX9jhBPHJI/aBbfF3mtHLTZSKIhw8snbe5SYwvO5rlM7dYqEClXrg9pEqnZSo1PXIrj5 ETbFZVRG4zyJKOTA7YR/hxAdgVq+GvF5S8YLZluaB1EJvt+5203TTRWCECv7EepdGDbC FVt+sOhS68bzBfG3wNJ3NbyLkTgjrksS0/wCoUXKLjXwb2Usd7RxOxOdmgE8cHj5j2TP 8neg== X-Gm-Message-State: AC+VfDx4FMamf4PK6fh8PH7FRrg1i7nCW+vXE33Hz3+I7oCbNu77gMeH UsNFVQfUXDwy7SJpwQmduy9gz/iXKh7MLMVzbgc3+yN+DzIbuYSs8un9zPSr64YlFHhkOA/wuPn eLqEFdaq/WM95ARqsMyIE7YpeRoC4f4HO/DWzSXk= X-Google-Smtp-Source: ACHHUZ57DarN70f190rb5La2RwyDqWjjNTcDHKzPaG/Nef6Y8wzRfR6F3hRKibmT7PhoxpRR5zReoJYppXYNbV1g0bA= X-Received: by 2002:a81:6e54:0:b0:559:e50b:fa80 with SMTP id j81-20020a816e54000000b00559e50bfa80mr5621479ywc.44.1682895170622; Sun, 30 Apr 2023 15:52:50 -0700 (PDT) MIME-Version: 1.0 From: Nick French Date: Sun, 30 Apr 2023 23:52:39 +0100 Message-ID: Subject: Memory reclaim errors To: newlib@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.0 required=5.0 tests=BAYES_05,DKIM_SIGNED,DKIM_VALID,KAM_COUK,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: We currently have a problem that when we tidy up a task that exists we get memory problems due to the fact that we clear memory that is within newlibs global file handles. The build of newlib that we do is nano. We have tracked down an error to what I believe is the following function. /* * Find a free FILE for fopen et al. */ FILE * __sfp (struct _reent *d) { FILE *fp; int n; struct _glue *g; _newlib_sfp_lock_start (); if (!_GLOBAL_REENT->__sdidinit) __sinit (_GLOBAL_REENT); for (g =3D &_GLOBAL_REENT->__sglue;; g =3D g->_next) { for (fp =3D g->_iobs, n =3D g->_niobs; --n >=3D 0; fp++) if (fp->_flags =3D=3D 0) goto found; if (g->_next =3D=3D NULL && (g->_next =3D __sfmoreglue ( d, NDYNAMIC)) =3D=3D NULL) break; } _newlib_sfp_lock_exit (); The line below causes us to free the memory as it is assigned to the current thread (g->_next =3D __sfmoreglue ( d, NDYNAMIC)) =3D=3D NULL) changing the local thread to global as below fixes it and the file handle get reused (g->_next =3D __sfmoreglue (_GLOBAL_REENT, NDYNAMIC)) =3D=3D NULL) Any comments on our assumptions are appreciated. --=20 *ATTENTION:* This e-mail and any files transmitted with it are confidential=20 and intended solely for the use of the individual or entity to whom they=20 are addressed.=C2=A0If you are not the intended recipient, please e-mail th= e=20 sender immediately by replying to this message and delete the material from= =20 any computer.=C2=A0 This e-mail is attributed to the sender and may not=20 necessarily reflect the view of DVus Ltd, any subsidiary or associate. _________________________________________ Please consider the environment=20 before printing this e-mail