Fix member function call on null-pointer instance of SignalingClient#940
Merged
Conversation
Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
n-eiling
requested changes
Jul 8, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the WebRTC signaling client’s protocol callback to eliminate a crash when the callback is invoked on a null instance. It inlines the former non-static protocolCallback into the static entry point and updates registration in lib/web.cpp.
- Switch
.callbackinlib/web.cppto the unified staticprotocolCallback - Merge logic into the static callback and remove the old non-static overload
- Adjust internal calls to use the session
userpointer (c->…) - Add
gdbto development tools inflake.nix
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/web.cpp | Updated protocol registration to use the new static callback |
| lib/nodes/webrtc/signaling_client.cpp | Inlined non-static logic into protocolCallback, removed old overload, fixed dummy callback invocation |
| include/villas/nodes/webrtc/signaling_client.hpp | Removed obsolete member declaration, updated static callback signature |
| flake.nix | Added gdb to development dependencies |
This fixes a bug where libwebsockets would call the protocol handler with a NULL `user` pointer on initialization. This caused the `SignalingClient::protocolCallback` non-static function to be invoked on a null pointer instance. Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
n-eiling
approved these changes
Jul 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
libwebsocketscalls the protocol callbacks for our webrtc signaling client even when the connection is not explicitly initiated from the signaling client code. This causes theprotocolCallbackStaticfunction to cast a null-pointer to aSignalingClientand call the non-staticprotocolCallback.Fix
I moved the entire
protocolCallbacklogic into the static member function and removed the non-static member function.Context
I found this bug using
-fsanitize=addressand-fsanitize=undefined. This bug occurs on an idle villas-node process, without any configuration or user input.