bug in register/2 BIF

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Mon Dec 20 11:43:42 CET 2004


This bug was introduced in OTP R8B, I believe.

According to the manual for register(), you should get
exit (badarg) if the given process is not active. This
was true in OTP R7B, but isn't anymore (I've tried it 
on R7B, R8B, R9B, R9C and R10B.) If the P is not 
alive (but a local pid), register(Name, P) always 
returns true.

One really interesting characteristic of this bug is 
this:

1> Dead = spawn(fun() -> true end).
<0.39.0>
2> register(foo, self()).
true
3> register(foo,Dead).
true

This is what the manual says:

"register(Name, P)
Associates the name Name with the port or pid P. Name, which 
must be an atom, can be used instead of a port or pid in the 
send operator (Name ! Message). 
Returns true. 
Failure: badarg if P is not an active port or process, if P 
is on another node, if Name is already in use, if the port 
or process is already registered (already has a name), if 
Name is not an atom, or if Name is the atom undefined. "


/Uffe



More information about the erlang-questions mailing list