[erlang-questions] funs versus code loading

Sam Bobroff <>
Fri May 13 09:05:15 CEST 2011

On 13 May 2011 16:08, Nahuel Greco <> wrote:

> Sam, check this thread:
> http://thread.gmane.org/gmane.comp.lang.erlang.general/47310
> Saludos,
> Nahuel Greco.
> Ah yes that seems to match exactly what I've observed!

Thanks for that :-)

I agree with your (and Matthias') comments in that it should be changed in
accordance with the patch!
In my opinion the current system is confusing and therefore dangerous.

Hmm... from poking around in the emulator code it looks like the "hash" is
made up of three components XOR'ed together:

* the index
* the module's name
* a "uniq" value

Since during code reloading, the module name and index could easily be the
same... if the uniq were the same then the emulator would be fooled into
thinking it was OK to use the new version of the code... when it was not OK.

I couldn't see what system was used to set the uniq value ("old_uniq" in
most of the code I saw)... does anyone know what it is?

Even without knowing the algorithm, if I can control the Fun's index, and I
can see it's uniq, I can probably cause a hash collision by setting the
index to a specific value.

The reason I ask is that I'm wondering if a hash collision is possible and
if that has the potential to crash the emulator.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110513/6ac168d6/attachment.html>

More information about the erlang-questions mailing list