diagnostics icon indicating copy to clipboard operation
diagnostics copied to clipboard

FrequencyStatusParam is not thread safe

Open progtologist opened this issue 9 years ago • 4 comments

The Struct is storing pointers to the min_freq_ and max_freq_ that are being accessed from the FrequencyStatus class using scoped_locks protecting only the object itself but not the data that can be altered using the struct. Also, the data are not checked prior being dereferenced, but I guess this is not as important since it will most likely cause problems at the start time compared to the thread safety issue that could cause problems at any point of the lifetime of the application.

progtologist avatar Oct 24 '16 14:10 progtologist

Hrm; that does seem like it's a potential issue, but I think it would be incredibly difficult to actually hit it. Is it causing trouble for you? Do you have a reproducible test case that exploits it?

The API has been like this for about 6 or 7 years, and at this point it is very widely used, so we should think carefully about compatibility before introducing changes.

I'm happy to accept a fix for this, particularly if it includes a test cases that exercises the issue.

trainman419 avatar Oct 25 '16 20:10 trainman419

I wouldn't really expect many scenarios where this can be exploited, since I doubt many users have actually changed the value of min_freq_ and max_freq_ dynamically at runtime.

However, I am currently developing a nodelet that would actually need this functionality for a production environment and I am having second thoughts on using it. The possibility of a segmentation fault is there and could cause crashes on the whole system.

I could propose a fix, but that would have to break the API, would this be acceptable?

progtologist avatar Oct 25 '16 23:10 progtologist

An alternative API with a copy could be added to not break backwards compatibility.

tfoote avatar Oct 26 '16 01:10 tfoote

I will develop this functionality and make a PR to further discuss on this.

progtologist avatar Oct 28 '16 19:10 progtologist

Probably outdated. If still present, please open a new issue or raise a PR.

ralph-lange avatar Nov 21 '22 13:11 ralph-lange