-
Notifications
You must be signed in to change notification settings - Fork 33
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
erase() crashes #53
Comments
Unfortunately impossible to diagnose without some dummy code which replicates the issue. [EDIT: only thing I can see that you might be doing wrong there is that if your code erases the last element in the colony, it's going to iterate past .end() and cause a segmentation fault. To fix:
|
Thanks for the quick reply. I tested the loop issue you mentioned:
Result:
And no crash. After all, that kind of loop is the same as you have in the examples on your website. I guess I have to add more debug logging and investigate further. Thanks either way so far! |
That's not the loop I wrote. |
The loop you wrote there: https://plflib.org/colony.htm#functions
The purpose of my test was to see whether this causes a crash and it did not. Since that's a quick and simple test I did that first before trying the different loop you suggested in this very thread here previously. |
Yeah, that loop explicitly states that it's trying to erase half the elements, in a use-case where I know that the number of elements is even, therefore it will reach the end condition. |
Yes okay, my test above with 3 elements does crash. Might not hurt to make that more clear on the website. |
For any std:: container, erase returns the element after the element you're erasing, so the situation will be the same for any standard container. It just might take longer to reach a crash state for a vector because non-back erasure is so much slower. Cheers- |
Thanks for the insight. That might be why it didn't crash for me with a vector because I didn't catch the return. I did it like this:
Running this with 3 elements doesn't crash unlike the colony (or other container) version with an iterator. |
Ah, I see. BTW using indexes in that way will always be slower than using an iterator, |
Thanks again for the info and Merry Christmas to you, too :-) |
Hi,
I get crashes with colony after it's running for a few hours on rhel 9. I get that with different compilers so the compiler shouldn't be the problem. Here's the trace:
The program in question is a network related tool but unfortunately I'm not at liberty to show the full source. However, here are the relevant parts:
the content gets added like this later on:
I ran the same program with a vector before I switched to colony which worked fine. The only difference I noticed was that accessing the struct's members with colony is via pointer (->).
This happens with 7.39 i checked out from github after you fixed the exceptions bug i reported.
Any help would of course be welcome ...
The text was updated successfully, but these errors were encountered: