-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Destructor for generic/top-level client in plugin not called on conditional restart #674
Comments
I have never used these |
/*Plugin Context: We create a small structure (plugin_context_t) to keep track of the plugin's callbacks and the current client instance. This helps us manage things better. Plugin Open: When the plugin starts, we allocate memory for the context and store the callbacks. This is like setting up the basics for the plugin to work. Plugin Func: This function doesn’t do much in this example. It just returns an error. You can add your logic here if needed. Plugin Close: When the plugin is closed, we free the memory we allocated for the context. This is like cleaning up after ourselves. Client Constructor: When a new client is created, we first check if there’s an old client instance. If yes, we clean it up. Then we allocate memory for the new client and return it. This ensures no memory is wasted. Client Destructor: When a client is no longer needed, we free its memory and clear the pointer. This is like saying goodbye and cleaning up. Min Version: We tell OpenVPN that this plugin needs at least version 3 to work.*/ |
Describe the bug
When performing a conditional restart (
SIGUSR1
) of an OpenVPN server with a plugin,openvpn_plugin_client_constructor_v1
is called to create a new generic/top-level client instance without deconstructing the previous one withopenvpn_plugin_client_destructor_v1
. When the server is stopped after one or more conditional restarts, only the last instance is destructed.This not only causes a memory leak, it also creates a logical issue when trying to distinguish the allocation of a generic/top-level client and a real client early on by counting allocations/deallocations.
To reproduce
openvpn_plugin_client_constructor_v1
and return a pointer to it.openvpn_plugin_client_destructor_v1
.SIGUSR1
to observe the issue.Expected behavior
On a conditional restart, either
openvpn_plugin_client_constructor_v1
should not be called, oropenvpn_plugin_client_destructor_v1
should be called beforehand, so that there is no memory leak.Version information
Additional context
Minimal example:
Log:
The text was updated successfully, but these errors were encountered: