Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
4742-kernel-Fix-group-to-not-crash-if-group_his...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4742-kernel-Fix-group-to-not-crash-if-group_history-fails.patch of Package erlang
From 172a15ce1d13efe256a3d93b6ef279e59cdcf481 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Tue, 23 Apr 2024 21:14:04 +0200 Subject: [PATCH 2/2] kernel: Fix group to not crash if group_history fails There used to be a bug where the AC would block and set_env would crash. This caused the shell to be unuseable as it crashed all the time. So we add some safe guards to make sure that does not happen again. --- lib/kernel/src/group.erl | 9 ++++++++- lib/kernel/src/group_history.erl | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/kernel/src/group.erl b/lib/kernel/src/group.erl index 44ac1c4097..1792ffe2fb 100644 --- a/lib/kernel/src/group.erl +++ b/lib/kernel/src/group.erl @@ -19,6 +19,8 @@ %% -module(group). +-include_lib("kernel/include/logger.hrl"). + %% A group leader process for user io. -export([start/2, start/3, server/4]). @@ -1005,7 +1007,12 @@ save_line_buffer("\n", Lines) -> save_line_buffer(Line, [Line|_Lines]=Lines) -> save_line_buffer(Lines); save_line_buffer(Line, Lines) -> - group_history:add(Line), + try + group_history:add(Line) + catch E:R:ST -> + ?LOG_ERROR(#{ msg => "Failed to write to shell history", + error => {E, R, ST} }) + end, save_line_buffer([Line|Lines]). save_line_buffer(Lines) -> diff --git a/lib/kernel/src/group_history.erl b/lib/kernel/src/group_history.erl index 7738a2155e..f770a85a90 100644 --- a/lib/kernel/src/group_history.erl +++ b/lib/kernel/src/group_history.erl @@ -374,7 +374,10 @@ find_path() -> to_drop() -> case application:get_env(kernel, shell_history_drop) of undefined -> - application:set_env(kernel, shell_history_drop, ?DEFAULT_DROP), + %% The AC might be overloaded/not responding and + %% we want the shell to be as responsive as possible + %% so we set a short timeout + application:set_env(kernel, shell_history_drop, ?DEFAULT_DROP, [{timeout, 10}]), ?DEFAULT_DROP; {ok, V} when is_list(V) -> [Ln++"\n" || Ln <- V]; {ok, _} -> ?DEFAULT_DROP -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor