[erlang-patches] [PATCH] erts: fix error handling in bif erlang:start_timer/3

Jovi Zhang bookjovi@REDACTED
Wed Dec 28 08:56:56 CET 2011


>From 18612f43f0c8a6f217806c22c9f9bec8b0de4b26 Mon Sep 17 00:00:00 2001
From: Jovi Zhang <bookjovi@REDACTED>
Date: Wed, 21 Dec 2011 03:26:03 +0800
Subject: [PATCH] erts: fix error handling in bif erlang:start_timer/3

See below, When recevier pid is non-exist, start_timer/3 return a
valid internal Ref, this is wrong, erlang should return badarg instead.

Eshell V5.9  (abort with ^G)
1> A = erlang:start_timer(100*1000, pid(0, 9999, 0), {none}).
Ref<0.0.0.29>
2> erlang:read_timer(A).
false
3>
---
erts/emulator/beam/erl_bif_timer.c |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/erts/emulator/beam/erl_bif_timer.c
b/erts/emulator/beam/erl_bif_timer.c
index a922a33..7bd2b8e 100644
--- a/erts/emulator/beam/erl_bif_timer.c
+++ b/erts/emulator/beam/erl_bif_timer.c
@@ -414,7 +414,7 @@ setup_bif_timer(Uint32 xflags,
       rp = erts_pid2proc(c_p, ERTS_PROC_LOCK_MAIN,
                          receiver, ERTS_PROC_LOCK_MSGQ);
       if (!rp)
-           return ref;
+           return THE_NON_VALUE;
    }

    if (timeout < ERTS_ALC_MIN_LONG_LIVED_TIME) {
--
1.7.2.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-erts-fix-error-handling-in-bif-erlang-start_timer-3.patch
Type: application/octet-stream
Size: 1061 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20111228/8424e6e0/attachment.obj>


More information about the erlang-patches mailing list