Re: Garbage collection of remote references

Dániel Szoboszlay <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CADcfxo=ohzuD_zfYThTA8KmRaMbiaimKHHJDnLvF+42Rh_v8Bw@mail.gmail.com>
Hi Ludovic,

As far as I know references themselves are stored as regular data on the
heap, and can be garbage collected. However, references (and pids) also
contain
<https://erlang.org/doc/apps/erts/erl_ext_dist.html#new_reference_ext> the
node on which they were created (an atom). So I believe the documentation
wants to warn you that decoding a reference may also create an atom in your
atom table (plus also an entry in the node name to "first number in a pid"
mapping table, which probably has an official name). which will not be
garbage collected. The reference itself will be.

Hope it helps,
Daniel

On Fri, 15 Oct 2021 at 12:24, Ludovic Demblans <[email protected]> wrote:

> Hello,
>
> I can read the following in the binary_to_term documentation:
>
>      When decoding binaries from untrusted sources, the untrusted source
> may submit
>      data in a way to create resources, such as atoms and remote
> references, that
>      cannot be garbage collected and lead to Denial of Service attack. In
> such
>      cases, consider using binary_to_term/2 with the safe option.
>
>
> I use binary serialized remote references to dispatch messages received
> from an
> external source (Kafka) to the right process in the right node.  Those
> references are process aliases with the reply option.
>
> Reading the docs, should I understand that each reference will stay
> forever
> in memory after being used to send a message?
>
> I am also looking for more docs on that topic, I couldn't find much.
>
> Thank you.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.