bug in register/2 BIF

Ulf Wiger (AL/EAB) <>
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 

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

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. "


More information about the erlang-questions mailing list