Skip to content

Possible race condition in umask? #2610

Description

@chengguizi

Problem Description

We are currently experiencing seeminly race condition issues, where sometime exactly 1 of all the /dev/shm/ecal_ files has the permission set to 644 instead of 666.

It typically happens when we run with sudo which default to have umask 0002.

We are using 6.0.1 eCAL. I have inspect the source code, for both 6.0.1 and latest main, I notice:

int previous_umask = umask(000); // set umask to nothing, so we can create files with all possible permission bits

umask is being called in different parts of eCAL code. and there is actually blocking calls between

const int previous_umask = ::umask(000);

and

::umask(previous_umask);

Wouldn't this create race condition where, for example we have two thread, thread1 and thread2:

thread1: ::umask(000);
thread2: ::umask(000);
thread1: ::umask(previous_umask);

thread2 ::shm_open(name.c_str(), O_RDWR | O_CREAT

thread2: ::umask(previous_umask);

the thread2 shm_open will have the wrong umask, not 000, but actually the process umask.

How to reproduce

Can't be sure.

But running pubisher in sudo privilege helps reproduction. And must be multiple topics streaming together.

How did you get eCAL?

I don't know

Environment

eCAL: 6.0.1

eCAL System Information

Ubuntu 24.04

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