Skip to content

Conversation

amstokely
Copy link
Contributor

@amstokely amstokely commented Aug 4, 2025

This PR fixes a bug in the mpas_stream_list module where adjacent duplicate streams were allowed to be inserted into the list. The issue was in the MPAS_stream_list_insert logic, which has been updated to properly reject adjacent duplicates. The fix has been confirmed by the mpas_test_insert_duplicate_at_begin and mpas_test_insert_duplicate_at_end tests. Additionally, the unit test suite covers all core subroutines in the mpas_stream_list module, ensuring there are no other similar bugs.

@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch from 5e91e71 to 9b7263a Compare August 4, 2025 21:57
@mgduda mgduda self-requested a review August 8, 2025 16:16
@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch 3 times, most recently from 5ebe42b to 838fa77 Compare August 8, 2025 22:38
@amstokely amstokely requested a review from mgduda August 11, 2025 21:12
@amstokely amstokely requested a review from mgduda August 11, 2025 23:08
@amstokely amstokely requested a review from mgduda August 12, 2025 16:25
Copy link
Contributor

@mgduda mgduda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a couple of comments that I've left, it might be worth adding at least one test to verify that we can successfully remove items from the middle or the end of a list. Currently, it seems that we only test:

  1. Removing the only item (head) of a list
  2. Attempting to remove an item from an empty list (which should yield an error)
  3. Attempting to remove a non-existent item from a list (which should yield an error)

@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch from 9b63241 to 7c580b8 Compare August 12, 2025 19:34
@amstokely amstokely requested a review from mgduda August 12, 2025 19:48
@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch 2 times, most recently from 63be121 to dec7767 Compare August 12, 2025 20:06
@amstokely amstokely requested a review from mgduda August 12, 2025 21:09
@amstokely amstokely requested a review from mgduda August 13, 2025 22:51
@amstokely amstokely requested a review from mgduda August 14, 2025 17:38
@mgduda
Copy link
Contributor

mgduda commented Aug 14, 2025

@amstokely I've left just one more comment regarding changes to the LIST_WARN_WRITE and LIST_ERROR_WRITE macros. Otherwise, the code looks fine to me, and I think we can rework the commit history to contain just a few commits:

  1. Add unit tests for the mpas_stream_list module
  2. Fix the bug related to insertion of duplicate entries.
  3. Fix the bug related the premature nullification of stream % next pointer.

@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch from 72d6036 to 7a87f04 Compare August 15, 2025 15:36
@mgduda mgduda self-requested a review August 15, 2025 15:49
Andy Stokely added 2 commits August 15, 2025 09:51
Unit tests were added for the mpas_stream_list module, covering stream list
creation, insertion, querying, and removal. The tests fail when inserting
duplicate streams adjacent to each other, either as the first or last stream
in the list. The bug is in the MPAS_stream_list_insert subroutine in the
mpas_stream_list module, which does not correctly handle duplicates in these
cases.
The original code allowed adjacent duplicate streams to be inserted into the
list, which caused incorrect behavior when adding a duplicate stream next to an
existing one. The bug was fixed by updating the insertion logic to properly
reject adjacent duplicate streams. The new code checks for duplicates during
insertion and prevents adding the stream if it is already in the list, even if
adjacent. The mpas_test_insert_duplicate_at_begin and
mpas_test_insert_duplicate_at_end tests in the mpas_stream_list test suite
confirm that these changes fix the bug.
Copy link
Contributor

@mgduda mgduda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try again to rework the commit history? Currently, 1b24f2f not only fixes the duplicate insertion bug, but it also makes many changes to the unit tests introduced in f8eb09c. Also, can you add some details to the commit message that is currently in 7a87f04 and ensure that any changes to the unit test module are moved into the first commit?

@amstokely
Copy link
Contributor Author

Can you try again to rework the commit history? Currently, 1b24f2f not only fixes the duplicate insertion bug, but it also makes many changes to the unit tests introduced in f8eb09c. Also, can you add some details to the commit message that is currently in 7a87f04 and ensure that any changes to the unit test module are moved into the first commit?

I'm working on it right now!

@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch from 7a87f04 to 214a6e7 Compare August 15, 2025 15:55
Fix bug in mpas_stream_list_insert that could unlink the head node when a
duplicate stream was inserted. Moved nullify(stream % next) calls into the
relevant conditional blocks to ensure new streams are only linked after
passing duplicate checks. Prevents inadvertent modification of the list when
duplicate insertions occur.
@amstokely amstokely force-pushed the framework/duplicate_stream_fix branch from 214a6e7 to 3f9ead8 Compare August 15, 2025 16:05
@amstokely amstokely requested a review from mgduda August 15, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants