Skip to content

Commit c23ded5

Browse files
tomyouyoumergify[bot]
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) (cherry picked from commit 1afbdca)
1 parent be3aa5b commit c23ded5

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
@@ -202,6 +202,11 @@ init_it(Recover, From, State = #q{q = Q0}) ->
202202
State#q{backing_queue = BQ, backing_queue_state = BQS}}}
203203
end.
204204

205+
stop_for_init(none, {Operation, Reason, _Reply, State}) ->
206+
{Operation, Reason, State};
207+
stop_for_init(_From, Result) ->
208+
Result.
209+
205210
init_it2(Recover, From, State = #q{q = Q,
206211
backing_queue = undefined,
207212
backing_queue_state = undefined}) ->
@@ -226,16 +231,16 @@ init_it2(Recover, From, State = #q{q = Q,
226231
fun() -> emit_stats(State1) end),
227232
noreply(State1);
228233
false ->
229-
{stop, normal, {existing, Q1}, State}
234+
stop_for_init(From, {stop, normal, {existing, Q1}, State})
230235
end;
231236
{error, timeout} ->
232237
Reason = {protocol_error, internal_error,
233238
"Could not declare ~ts on node '~ts' because the "
234239
"metadata store operation timed out",
235240
[rabbit_misc:rs(amqqueue:get_name(Q)), node()]},
236-
{stop, normal, Reason, State};
241+
stop_for_init(From, {stop, normal, Reason, State});
237242
Err ->
238-
{stop, normal, Err, State}
243+
stop_for_init(From, {stop, normal, Err, State})
239244
end.
240245

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

0 commit comments

Comments
 (0)