Subject: bug#41204: closed (Re: bug#41204: port-revealed count is initially > 30000)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 12 May 2020 13:05:03 +0000

Your bug report

#41204: port-revealed count is initially > 30000

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
41204: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=41204
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#41204: port-revealed count is initially > 30000
From: Ludovic Courtès <[email-masked]>
To: Caleb Ristvedt <[email-masked]>
Cc: [email-masked]
Date: Tue, 12 May 2020 15:04:16 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Caleb Ristvedt <[email-masked]> skribis:

> (port-revealed (open-input-file "/dev/null"))
> => 32539

Fixed in b1bdd791cefa1b6d113f9b3972550342d8f4aa9f.

Guile up to 2.2.7/3.0.2 included (but not 2.0) would thus leak the file
descriptors of all the file ports not explicitly closed.  It’s probably
not that common (good practice is too close file ports as soon as you’re
done with them and ‘call-with-output-file’ & co. take care of that), but
still.

Thanks a lot for finding the problem!

Ludo’.

Subject: port-revealed count is initially > 30000
From: Caleb Ristvedt <[email-masked]>
To: [email-masked]
Date: Tue, 12 May 2020 05:32:07 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

(port-revealed (open-input-file "/dev/null"))
=> 32539

The little investigating I've done so far suggests that this is because
scm_i_fdes_to_port calls scm_gc_malloc_pointerless and initializes only
the 'fdes' and 'options' fields, leaving 'revealed' uninitialized. The
comment above scm_gc_malloc_pointerless does a good job of explaining
why this is an issue:

/* Allocate SIZE bytes of memory whose contents should not be scanned
   for pointers (useful, e.g., for strings).  Note though that this
   memory is *not* cleared; be sure to initialize it to prevent
   information leaks.  */

This issue appears to be present both in the 2.2 and 3.0 releases
packaged in guix.

- reepca