Project

General

Profile

Actions

Bug #54932

closed
TB BS

crash: PeeringState::proc_lease(pg_lease_t const&)

Bug #54932: crash: PeeringState::proc_lease(pg_lease_t const&)

Added by Telemetry Bot over 4 years ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Peering
Target version:
-
Due date:
% Done:

0%

Source:
Telemetry
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(RADOS):
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-1489-g15825ec7bf
Released In:
Upkeep Timestamp:
2026-07-28T23:45:02+00:00

Description

http://telemetry.front.sepia.ceph.com:4000/d/jByk5HaMz/crash-spec-x-ray?orgId=1&var-sig_v2=941c3ef0cf8aaa22e08d18480fb6942153c4f73090616564dc1b703f77ed1c6c

Sanitized backtrace:

    PeeringState::proc_lease(pg_lease_t const&)
    PeeringState::ReplicaActive::react(MLease const&)
    boost::statechart::simple_state<PeeringState::ReplicaActive, PeeringState::Started, PeeringState::RepNotRecovering, (boost::statechart::history_mode)>::react_impl(boost::statechart::event_base const&, void const*)
    boost::statechart::simple_state<PeeringState::RepNotRecovering, PeeringState::ReplicaActive, boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, (boost::statechart::history_mode)>::react_impl(boost::statechart::event_base const&, void const*)
    boost::statechart::state_machine<PeeringState::PeeringMachine, PeeringState::Initial, std::allocator<boost::statechart::none>, boost::statechart::null_exception_translator>::process_event(boost::statechart::event_base const&)
    PG::do_peering_event(std::shared_ptr<PGPeeringEvent>, PeeringCtx&)
    OSD::dequeue_peering_evt(OSDShard*, PG*, std::shared_ptr<PGPeeringEvent>, ThreadPool::TPHandle&)
    ceph::osd::scheduler::PGPeeringItem::run(OSD*, OSDShard*, boost::intrusive_ptr<PG>&, ThreadPool::TPHandle&)
    OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*)
    ShardedThreadPool::shardedthreadpool_worker(unsigned int)
    ShardedThreadPool::WorkThreadSharded::entry()

Crash dump sample:
{
    "backtrace": [
        "/lib64/libpthread.so.0(+0x12c20) [0x7f5ea6da4c20]",
        "gsignal()",
        "abort()",
        "ceph-osd(+0x6288a8) [0x557c80c678a8]",
        "(PeeringState::proc_lease(pg_lease_t const&)+0xa2d) [0x557c80f333ad]",
        "(PeeringState::ReplicaActive::react(MLease const&)+0x6b) [0x557c80f3347b]",
        "(boost::statechart::simple_state<PeeringState::ReplicaActive, PeeringState::Started, PeeringState::RepNotRecovering, (boost::statechart::history_mode)0>::react_impl(boost::statechart::event_base const&, void const*)+0x3b0) [0x557c80f89410]",
        "(boost::statechart::simple_state<PeeringState::RepNotRecovering, PeeringState::ReplicaActive, boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, (boost::statechart::history_mode)0>::react_impl(boost::statechart::event_base const&, void const*)+0xd3) [0x557c80f88383]",
        "(boost::statechart::state_machine<PeeringState::PeeringMachine, PeeringState::Initial, std::allocator<boost::statechart::none>, boost::statechart::null_exception_translator>::process_event(boost::statechart::event_base const&)+0x5b) [0x557c80d70f6b]",
        "(PG::do_peering_event(std::shared_ptr<PGPeeringEvent>, PeeringCtx&)+0x2d1) [0x557c80d659e1]",
        "(OSD::dequeue_peering_evt(OSDShard*, PG*, std::shared_ptr<PGPeeringEvent>, ThreadPool::TPHandle&)+0x29c) [0x557c80cdfe5c]",
        "(ceph::osd::scheduler::PGPeeringItem::run(OSD*, OSDShard*, boost::intrusive_ptr<PG>&, ThreadPool::TPHandle&)+0x56) [0x557c80f0f0e6]",
        "(OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*)+0xc28) [0x557c80cd1d48]",
        "(ShardedThreadPool::shardedthreadpool_worker(unsigned int)+0x5c4) [0x557c813435b4]",
        "(ShardedThreadPool::WorkThreadSharded::entry()+0x14) [0x557c81346254]",
        "/lib64/libpthread.so.0(+0x817f) [0x7f5ea6d9a17f]",
        "clone()" 
    ],
    "ceph_version": "16.2.7",
    "crash_id": "2022-03-03T18:29:49.532173Z_f66ee0b8-00d2-4405-96ef-ca4c480b84d7",
    "entity_name": "osd.80df4f4e307d88578b7ab045e374c1d9be1c6cef",
    "os_id": "centos",
    "os_name": "CentOS Stream",
    "os_version": "8",
    "os_version_id": "8",
    "process_name": "ceph-osd",
    "stack_sig": "85a6718dd1f11ccb994e10ae15320efa563cd3c4dbbcc66193a892589f8e9398",
    "timestamp": "2022-03-03T18:29:49.532173Z",
    "utsname_machine": "x86_64",
    "utsname_release": "5.4.0-62-generic",
    "utsname_sysname": "Linux",
    "utsname_version": "#70-Ubuntu SMP Tue Jan 12 12:45:47 UTC 2021" 
}

TB Updated by Telemetry Bot over 4 years ago Actions #1

  • Crash signature (v1) updated (diff)
  • Crash signature (v2) updated (diff)
  • Affected Versions v16.2.7 added

BS Updated by Bill Scales 7 months ago Actions #2

  • Category set to Peering
  • Assignee set to Alex Ainscow

Reproduced this bug in downstream testing https://ibm-ceph.atlassian.net/browse/IBMCEPH-14316

We think this is a race hazard between two threads:

Thread 1 calls PeeringState::proc_lease which accesses std::optional fields inside struct HeartbeatStamps with code like this:

hb_stamps[0]->peer_clock_delta_ub

Thread 2 calls OSD::handle_osd_ping which calls s->stamps->got_ping which assigns a new value to the std::optional fields in the same structure

  void got_ping(epoch_t this_up_from,
                ceph::signedspan now,
                ceph::signedspan peer_send_stamp,
                std::optional<ceph::signedspan> delta_ub,
                ceph::signedspan *out_delta_ub) {
    std::lock_guard l(lock);
    if (this_up_from < up_from) {
      return;
    }
    if (this_up_from > up_from) {
      up_from = this_up_from;
    }
    peer_clock_delta_lb = peer_send_stamp - now;
    peer_clock_delta_ub = delta_ub;
    *out_delta_ub = - *peer_clock_delta_lb;
  }

It is not thread safe to have 1 thread assigning a value to a std::optional while a 2nd thread reads from it.

The got_ping function is taking a lock to protect the update, sadly proc_lease is not taking that lock.

Bug is going to be rare because its a very narrow race hazard between two threads. Consequence of the bug will be a restart of an OSD process

BS Updated by Bill Scales 5 months ago Actions #3

  • Assignee changed from Alex Ainscow to Bill Scales

BS Updated by Bill Scales 5 months ago Actions #4

  • Status changed from New to Fix Under Review
  • Pull request ID set to 70233

UB Updated by Upkeep Bot 4 months ago Actions #5

  • Status changed from Fix Under Review to Resolved
  • Merge Commit set to 15825ec7bf7cc41d3ecd77c0bda78882bd02a884
  • Fixed In set to v21.3.0-1489-g15825ec7bf
  • Upkeep Timestamp set to 2026-07-28T23:45:02+00:00
Actions

Also available in: PDF Atom