From ludo at gnu.org Mon Jan 4 10:59:59 2021 From: ludo at gnu.org (=?utf-8?Q?Ludovic_Court=C3=A8s?=) Date: Mon, 04 Jan 2021 10:59:59 +0100 Subject: [gnutls-help] Bug#964284: guile-gnutls: update to use guile 3.0 In-Reply-To: <87v9cjxupe.fsf-ueno@gnu.org> (Daiki Ueno's message of "Wed, 30 Dec 2020 14:57:33 +0100") References: <87v9j2204s.fsf@ponder> <877dpymybw.fsf@yucca> <87czzm2ehb.fsf@gnu.org> <87lfe83heg.fsf@trouble.defaultvalue.org> <87a6uoutgn.fsf@gnu.org> <87blem41jz.fsf@gnu.org> <87v9cjxupe.fsf-ueno@gnu.org> Message-ID: <87ble5xbs0.fsf@gnu.org> Hi Daiki, Daiki Ueno skribis: > Ludovic Court?s writes: > >> This is because Guile >= 3.0.1 and >= 2.2.7 changes the GMP allocation >> functions such that they go through libgc?. As a result, libgc may >> reuse that memory when it becomes unreachable from its point of view; in >> this case, since GnuTLS structures are not scanned by libgc, libgc >> doesn?t ?see? pointers to those bignums and thus considers they are no >> longer reachable. > > That's interesting, though I might not follow completely. > >> ? In Guile-GnuTLS, arrange so that GnuTLS allocations are made through >> libgc. Unfortunately, ?gnutls_global_set_mem_functions? was >> deprecated in GnuTLS 3.3.0 so this doesn?t look like an option. > > GnuTLS doesn't call mp_set_memory_functions, so even if it is possible, > I doubt that it would affect the current behavior. What happens currently is that data structures allocated by GnuTLS are not scanned by the GC; thus, when those data structures refer to an ?mpz_t?, the GC doesn?t ?see? those references. If we could arrange so that GnuTLS allocates via libgc, those ?mpz_t? references would become visible to the GC, which would solve this issue. Would it be an option? > On the other hand, if GnuTLS (or Nettle) internally allocates an > mpz_t, it should be done using the libgc-backed allocator set by Guile > and the pointers should be reachable until it is no longer, if I > understand correctly. Therefore, I suspect that there might be some > code that confuses libgc to track the pointers; one thing that comes > to my mind is a manual copy of mpz_t values: > https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L141 > > If you replace memcpy with mpz_init_set, does it work? I tried the patch below but it doesn?t help. Thanks for taking a look! Ludo?. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/x-patch Size: 465 bytes Desc: not available URL: From ametzler at bebt.de Sat Jan 16 18:27:30 2021 From: ametzler at bebt.de (Andreas Metzler) Date: Sat, 16 Jan 2021 18:27:30 +0100 Subject: [gnutls-help] Bug#964284: Bug#964284: guile-gnutls: update to use guile 3.0 In-Reply-To: <87v9cjxupe.fsf-ueno@gnu.org> References: <87v9j2204s.fsf@ponder> <877dpymybw.fsf@yucca> <87czzm2ehb.fsf@gnu.org> <87lfe83heg.fsf@trouble.defaultvalue.org> <87a6uoutgn.fsf@gnu.org> <87blem41jz.fsf@gnu.org> <87v9j2204s.fsf@ponder> <87v9cjxupe.fsf-ueno@gnu.org> Message-ID: On 2020-12-30 Daiki Ueno wrote: > Ludovic Court?s writes: [...] > > ? In Guile-GnuTLS, arrange so that GnuTLS allocations are made through > > libgc. Unfortunately, ?gnutls_global_set_mem_functions? was > > deprecated in GnuTLS 3.3.0 so this doesn?t look like an option. > GnuTLS doesn't call mp_set_memory_functions, so even if it is possible, > I doubt that it would affect the current behavior. On the other hand, > if GnuTLS (or Nettle) internally allocates an mpz_t, it should be done > using the libgc-backed allocator set by Guile and the pointers should be > reachable until it is no longer, if I understand correctly. Therefore, > I suspect that there might be some code that confuses libgc to track the > pointers; one thing that comes to my mind is a manual copy of mpz_t > values: > https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L141 > If you replace memcpy with mpz_init_set, does it work? Stupid question: That suggestion is about using mpz_init_set instead of memcpy for all of these initializations, not just for the specific one in the specific function? cu Andreas -- `What a good friend you are to him, Dr. Maturin. His other friends are so grateful to you.' `I sew his ears on from time to time, sure'