-
Notifications
You must be signed in to change notification settings - Fork 477
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
loggen: fix crash with invalid parameterization #3146
Conversation
../bin/loggen -S --active-connections=10 -I 120 caused crash in loggen, because mandatory parameters were not passed. The reason is even if a module cannot start, stop was still called. In our specific case, thread_array was accessed in stop, even though it was not initialized in start (because start returned earlier due to error). The fix is that start returns boolean now. Stop is only called a plugin is started. Signed-off-by: Antal Nemes <[email protected]>
Signed-off-by: Antal Nemes <[email protected]>
Signed-off-by: Antal Nemes <[email protected]>
Build FAILURE |
@kira-syslogng retest this please |
Build SUCCESS |
In general I like these changes. I know that we (currently) allow only one plugin to be active at a time so your changes are correct. If in the future we will allow to run more than one plugin your change might cause plugins not stopped if other plugins were not started successfully. So I suggest to prepare the plugin's stop function to handle the situation when a plugin was not activated and call all plugin's stop function every time. As I see the crash caused by the missing thread_array so I simple check for this can avoid the crash in the stop function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach better with explicitly stating that 0 plugin started.
In case of multiple plugins will be needed, this will be modified.
@norberttak I was thinking about the alternative of making the stop non-start safe. In the end I opted for not calling stop when a plugin was not started because I felt that the other version would induce some implementation requirements/architectural complexity that we are not used to, or inconvenient. For example:
It may, but I have a little doubts. At least not in the near future. For any usecase that I can think of, we can always start more loggen instances. On the other hand, having a controller node over multiple active plugins has it's own challenges.
Technically all these can be implemented with some effort. But as most of these questions can be avoided by executing multiple loggen instances in parallel, I think the implementation will not happen in the near future.
After my change, start_plugins will return with zero, so the code quickly returns to the main function and the program exits immediately. This kind of imitates my preference: loggen should not start if one of the plugins cannot start. This can be challenged of course (or make configurable?), when we implement the multiple active plugin version. But for now I do not see how this can be imlemented, so I would like to avoid preparing for that. |
accept your opinion. |
../bin/loggen -S --active-connections=10 -I 120
caused crash inloggen, because mandatory parameters were not passed: ip and port.
The reason is even if a module cannot start, stop was still called. In
our specific case, thread_array was accessed in stop, even though it
was not initialized in start (because start returned earlier due to error).
The fix is that start returns boolean now. Stop is only called a
plugin is started.