Skip to content

Conversation

@igor-sirotin
Copy link
Collaborator

Copy link

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Good job on finding the issue and fixing it

)

var
ctxPool: seq[ptr SdsContext]

Choose a reason for hiding this comment

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

seq cannot be used cross-thread until we migrate to the orc memory manager meaning that this list needs to be managed manually - the absolutely easiest way to do that is to use an array + counter and limit the number of sds contexts that can be created.

)

var
ctxPool: seq[ptr SdsContext]

Choose a reason for hiding this comment

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

Suggested change
ctxPool: seq[ptr SdsContext]
ctxPool: array[32, ptr SdsContext]
ctxPos: int

something like this - assuming you don't want more than 32 concurrent contexts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's okay for now to allow as much as needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know how many is needed. And eventually we'll need a proper fix anyway

Choose a reason for hiding this comment

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

no, I mean using a seq here is undefined behavior - if it grows more than once, it'll crash - seqs are tied to a particular thread, arrays are not - for a cross-thread seq, one needs to use createShared and a bit of extra work (similar to sharedseq in waku / ffi)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We tested this to work for now in Go tests and Status App.
We agreed with @Ivansete-status to sort this out in next releases.

@igor-sirotin igor-sirotin merged commit 8d33a7f into master Dec 22, 2025
1 check passed
@igor-sirotin igor-sirotin deleted the fix/thread-pool branch December 22, 2025 18:10
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.

SDS usage crashes unit tests

5 participants