-
Notifications
You must be signed in to change notification settings - Fork 187
Hashtable write error on exit #750
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
Comments
recursive subroutine free_map_entry_pool(pool) seems to be the free memory routine that is causing the error. |
Thank you @chuckyvt for reporting the issue. I used program main
use stdlib_hashmaps, only: chaining_hashmap_type
use stdlib_hashmap_wrappers, only: fnv_1_hasher
implicit none
call hash_test
contains
subroutine hash_test
type(chaining_hashmap_type) :: map
call map%init(fnv_1_hasher)
end subroutine hash_test
end program main I got the following error on my Fedora computer:
Could you test it on your computer, please? |
Update: it seems to be a more general issue: see here for more details. |
Interesting. I'm on Windows, and I believe IFX for Linux has more detailed memory sanitizer features, so I am not seeing this. I will say I have tested the posted code snippet with IFX, IFort, and GFortran 13.2 and see the same behavior for all. So at this point, it doesn't seem to be compiler specific. |
Strange. I can compile and run the posted code snippet with GCC 12.2.1. on my Fedora computer. Do you have similar problems with the |
Ok, so I think I have this run to ground. Long story short, the failure is due to a stack overflow as best I can tell, though the program doesn't say that. (Just returns a memory access error vs a specific stack overflow message I'm used to). This would explain the different behavior between Linux and Windows. I have increased the stack size and now runs ok. As a side note, since on the stdlib test cases the hashtable is at the main program level, the final procedure is never called in the checks I put together. Structuring a test case so that the hastable is in a subroutine or similar may be a decent idea to include at some point. |
Thank you @chuckyvt for clarifying and closing the issue.
Good point. Don't hesitate to submit a PR with such a test. Otherwise I'll try to do it. |
Description
I am running into a write access violation with the hashmap function when it goes out of scope. This typically happens only with relatively large maps, in the attached example code, 1020000 entries works, but 1030000 fails. My guess is it is an error is in the "final" procedure to free memory. If the hashmap is in the main program scope, I typically don't see the error. My understanding is the final procedure won't be called at the main program scope level.
Example code:
program hash_error
end program
Expected Behaviour
Intent would be for the subroutine to exit without error.
Version of stdlib
0.3.0
Platform and Architecture
Windows, Intel IFX and IFort compiler v2024.0, GFortran 13.2
Additional Information
No response
The text was updated successfully, but these errors were encountered: