develooper Front page | perl.perl5.porters | Postings from September 2017

Re: [perl #132142] Bleadperl v5.27.3-34-gf6107ca24b breaksMLEHMANN/AnyEvent-HTTP-2.23.tar.gz

Thread Previous | Thread Next
September 22, 2017 02:12
Re: [perl #132142] Bleadperl v5.27.3-34-gf6107ca24b breaksMLEHMANN/AnyEvent-HTTP-2.23.tar.gz
Message ID:
(Andreas J. Koenig) (via RT) <> writes:

> bisect
> ------
> commit f6107ca24b4cf22dcf7fd69d65612ad718c48fca
> Author: Dagfinn Ilmari Mannsåker <>
> Date:   Wed Aug 30 22:35:17 2017 +0100
>     Strengthen weak refs when sorting in-place
> diagnostics
> -----------

AnyEvent is relying on in-place sorting of its array of pending timers
keeping the references weak, and when it doesn't, user code can't cancel
a timer by dropping its reference to it.

Weakening all the references in the array after sorting it fixes the
issue, but that only works for arrays where all the references are weak.
If an array has a mix of strong and weak references one would have to
record which references were weak before the sort, and then go through
the sorted array and re-weaken them afterwards.

With the old behaviour, getting the strengthening effect was trivial:
one could assign the array to itself before or after the sort, or defeat
the in-place sort altogether with the =()= trick.

This makes me think that despite all the work that's gone into making
the in-place sort optimisation invisible, the weak ref special case
needs to be kept, i.e. the above commit reverted.

I still think sv_rvunweaken() is a useful API function, so the commit
that added that should be kept.

- ilmari
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About