apache / celix

Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component and in-process service-oriented programming.
https://celix.apache.org/
Apache License 2.0
166 stars 87 forks source link

hotfix/fix use-after-free caused by cancelled service tracker. #596

Closed PengZheng closed 1 year ago

PengZheng commented 1 year ago

This PR fixes #595, a use-after-free introduced by a previous attempt to avoid deadlock, by splitting the creation of a service tracker into two steps:

  1. Create a closed service tracker if not cancelled under the protection of ctx->mutex
  2. Open the tracker without holding ctx->mutex (no risk of deadlock).
codecov-commenter commented 1 year ago

Codecov Report

Merging #596 (e5a0a37) into master (456de19) will decrease coverage by 0.48%. The diff coverage is 80.76%.

:exclamation: Current head e5a0a37 differs from pull request most recent head 7c65bfc. Consider uploading reports for the commit 7c65bfc to get more accurate results

@@            Coverage Diff             @@
##           master     #596      +/-   ##
==========================================
- Coverage   79.00%   78.52%   -0.48%     
==========================================
  Files         234      234              
  Lines       35386    35389       +3     
==========================================
- Hits        27955    27790     -165     
- Misses       7431     7599     +168     
Files Changed Coverage Δ
libs/framework/src/service_tracker.c 77.70% <75.00%> (+0.07%) :arrow_up:
libs/framework/src/bundle_context.c 80.53% <88.88%> (+0.17%) :arrow_up:
...iscovery_zeroconf/src/discovery_zeroconf_watcher.c 88.51% <100.00%> (-0.04%) :arrow_down:

... and 6 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more