codership/galera

Infinite recursion in TrxHandle::print_state for unknown state

wdoekes opened this issue · 3 comments

See this:

(gdb) bt -32
#12203 0x00007f21fd17c2e8 in galera::TrxHandle::print_state (os=..., s=634168720) at /usr/include/c++/9/bits/char_traits.h:335
#12204 0x00007f21fd17c11e in galera::operator<< (os=..., s=s@entry=634168720) at galera/src/trx_handle.cpp:52
#12205 0x00007f21fd17c2e8 in galera::TrxHandle::print_state (os=..., s=634168720) at /usr/include/c++/9/bits/char_traits.h:335
#12206 0x00007f21fd17c11e in galera::operator<< (os=..., s=s@entry=634168720) at galera/src/trx_handle.cpp:52
#12207 0x00007f21fd17c2e8 in galera::TrxHandle::print_state (os=..., s=634168720) at /usr/include/c++/9/bits/char_traits.h:335
#12208 0x00007f21fd17c11e in galera::operator<< (os=..., s=<optimized out>) at galera/src/trx_handle.cpp:52
#12209 0x00007f21fd17c36f in galera::TrxHandle::print_state_history (this=this@entry=0x7f1e1408ee70, os=...) at /usr/include/c++/9/bits/stl_vector.h:1058
#12210 0x00007f21fd17c731 in galera::TrxHandle::print (os=..., this=0x7f1e1408ee70) at galera/src/trx_handle.cpp:84
#12211 galera::TrxHandleSlave::print (this=this@entry=0x7f1e1408ee70, os=...) at galera/src/trx_handle.cpp:96
#12212 0x00007f21fd17c914 in galera::operator<< (os=..., th=...) at galera/src/trx_handle.cpp:127
#12213 0x00007f21fd1928fa in check_against<(wsrep_key_type)2> (found=found@entry=0x7f1875ec5680, key=..., key_type=key_type@entry=WSREP_KEY_UPDATE, trx=trx@entry=0x7f1e1404fe70, log_conflict=log_conflict@entry=true, depends_seqno=@0x7f1e1c8a1be8: 971072699)
    at /usr/include/c++/9/bits/char_traits.h:335
#12214 0x00007f21fd18f07c in certify_and_depend_v3to5 (log_conflict=<optimized out>, trx=0x7f1e1404fe70, key=..., found=<optimized out>) at galera/src/certification.cpp:411
#12215 certify_v3to5 (log_conflicts=<optimized out>, store_keys=true, trx=0x7f1e1404fe70, key=..., cert_index_ng=...) at galera/src/certification.cpp:280
#12216 galera::Certification::do_test_v3to5 (this=0x560bf21ae920, trx=0x7f1e1404fe70, store_keys=true) at galera/src/certification.cpp:379
#12217 0x00007f21fd1916b8 in galera::Certification::do_test (this=0x560bf21ae920, trx=..., store_keys=<optimized out>) at galera/src/certification.cpp:491
#12218 0x00007f21fd19196b in galera::Certification::test (this=<optimized out>, trx=..., store_keys=<optimized out>) at galera/src/certification.cpp:1132
#12219 0x00007f21fd191a1c in galera::Certification::append_trx (this=this@entry=0x560bf21ae920, trx=...) at galera/src/certification.cpp:1235
#12220 0x00007f21fd1c9d04 in galera::ReplicatorSMM::finish_cert (this=this@entry=0x560bf21add70, trx=trx@entry=0x0, ts=...) at galera/src/replicator_smm.cpp:3309
#12221 0x00007f21fd1c9ec5 in galera::ReplicatorSMM::cert (ts=..., trx=0x0, this=0x560bf21add70) at galera/src/replicator_smm.cpp:3389
#12222 galera::ReplicatorSMM::cert_and_catch (this=0x560bf21add70, trx=0x0, ts=...) at galera/src/replicator_smm.cpp:3400
#12223 0x00007f21fd1cabc1 in galera::ReplicatorSMM::process_trx (this=0x560bf21add70, recv_ctx=0x7f1e1c8a2cf0, ts_ptr=...) at galera/src/replicator_smm.cpp:2091
#12224 0x00007f21fd19cc43 in galera::GcsActionSource::process_writeset (this=0x560c0b8fd4c0, recv_ctx=0x7f1e1c8a2cf0, act=..., exit_loop=@0x7f1e1c8a28ef: false) at galera/src/gcs_action_source.cpp:62
#12225 0x00007f21fd19d60b in galera::GcsActionSource::dispatch (this=<optimized out>, recv_ctx=<optimized out>, act=..., exit_loop=<optimized out>) at galera/src/gcs_action_source.cpp:110
#12226 0x00007f21fd19d812 in galera::GcsActionSource::process (this=0x560c0b8fd4c0, recv_ctx=0x7f1e1c8a2cf0, exit_loop=@0x7f1e1c8a28ef: false) at galera/src/gcs_action_source.cpp:183
#12227 0x00007f21fd1c7c40 in galera::ReplicatorSMM::async_recv (this=0x560bf21add70, recv_ctx=0x7f1e1c8a2cf0) at galera/src/replicator_smm.cpp:390
#12228 0x00007f21fd1e41d1 in galera_recv (gh=<optimized out>, recv_ctx=<optimized out>) at galera/src/wsrep_provider.cpp:236
#12229 0x0000560bf0c7c532 in wsrep::wsrep_provider_v26::run_applier (this=<optimized out>, applier_ctx=<optimized out>) at ./wsrep-lib/src/wsrep_provider_v26.cpp:740
#12230 0x0000560bf06386f3 in wsrep_replication_process (thd=0x7f1880000c48, arg=<optimized out>) at ./wsrep-lib/include/wsrep/server_state.hpp:308
#12231 0x0000560bf062a34c in start_wsrep_THD (arg=arg@entry=0x560c28988cd0) at ./sql/wsrep_mysqld.h:421
#12232 0x0000560bf0bace56 in pfs_spawn_thread (arg=0x560c28988cf8) at ./storage/perfschema/pfs.cc:1869
#12233 0x00007f222562c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#12234 0x00007f2224e00293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Faulty code:

void galera::TrxHandle::print_state(std::ostream& os, TrxHandle::State s)

os << "<unknown TRX state " << s << ">";
assert(0);
}
std::ostream& galera::operator<<(std::ostream& os, TrxHandle::State const s)
{
galera::TrxHandle::print_state(os, s);
return os;
}

No known state s found, so add

  • "<unknown TRX state " and then a readable representation of state s, which becomes
  • "<unknown TRX state " and then a readable representation of state s, which becomes
  • ...

Suggested fix: cast state s to an int, like is done in the 3.x branch:

gu_throw_fatal << "invalid state " << static_cast<int>(s);

Do you want a PR for this?

temeo commented

Do you want a PR for this?

We will make the corresponding change along with #606 fix, so PR is not necessary.

temeo commented

Fixed in 4.11