Skip to content

Conversation

@desertwitch
Copy link
Contributor

This is a rudimentary proposal for a fix of the issues outlined in #10:

*GenericSorter[E] with a tempWriter field of nil (due to initialization error) should not be returned as a non-nil pointer.
Consumers would assume a returned pointer to be a fully functional instance and run into panics (closed channels, nil-deref).

Instead, nil should be returned alongside the already closed channels and bubble up unmasked towards the last consumer.
Safeguards were put in place so that internal consumers (of generics) do not mask nil by embedding in return structs either.

I would not consider this to be an API break as previously returned non-functional pointers were unusuable.
The proposed changes returning nil aligns with common Go function return expectations in case of any errors.

The changes pass the test suite, but feel free to merge/close/critique as required.

fixes #10

Signed-off-by: desertwitch <24509509+desertwitch@users.noreply.github.com>
@lanrat
Copy link
Owner

lanrat commented Sep 12, 2025

Thanks for the fix. I'll merge this in and add a test to ensure #10 does not happen again.

@lanrat lanrat merged commit 586a643 into lanrat:main Sep 12, 2025
1 check passed
@desertwitch desertwitch deleted the issue-10 branch September 12, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segmentation fault with zero-space left temporary location

2 participants