erlang/otp

Inconsistent error message from `is_process_alive`

Closed this issue · 3 comments

Describe the bug

is_process_alive/1 can raise the error "not a pid" for a value for which is_pid/1 returns true.
This happens when the pid is not local.

To Reproduce

  1. Start two nodes:
erl -sname one@localhost -setcookie hello

and

erl -sname two@localhost -setcookie hello
  1. Spawn a process on the other node to get a valid remote pid.
(one@localhost)1> Pid = spawn('two@localhost', fun() -> 'hi' end).
<10531.109.0>
  1. Attempt to work with that pid.
(one@localhost)2> is_pid(Pid).
true
(one@localhost)3> is_process_alive(Pid).
** exception error: bad argument
     in function  is_process_alive/1
        called as is_process_alive(<10531.109.0>)
        *** argument 1: not a pid

Expected behavior

The error message should say "not a local pid", or "is a remote pid", or something else that explains why it's not possible to check whether it's alive. "not a pid" is untrue and is inconsistent with the return value from is_pid/1.

Affected versions
Tested with OTP 27.0

The code that prints that value is located here. A PR improving it would be most welcome!

Somewhat related, I noticed many wrong error messages in io:format and friends lately, I'll open a separate ticket for those.

Fix merged for release in 27.1