You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: resolve critical memory leak in PubSub FFI message processing
This commit addresses a critical memory leak in the FFI layer where Rust-allocated
memory was not properly freed after C# marshaling during PubSub message processing.
Key Changes:
Rust FFI Layer (rust/src/lib.rs):
- Replaced std::mem::forget() with scoped lifetime management in process_push_notification
- Vec<u8> instances now remain alive during callback execution and auto-cleanup on exit
- Added comprehensive message structure validation based on PushKind type
- Implemented proper error logging for invalid message formats and unexpected value types
- Enhanced validation ensures message structure matches expected format for each PushKind
Memory Leak Detection Tests:
- Added PubSubFFIMemoryLeakTests.cs with comprehensive memory leak detection
- Tests process 100,000+ messages and verify memory usage remains bounded
- Includes tests for various message sizes, GC pressure, concurrent access, and extended duration
- Added PubSubMemoryLeakFixValidationTests.cs for simple validation scenarios
Test Cleanup:
- Removed tests dependent on deleted PubSubCallbackManager and ClientRegistry classes
- Deleted PubSubCallbackIntegrationTests.cs (tested removed PubSubCallbackManager)
- Deleted PubSubFFIWorkflowTests.cs (tested removed PubSubCallbackManager)
- Deleted ClientRegistryTests.cs (tested removed ClientRegistry)
- Updated PubSubFFIIntegrationTests.cs to remove tests using removed infrastructure
- Updated PubSubFFICallbackIntegrationTests.cs to remove ClientRegistry tests
- Fixed Lock type to object for .NET 8 compatibility
- Changed explicit type declarations to var to avoid type resolution issues
All unit tests (242) now pass successfully.
Addresses requirements 1.1-1.6 and 9.1 from pubsub-critical-fixes spec.
Signed-off-by: Joe Brinkman <joe.brinkman@improving.com>
0 commit comments