How to deal with the potential “wild pointer" when using the exposed vector? #432
Unanswered
Yikai-Liao
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hi @Yikai-Liao, thank you for report. This was a very bad issue, I almost cannot believe you are the first one to mention it. (I personally don't use the The following commit fixes the implementation to avoid dangling pointers, which does come with a slight decrease of convenience though. (Cannot get an element and then mutate it to affect the vector itself unless a shared ownership model is used.) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The problem is simple. When we free a vector (e.g., by replacing it with another vector), python objects that refer to elements in that vector become "wild pointers".
I verified my suspicions with the following code. I'd like to know if there's a way to avoid this problem, or at the very least get a warning when I access invalid python objects, because accessing these "wild pointers" has a probability of giving the program a segmentation fault.
Here is the minimal code:
Beta Was this translation helpful? Give feedback.
All reactions