Skip to content

Hashtable write error on exit #750

Closed
@chuckyvt

Description

@chuckyvt

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

use stdlib_hashmaps, only: chaining_hashmap_type, open_hashmap_type
use stdlib_hashmap_wrappers, only: fnv_1_hasher, key_type, set
    
implicit none
 
call hash_test

contains

subroutine hash_test
    
    character(len=12) :: char_key
    
    integer :: i, n

    type(key_type) :: key
    type(chaining_hashmap_type) :: test_map
    
    ! 1020000 works
    ! 1030000 fails
    n=1030000
    
    call test_map%init(fnv_1_hasher, 22)

    do i = 1, n

        write (char_key,'(I0)') i
        call set(key, char_key )
            
        call test_map%map_entry(key)

    enddo
    
end subroutine hash_test

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions