Skip to content

Race Condition while clean up of pools #915

Description

@manav-yb

Hi Team,

I'm witnessing a crash of odyssey process in one of my workloads. I'm using a bit older version of odyssey. I'm attaching below the stack trace.

thread #1, name = 'odyssey', stop reason = signal SIGSEGV
frame #0: 0x00005e30f8887c6f odysseyod_backend_connect(server=0x000032bc7e014380, context="", route_params=0x0000000000000000, client=0x000032bc7da72c00) at backend.c:815:19 frame #1: 0x00005e30f888580e odysseyod_frontend_attach(client=0x000032bc7da72c00, context="", route_params=0x0000000000000000) at frontend.c:305:8
frame #2: 0x00005e30f8881b11 odysseyod_frontend_remote [inlined] od_frontend_attach_and_deploy(client=0x000032bc7da72c00, context=<unavailable>) at frontend.c:361:11 frame #3: 0x00005e30f8881afe odysseyod_frontend_remote(client=0x000032bc7da72c00) at frontend.c:2120:13
frame #4: 0x00005e30f887dd65 odysseyod_frontend(arg=0x000032bc7da72c00) at frontend.c:2756:12 frame #5: 0x00005e30f88a6912 odysseymm_scheduler_main(arg=0x000032bc7e7cf900) at scheduler.c:17:2
frame #6: 0x00005e30f88a6b77 odyssey`mm_context_runner at context.c:28:2

The top of the threads points to: storage = route->rule->storage; used in od_router_gc_cb() function.

I'm suspecting it's happening due to a race condition on how rule field of route object is been unref https://github.com/yandex/odyssey/blob/0856d66419d8cc0a3328fa92f3d463323a55cb22/sources/router.c#L313.
`od_route_unlock(route);

/* unref route rule and free route object */
od_rules_unref(route->rule);
od_route_free(route);`

It releases the lock before doing unref and freeing the route->rule and route object respectively. What if any other worker thread is accessing route->rule after it's been unref in above code after the lock has been released.

I wanted to confirm, have you guys faced such issue in past or any fixes been done in order to handle the above scenario.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions