Skip to content

Conversation

@srxqds
Copy link
Contributor

@srxqds srxqds commented May 23, 2024

there is a bug when the size == capacity without set the vector->size

@ghost ghost added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 23, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 23, 2024
@marek-safar marek-safar requested a review from lateralusX June 17, 2024 05:55
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

DN_ASSERT (vector);

if (size == vector->_internal._capacity)
if (size == vector->size)
Copy link
Member

@lateralusX lateralusX Jun 17, 2024

Choose a reason for hiding this comment

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

Looks like this part is actually coming all the way from mono/mono GArray that have similar behavior, https://github.com/dotnet/runtime/blob/main/src/mono/mono/eglib/garray.c#L229.

Since this follow the std::vector::resize, https://en.cppreference.com/w/cpp/container/vector/resize, it should behave accordingly, so if new size == current size do nothing, new size smaller than current size, reduce elements, if new size is bigger than current size, it should grow to requested size and setup values to default.

if (size > vector->_internal._capacity) is an optimization to not call additional function in case not really needed (there is already capacity available in the vector), so that works, and the shrink scenario already checks against vector->size, so that is also fine.

Could you please add a test case for this scenario in https://github.com/dotnet/runtime/blob/main/src/mono/mono/eventpipe/test/dn-vector-tests.c#L945 as well? It should be possible to build and run these tests locally, enabling this when building Mono runtime, https://github.com/dotnet/runtime/blob/main/src/mono/mono/eventpipe/test/CMakeLists.txt, by setting ENABLE_EVENTPIPE_TEST, that should produce a test executable that runs all tests. NOTE, there might be tests broken in that suite, since it is currently run manual, and I guess not for sometime, but is normally straight forward to fix, please let me know if you have issues with the test suite.

Copy link
Member

@lateralusX lateralusX Jun 17, 2024

Choose a reason for hiding this comment

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

It is also worth pointing out that this function is currently not used in the dotnet runtime codebase. @srxqds do you use the library for standalone implementation or using it in Mono runtime embedding scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok,I have another fix, I will upload all later

@am11 am11 removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jun 17, 2024
@tommcdon
Copy link
Member

Hi @srxqds! Thanks for submitting this PR. Do you plan on addressing @lateralusX's feedback in the short term, or would it be OK to change this PR to draft mode while development is still in progress?

@tommcdon
Copy link
Member

Hi @srxqds! I'm changing the PR to a Draft PR - please let us know if you plan on working on it soon.

@tommcdon tommcdon marked this pull request as draft August 12, 2024 20:33
@srxqds srxqds closed this Aug 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Diagnostics-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants