Skip to content

Commit 1afbdca

Browse files
tomyouyoumichaelklishin
authored andcommitted
CQ: 'handle_cast(init, State) ' may cause exceptions
In the init_it2 function, when returning stop with none 'From'. This will result in the following exceptions: 2025-06-28 16:01:15.636 [error] <0.1306.0> crasher:, initial call: rabbit_amqqueue_process:init/1, pid: <0.1306.0>, registered_name: [], exception exit: {bad_return_value, {stop,normal, {existing, {amqqueue, {resource,<<"/">>,queue,<<"q13">>}, false,false,none, [{<<"x-queue-type">>,longstr, <<"classic">>}], <14981.1295.0>,[],[],[],undefined, undefined,[],[],live,0,[],<<"/">>, #{user => <<"rabbit_inside_user">>, system_creation => 1751098305370332559, recover_on_declare => true, creator =>, {1751099091,"10.225.80.5",50046, "none"}, last_system_creation =>, 1751096873022515385}, rabbit_classic_queue,#{}}}, {q,{amqqueue, {resource,<<"/">>,queue,<<"q13">>}, false,false,none, [{<<"x-queue-type">>,longstr, <<"classic">>}], <0.1306.0>,[],[],[],undefined,undefined,[], [],crashed,0,[],<<"/">>, #{user => <<"rabbit_inside_user">>, system_creation => 1751096873022515385, recover_on_declare => false, creator =>, {1751097374,"10.225.80.5",56254, "none"}, recover_vsn => 0, zretarts => [-576459962]}, rabbit_classic_queue,#{}}, none,false,undefined,undefined, {state, {queue,[],[],0}, {active,-576459961468389,1.0}, []}, undefined,undefined,undefined,undefined, {state,none,30000,undefined}, #{},undefined,undefined,undefined, {state,#{},delegate}, undefined,undefined,undefined,undefined, 'drop-head',0,0,running,false,0,undefined, <<"/">>,undefined,0,false,0,undefined,0,0,0,[], undefined,0,0,0,0,true}}}, in function gen_server2:terminate/3 (gen_server2.erl, line 1172), ancestors: [<0.1089.0>,<0.511.0>,<0.471.0>,<0.470.0>, rabbit_vhost_sup_sup,rabbit_sup,<0.250.0>], message_queue_len: 0, messages: [], links: [<0.1089.0>], dictionary: [{virtual_host,<<"/">>}, {rand_seed, {#{max => 288230376151711743,type => exsplus, next => #Fun<rand.5.65977474>, jump => #Fun<rand.3.65977474>}, [134188285183854767|82006587006243019]}}, {debug_openv_dt_cfg,{1751097655,[1]}}, {process_name, {rabbit_amqqueue_process, {resource,<<"/">>,queue,<<"q13">>}}}], trap_exit: true, status: running, heap_size: 28690, stack_size: 28, reductions: 46062, neighbours:, (cherry picked from commit e6ec4df)
1 parent 2387fdc commit 1afbdca

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

deps/rabbit/src/rabbit_amqqueue_process.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ init_it(Recover, From, State = #q{q = Q0}) ->
205205
State#q{backing_queue = BQ, backing_queue_state = BQS}}}
206206
end.
207207

208+
stop_for_init(none, {Operation, Reason, _Reply, State}) ->
209+
{Operation, Reason, State};
210+
stop_for_init(_From, Result) ->
211+
Result.
212+
208213
init_it2(Recover, From, State = #q{q = Q,
209214
backing_queue = undefined,
210215
backing_queue_state = undefined}) ->
@@ -229,16 +234,16 @@ init_it2(Recover, From, State = #q{q = Q,
229234
fun() -> emit_stats(State1) end),
230235
noreply(State1);
231236
false ->
232-
{stop, normal, {existing, Q1}, State}
237+
stop_for_init(From, {stop, normal, {existing, Q1}, State})
233238
end;
234239
{error, timeout} ->
235240
Reason = {protocol_error, internal_error,
236241
"Could not declare ~ts on node '~ts' because the "
237242
"metadata store operation timed out",
238243
[rabbit_misc:rs(amqqueue:get_name(Q)), node()]},
239-
{stop, normal, Reason, State};
244+
stop_for_init(From, {stop, normal, Reason, State});
240245
Err ->
241-
{stop, normal, Err, State}
246+
stop_for_init(From, {stop, normal, Err, State})
242247
end.
243248

244249
recovery_status(new) -> {no_barrier, new};

0 commit comments

Comments
 (0)