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
collect
removes bounds-checks, even for broken custom types
#41214
Comments
What kind of error do you get? Is a stacktrace printed? |
Julia.exe crashes and gives me this:
(line numbers may be slightly off from gist) |
EXCEPTION_ACCESS_VIOLATION at 0x1f7add9
With this kind of error it's often helpful to try
It looks like the |
EXCEPTION_ACCESS_VIOLATION at 0x1f7add9
collect
removes bounds-checks, even for broken custom types
We could perhaps try switching that loop:
But I think that may be equivalent, in terms of branches and bounds |
If we had the above with |
I mean, arguably the root of this is the fact that everything is HasLength() by default, so that you effectively have to explicitly opt out of implementations that require the length to be safe, rather than the other way around. |
HasLength is not about safety though; it's about whether |
Incidentally, I tracked down the source of the broken length in the first case: pop in FunctionalCollections.jl is broken, and there is an unmerged pull request from almost a year ago that would fix it. That was also the reason why the code worked for Lists but not Persistent vectors |
From triage:
|
Here's a basic gist, using the smallest approximate input sizes that consistently triggers the bug
https://gist.github.com/saolof/dcf785c559574b16d478db4632173096
The above implementation of pairing heaps is fairly robust when using linked lists (though copying to an array and sorting there is clearly going to be a lot faster if you don't specifically need a persistent heap), but attempting to make it use vectors instead (replacing cons/tail/head with push/pop/peek) will consistently cause Julia to crash on my machine even when using heapsort on just a hundred elements. It looks like this may be some memory allocator failure?
The text was updated successfully, but these errors were encountered: