GNU bug report logs - #73199
url-retrieve is not thread-safe

Previous Next

Package: emacs;

Reported by: Michael Albinus <michael.albinus <at> gmx.de>

Date: Thu, 12 Sep 2024 14:21:02 UTC

Severity: normal

Fixed in version 31.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: AlexHarsanyi <at> gmail.com, fitzsim <at> fitzsim.org, monnier <at> iro.umontreal.ca, 73199 <at> debbugs.gnu.org
Subject: bug#73199: url-retrieve is not thread-safe
Date: Wed, 02 Oct 2024 18:34:55 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Michael Albinus <michael.albinus <at> gmx.de>
>> Cc: 73199 <at> debbugs.gnu.org,  AlexHarsanyi <at> gmail.com,  fitzsim <at> fitzsim.org,
>>   monnier <at> iro.umontreal.ca
>> Date: Mon, 30 Sep 2024 18:42:55 +0200
>>
>> Oops, sorry. I've appended the vc-dir buffer, not the vc-diff ...
>
> Thanks.  I'd appreciate if you could explain why url-retrieve is
> currently not thread-safe, and how this patch is supposed to solve
> that.

In <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73199#14>, there's a
recipe for reproduction.

The general problem is when you want to access the same HTTP server from
a different thread, and url-http-attempt-keepalives is set to t. This
happens, for example, in debbugs 0.41.

Let's assume, there is an access to debbugs:443 from a given thread, for
example the main thread. Soap-client serves. It also binds
url-http-attempt-keepalives to t, the https process stays alive.

Later on, there is an access to debbugs:443 from another thread. It
checks, whether there is a running process for that target, and tries to
reuse. We get the error

--8<---------------cut here---------------start------------->8---
Error #<thread debbugs>: (error "Attempt to accept output from process debbugs.gnu.org locked to thread #<thread 0xc288a0>")
--8<---------------cut here---------------end--------------->8---

My patch tries to fix this. The list of still open processes is the hash
table url-http-open-connections. It has the ky (cons host port), and as
value a list of processes.

My patch changes this such a way, that the key is now (list host port
thread). Therefore, only open processes which belong to the same thread
are checked.

This seems to work sufficiently.

Best regards, Michael.




This bug report was last modified 260 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.