otp icon indicating copy to clipboard operation
otp copied to clipboard

Monitor 'DOWN' message doesn't contain custom tag in some cases

Open Yozhig opened this issue 2 years ago • 1 comments

Describe the bug Monitor created by registered name which is actually not registered at the moment of monitor creation results in 'DOWN' message without specified custom tag.

To Reproduce

$ erl
Erlang/OTP 25 [erts-13.0.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Eshell V13.0.3  (abort with ^G)
1> erlang:monitor(process, some_absent_registered_name, [{tag, custom}]).
#Ref<0.2127597027.1768947713.127398>
2> flush().
Shell got {'DOWN',#Ref<0.2127597027.1768947713.127398>,process,
                  {some_absent_registered_name,nonode@nohost},
                  noproc}
ok
3> erlang:monitor(process, c:pid(0,999,999), [{tag, custom}]).
#Ref<0.2127597027.1768947719.127544>
4> flush().
Shell got {custom,#Ref<0.2127597027.1768947719.127544>,process,<0.999.999>,
                  noproc}
ok

Expected behavior Monitor 'DOWN' message should contain specified custom tag as with monitor created by pid.

Affected versions At least 24.2.1 and 25.0.3

Yozhig avatar Jul 29 '22 14:07 Yozhig

Thanks for the bug report! I've made a fix in the #6209 PR (not very well tested yet). The fix will be part of the next patch unless something unexpected happens. Besides the lost custom tag also the alias option was lost. This since monitor() "cheated" by sending a DOWN message directly instead of creating the monitor when the target process or port did not exist.

rickard-green avatar Aug 10 '22 14:08 rickard-green

Fixed in patches OTP 25.0.4 and OTP 24.3.4.3 which we released today.

rickard-green avatar Aug 18 '22 19:08 rickard-green