Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined behaviour in Cola2Session and Command? #144

Open
mlederhi opened this issue Oct 24, 2023 · 2 comments
Open

Undefined behaviour in Cola2Session and Command? #144

mlederhi opened this issue Oct 24, 2023 · 2 comments

Comments

@mlederhi
Copy link

From looking at the code I saw the following two things:

Could it be that the mutex of a command is locked in thread A when Cola2Session::sendTelegramAndListenForAnswer is called, and then unlocked in thread B (ASIO io service thread) when Cola2Session::processPacket is called when the answer is received? If this is the case, then this is undefined behavior.

Also what happens, when a command is sent, and no answer is received (because of some error). Is the mutex then never unlocked?

@puck-fzi
Copy link
Collaborator

Hi, thanks for spotting this. I think you are correct with the undefined behavior. It should not occur that the unlock will be triggered before the lock; however, you are correct that it's undefined behavior in the current version.

And for the second part, yes, it would lock permanently currently, so maybe a timeout would be beneficial.

@mlederhi
Copy link
Author

Maybe you can use something like pull request #145 to address the first problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants