diff options
author | Erlang/OTP <otp@erlang.org> | 2021-10-18 17:50:19 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-10-18 17:50:19 +0200 |
commit | 4b9fbdc5dc446300c7d9c1bf53f39d3c159cc5e5 (patch) | |
tree | 86fe9be4c19cd3bae7484215970c3c0789df9520 | |
parent | 92f9932a2f01686bc1db8ca9ded1c6282d9f4bac (diff) | |
parent | 2be04f53570066031c4fc152aa14798dc38c0403 (diff) | |
download | erlang-4b9fbdc5dc446300c7d9c1bf53f39d3c159cc5e5.tar.gz |
Merge branch 'rickard/receive-bad-timeout-fix/OTP-17651' into maint-22
* rickard/receive-bad-timeout-fix/OTP-17651:
Restore save pointer on bad timeout value in receive
-rw-r--r-- | erts/emulator/beam/msg_instrs.tab | 2 | ||||
-rw-r--r-- | erts/emulator/test/receive_SUITE.erl | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/erts/emulator/beam/msg_instrs.tab b/erts/emulator/beam/msg_instrs.tab index 10fd5ad48d..7056bbc95b 100644 --- a/erts/emulator/beam/msg_instrs.tab +++ b/erts/emulator/beam/msg_instrs.tab @@ -305,6 +305,7 @@ timeout() { TIMEOUT_VALUE() { c_p->freason = EXC_TIMEOUT_VALUE; + JOIN_MESSAGE(c_p); goto find_func_info; //| -no_next } @@ -372,6 +373,7 @@ wait.src(Src) { } else { /* Wrong time */ erts_proc_unlock(c_p, ERTS_PROC_LOCKS_MSG_RECEIVE); c_p->freason = EXC_TIMEOUT_VALUE; + JOIN_MESSAGE(c_p); goto find_func_info; } } diff --git a/erts/emulator/test/receive_SUITE.erl b/erts/emulator/test/receive_SUITE.erl index 339507c9d8..d42db517c2 100644 --- a/erts/emulator/test/receive_SUITE.erl +++ b/erts/emulator/test/receive_SUITE.erl @@ -28,7 +28,8 @@ call_with_huge_message_queue/1,receive_in_between/1, receive_opt_exception/1,receive_opt_recursion/1, receive_opt_deferred_save/1, - erl_1199/1]). + erl_1199/1, + gh_5235_missing_save_reset/1]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -40,7 +41,8 @@ all() -> receive_opt_exception, receive_opt_recursion, receive_opt_deferred_save, - erl_1199]. + erl_1199, + gh_5235_missing_save_reset]. init_per_testcase(receive_opt_deferred_save, Config) -> case erlang:system_info(schedulers) of @@ -396,10 +398,36 @@ erl_1199_flush_blipp() -> ok end. +gh_5235_missing_save_reset(Config) when is_list(Config) -> + %% + %% Used to hang in the second receive due to save + %% pointer not being reset on bad timeout value... + %% + ct:timetrap({seconds, 10}), + id(self()) ! init, + try + receive blipp -> ok after blupp -> ok end + catch _:_ -> + ok + end, + receive init -> ok end, + + %% Try with a timeout value not known in compile + %% time as well... + id(self()) ! init2, + try + receive blapp -> ok after id(blepp) -> ok end + catch _:_ -> + ok + end, + receive init2 -> ok end. + %%% %%% Common helpers. %%% +id(X) -> X. + echo_loop() -> receive {Ref,{Pid,Msg}} -> |