Skip to content

Conversation

@menuet
Copy link

@menuet menuet commented Oct 7, 2023

Hi
I closed inadvertently my previous PR #30, probably because I force-pushed my related branch.
So, I am creating another PR to focus specifically on the memory/life-time issue when catching InvalidPartitionName in translate_exception and accessing the member name.
I hope this can help @cdacamar reproduce/analyze the issue.
(I have put my sample file and added some temporary cmake-stuff to test it easily)

@cdacamar
Copy link
Collaborator

Thank you for the focused test case. I do indeed see that there's an odd lifetime issue here. I believe what I want to suggest is that instead of using std::string we use a statically sized buffer to avoid extra memory allocation for the exception object. This can avoid issues where more code is executed than is strictly necessary to throw the exception.

I suspect a smallish buffer (say 64 bytes) is sufficient since our longest valid partition offset is currently 39 bytes. If the name is longer than 64 we can truncate it.

menuet pushed a commit to menuet/ifc that referenced this pull request Oct 27, 2023
menuet pushed a commit to menuet/ifc that referenced this pull request Oct 27, 2023
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.

2 participants