danielealbano / cachegrand

cachegrand - a modern data ingestion, processing and serving platform built for today's hardware
BSD 3-Clause "New" or "Revised" License
975 stars 34 forks source link

Bug fix queue mpmc next null #309

Closed danielealbano closed 1 year ago

danielealbano commented 1 year ago

This PR fix a bug in queue_mpmc which can lead to memory loss.

When popping the last value available on a page, the next_page pointer of the previous page can still be null because the other thread that has created the page and inserted the value might still have to fill the value. Therefore, to ensure that the chain doesn't break, ensure that next_page is not null before trying to do the CAS operation on the head of the queue.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 50.00% and project coverage change: +0.01 :tada:

Comparison is base (7fa5d21) 82.00% compared to head (0e03ccc) 82.01%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #309 +/- ## ========================================== + Coverage 82.00% 82.01% +0.01% ========================================== Files 168 168 Lines 11386 11388 +2 ========================================== + Hits 9336 9339 +3 + Misses 2050 2049 -1 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `82.01% <50.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/danielealbano/cachegrand/pull/309?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano) | Coverage Δ | | |---|---|---| | [src/data\_structures/queue\_mpmc/queue\_mpmc.c](https://codecov.io/gh/danielealbano/cachegrand/pull/309?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL2RhdGFfc3RydWN0dXJlcy9xdWV1ZV9tcG1jL3F1ZXVlX21wbWMuYw==) | `97.73% <50.00%> (-1.11%)` | :arrow_down: | ... and [3 files with indirect coverage changes](https://codecov.io/gh/danielealbano/cachegrand/pull/309/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.