Skip to content

Fix for 1693 bug access to deleted memory in array proxy index #3600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

christophe-murphy
Copy link
Contributor

Arrays can now be used as an index for creating an array proxy without failure.

Description

When using an array as an index when creating an array proxy a temporary index object is created and passed to the constructor for the array proxy. However the array underlying the index was not being kept after the temporary index was destroyed, resulting in undefined behavior. This fix ensures that the array is retained until the array proxy is destroyed. Users can now use an array as an index when creating an array proxy without needing to explicitly define an index object.

Fixes: #1693

Checklist

  • Rebased on latest master
  • Code compiles
  • Tests pass

@christophe-murphy christophe-murphy linked an issue Sep 5, 2024 that may be closed by this pull request
@melonakos melonakos added this to the 3.10 milestone Feb 5, 2025
@christophe-murphy
Copy link
Contributor Author

OK, I reran address sanitizer on the CUDA backend with the following options and it ran without any issues reported: protect_shadow_gap=0:replace_intrin=0:detect_stack_use_after_return=0

@christophe-murphy
Copy link
Contributor Author

I have done some more testing, see latest commit. I ran these through the leak sanitizer for all back ends and, aside from an unrelated memory leak in the random number generator engine, there are no issues.

The copy constructors for array_proxy have been made private. This will prevent you from assigning an array proxy to an auto variable accidently. Array proxies should only be assigned to variables of type array. Assigning to an auto will now lead to a compilation error.
edwinsolisf
edwinsolisf previously approved these changes Mar 14, 2025
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.

BUG: access to deleted memory in array_proxy index
4 participants