llvm / llvm/llvm-project

[flang][OpenMP] test_parallel_for_allocate.F90: free(): invalid next size (normal)

Open
#189,959 2 comments 0 reactions 0 assignees View on GitHub
flang:openmp regression
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The OpenMP V&V test [`test_parallel_for_allocate.F90`](https://github.com/OpenMP-Validation-and-Verification/OpenMP_VV/blob/master/tests/5.0/parallel_for/test_parallel_for_allocate.F90) is failing with:

```console
$ /home/meinersbur/install/llvm/bin/flang --version
flang version 23.0.0git (https://github.com/ROCm/llvm-project a30a8e9474f75000d9746b5d02800d2e47903f44)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/meinersbur/install/llvm/bin
Build config: +assertions
Configuration file: /home/meinersbur/install/llvm/bin/flang.cf
$ /home/meinersbur/install/llvm/bin/flang -I./ompvv -O2 -fopenmp --offload-arch=gfx90a -fopenmp-version=50 -DVERBOSE_MODE=1
$ LD_LIBRARY_PATH=/home/meinersbur/install/llvm/lib /home/meinersbur/src/OpenMP_VV/tests/5.0/parallel_for/test_parallel_for_allocate.F90 -o bin/test_parallel_for_allocate.F90
warning: OpenMP support for version 50 in flang is still incomplete
warning: OpenMP support for version 50 in flang is still incomplete
warning: OpenMP support for version 50 in flang is still incomplete
[header test_parallel_for_allocate.F90:26] Test is running on device
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
Aborted (core dumped)
```

I bisected this to a30a8e9474f75000d9746b5d02800d2e47903f44 (#183794, #188851). Its parent d5f7acdbc15fd15244bf6f3e4d4e3ea5a7bd2781 is working as expected.

LIBOMPTARGET_DEBUG=1 output

omptarget --> Init offload library!

OMPT --> Entering connectLibrary
OMPT --> OMPT: Trying to load library libomp.so
OMPT --> OMPT: Trying to get address of connection routine ompt_libomp_connect
OMPT --> OMPT: Library connection handle = 0x0000741ffb755210
OMPT --> Exiting connectLibrary
omptarget --> Loading RTLs
omptarget --> RTLs loaded!
TARGET AMDGPU RTL --> Implementing hsa_init with dlsym(hsa_init) -> 0x741ff098edf0
TARGET AMDGPU RTL --> Implementing hsa_status_string with dlsym(hsa_status_string) -> 0x741ff098f5c0
TARGET AMDGPU RTL --> Implementing hsa_shut_down with dlsym(hsa_shut_down) -> 0x741ff098ee10
TARGET AMDGPU RTL --> Implementing hsa_system_get_info with dlsym(hsa_system_get_info) -> 0x741ff098ee20
TARGET AMDGPU RTL --> Implementing hsa_agent_get_info with dlsym(hsa_agent_get_info) -> 0x741ff098ee90
TARGET AMDGPU RTL --> Implementing hsa_isa_get_info_alt with dlsym(hsa_isa_get_info_alt) -> 0x741ff098f380
TARGET AMDGPU RTL --> Implementing hsa_iterate_agents with dlsym(hsa_iterate_agents) -> 0x741ff098ee80
TARGET AMDGPU RTL --> Implementing hsa_agent_iterate_isas with dlsym(hsa_agent_iterate_isas) -> 0x741ff098f360
TARGET AMDGPU RTL --> Implementing hsa_signal_create with dlsym(hsa_signal_create) -> 0x741ff098f0b0
TARGET AMDGPU RTL --> Implementing hsa_signal_destroy with dlsym(hsa_signal_destroy) -> 0x741ff098f0c0
TARGET AMDGPU RTL --> Implementing hsa_signal_store_relaxed with dlsym(hsa_signal_store_relaxed) -> 0x741ff098f0f0
TARGET AMDGPU RTL --> Implementing hsa_signal_store_screlease with dlsym(hsa_signal_store_screlease) -> 0x741ff098f100
TARGET AMDGPU RTL --> Implementing hsa_signal_wait_scacquire with dlsym(hsa_signal_wait_scacquire) -> 0x741ff098f140
TARGET AMDGPU RTL --> Implementing hsa_signal_load_scacquire with dlsym(hsa_signal_load_scacquire) -> 0x741ff098f0e0
TARGET AMDGPU RTL --> Implementing hsa_signal_subtract_screlease with dlsym(hsa_signal_subtract_screlease) -> 0x741ff098f2b0
TARGET AMDGPU RTL --> Implementing hsa_queue_create with dlsym(hsa_queue_create) -> 0x741ff098eef0
TARGET AMDGPU RTL --> Implementing hsa_queue_destroy with dlsym(hsa_queue_destroy) -> 0x741ff098ef10
TARGET AMDGPU RTL --> Implementing hsa_queue_load_read_index_scacquire with dlsym(hsa_queue_load_read_index_scacquire) -> 0x741ff098ef30
TARGET AMDGPU RTL --> Implementing hsa_queue_add_write_index_relaxed with dlsym(hsa_queue_add_write_index_relaxed) -> 0x741ff098eff0
TARGET AMDGPU RTL --> Implementing hsa_memory_copy with dlsym(hsa_memory_copy) -> 0x741ff098f090
TARGET AMDGPU RTL --> Implementing hsa_executable_create with dlsym(hsa_executable_create) -> 0x741ff098f490
TARGET AMDGPU RTL --> Implementing hsa_executable_create_alt with dlsym(hsa_executable_create_alt) -> 0x741ff098f4a0
TARGET AMDGPU RTL --> Implementing hsa_executable_destroy with dlsym(hsa_executable_destroy) -> 0x741ff098f4b0
TARGET AMDGPU RTL --> Implementing hsa_executable_freeze with dlsym(hsa_executable_freeze) -> 0x741ff098f4f0
TARGET AMDGPU RTL --> Implementing hsa_executable_validate with dlsym(hsa_executable_validate) -> 0x741ff098f540
TARGET AMDGPU RTL --> Implementing hsa_executable_symbol_get_info with dlsym(hsa_executable_symbol_get_info) -> 0x741ff098f580
TARGET AMDGPU RTL --> Implementing hsa_executable_get_symbol_by_name with dlsym(hsa_executable_get_symbol_by_name) -> 0x741ff098f570
TARGET AMDGPU RTL --> Implementing hsa_executable_iterate_symbols with dlsym(hsa_executable_iterate_symbols) -> 0x741ff098f590
TARGET AMDGPU RTL --> Implementing hsa_code_object_deserialize with dlsym(hsa_code_object_deserialize) -> 0x741ff098f3f0
TARGET AMDGPU RTL --> Implementing hsa_executable_load_code_object with dlsym(hsa_executable_load_code_object) -> 0x741ff098f4c0
TARGET AMDGPU RTL --> Implementing hsa_code_object_destroy with dlsym(hsa_code_object_destroy) -> 0x741ff098f400
TARGET AMDGPU RTL --> Implementing hsa_amd_agent_memory_pool_get_info with dlsym(hsa_amd_agent_memory_pool_get_info) -> 0x741ff098f730
TARGET AMDGPU RTL --> Implementing hsa_amd_agent_iterate_memory_pools with dlsym(hsa_amd_agent_iterate_memory_pools) -> 0x741ff098f6b0
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_pool_allocate with dlsym(hsa_amd_memory_pool_allocate) -> 0x741ff098f6c0
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_pool_free with dlsym(hsa_amd_memory_pool_free) -> 0x741ff098f6d0
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_async_copy with dlsym(hsa_amd_memory_async_copy) -> 0x741ff098f6e0
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_pool_get_info with dlsym(hsa_amd_memory_pool_get_info) -> 0x741ff098f6a0
TARGET AMDGPU RTL --> Implementing hsa_amd_agents_allow_access with dlsym(hsa_amd_agents_allow_access) -> 0x741ff098f740
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_lock with dlsym(hsa_amd_memory_lock) -> 0x741ff098f770
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_unlock with dlsym(hsa_amd_memory_unlock) -> 0x741ff098f790
TARGET AMDGPU RTL --> Implementing hsa_amd_memory_fill with dlsym(hsa_amd_memory_fill) -> 0x741ff098f7a0
TARGET AMDGPU RTL --> Implementing hsa_amd_register_system_event_handler with dlsym(hsa_amd_register_system_event_handler) -> 0x741ff098f860
TARGET AMDGPU RTL --> Implementing hsa_amd_signal_create with dlsym(hsa_amd_signal_create) -> 0x741ff098f830
TARGET AMDGPU RTL --> Implementing hsa_amd_signal_async_handler with dlsym(hsa_amd_signal_async_handler) -> 0x741ff098f640
TARGET AMDGPU RTL --> Implementing hsa_amd_pointer_info with dlsym(hsa_amd_pointer_info) -> 0x741ff098f7e0
TARGET AMDGPU RTL --> Implementing hsa_code_object_reader_create_from_memory with dlsym(hsa_code_object_reader_create_from_memory) -> 0x741ff098f470
TARGET AMDGPU RTL --> Implementing hsa_code_object_reader_destroy with dlsym(hsa_code_object_reader_destroy) -> 0x741ff098f480
TARGET AMDGPU RTL --> Implementing hsa_executable_load_agent_code_object with dlsym(hsa_executable_load_agent_code_object) -> 0x741ff098f4e0
omptarget --> Registered plugin AMDGPU with 1 visible device(s)
omptarget --> Image 0x0000000000200388 is compatible with RTL AMDGPU device 0
omptarget --> Registering image 0x0000000000200388 with RTL AMDGPU
omptarget --> Done registering entries!
omptarget --> Entering target region for device -1 with entry point 0x000000000020a420
omptarget --> Default TARGET OFFLOAD policy is now mandatory (devices were found)
omptarget --> Use default device id 0
omptarget --> Call to omp_get_num_devices returning 1
omptarget --> Call to omp_get_num_devices returning 1
omptarget --> Call to omp_get_initial_device returning 1
omptarget --> Entry 0: Base=0x0000000000312fb0, Begin=0x0000000000312fb0, Size=4, Type=0x22, Name=loc(fused<#fir>["/home/mickruse/git/aomp-test/OpenMP_VV/ompvv/ompvv.F90":122:25, "/work/mickruse/git/aomp-test/OpenMP_VV/tests/5.0/parallel_for/test_parallel_for_allocate.F90":16:1])
omptarget --> Entry 1: Base=0x0000000000000000, Begin=0x0000000000000000, Size=0, Type=0x120, Name=unknown
omptarget --> Trans table 0x0000000000203d10 : 0x0000000000203db8
PluginInterface --> Load data from image 0x200388
omptarget --> Call to omp_get_num_devices returning 1
omptarget --> Call to omp_get_initial_device returning 1
PluginInterface --> MemoryManagerTy::allocate: size 48 with host pointer 0x0.
PluginInterface --> findBucket: Size 48 is floored to 32.
PluginInterface --> Cannot find a node in the FreeLists. Allocate on device.
PluginInterface --> Node address 0x24e8a920, target pointer 0x741ff2c3a000, size 48
PluginInterface --> MemoryManagerTy::free: target memory 0x741ff2c3a000.
PluginInterface --> findBucket: Size 48 is floored to 32.
PluginInterface --> Found its node 0x24e8a920. Insert it to bucket 4.
omptarget --> Entry point 0x0000000000313514 maps to global _QMompvv_libEompvv_errors (0x0000741ff2c40168)
PluginInterface --> Global symbol '__omp_offloading_fc00_64c3235__QMompvv_libPtest_offloading_probe_l144_kernel_environment' was found in the ELF image and 48 bytes will copied from 0x24e86cc0 to 0x24e7c7a0.
TARGET AMDGPU RTL --> ELFABIVersion: 4
omptarget --> Entry point 0x000000000020a420 maps to __omp_offloading_fc00_64c3235__QMompvv_libPtest_offloading_probe_l144 (0x0000000024e7c760)
PluginInterface --> Global symbol '__omp_offloading_fc00_64c3235__QMompvv_libPtest_shared_environment_probe_l312_kernel_environment' was found in the ELF image and 48 bytes will copied from 0x24e86cf0 to 0x24e7c890.
TARGET AMDGPU RTL --> ELFABIVersion: 4
omptarget --> Entry point 0x000000000020a450 maps to __omp_offloading_fc00_64c3235__QMompvv_libPtest_shared_environment_probe_l312 (0x0000000024e7c850)
omptarget --> Looking up mapping(HstPtrBegin=0x0000000000313514, Size=4)...
omptarget --> Add mapping from host 0x0000000000313514 to device 0x0000741ff2c40168 with size 4, name "_QMompvv_libEompvv_errors"
omptarget --> Notifying about new mapping: HstPtr=0x0000000000313514, Size=4
omptarget --> loop trip count is 0
omptarget --> Looking up mapping(HstPtrBegin=0x0000000000312fb0, Size=4)...
PluginInterface --> MemoryManagerTy::allocate: size 4 with host pointer 0x312fb0.
PluginInterface --> findBucket: Size 4 is floored to 4.
PluginInterface --> findBucket: Size 4 goes to bucket 0
PluginInterface --> Cannot find a node in the FreeLists. Allocate on device.
PluginInterface --> Node address 0x24e8bd90, target pointer 0x741fec400000, size 4
omptarget --> Creating new map entry with HstPtrBase=0x0000000000312fb0, HstPtrBegin=0x0000000000312fb0, TgtAllocBegin=0x0000741fec400000, TgtPtrBegin=0x0000741fec400000, Size=4, DynRefCount=1, HoldRefCount=0, Name=loc(fused<#fir>["/home/mickruse/git/aomp-test/OpenMP_VV/ompvv/ompvv.F90":122:25, "/work/mickruse/git/aomp-test/OpenMP_VV/tests/5.0/parallel_for/test_parallel_for_allocate.F90":16:1])
omptarget --> Notifying about new mapping: HstPtr=0x0000000000312fb0, Size=4
omptarget --> There are 4 bytes allocated at target address 0x0000741fec400000 - is new
omptarget --> Looking up mapping(HstPtrBegin=0x0000000000312fb0, Size=4)...
omptarget --> Mapping exists with HstPtrBegin=0x0000000000312fb0, TgtPtrBegin=0x0000741fec400000, Size=4, DynRefCount=1 (update suppressed), HoldRefCount=0
omptarget --> Obtained target argument 0x0000741fec400000 from host pointer 0x0000000000312fb0
omptarget --> Forwarding first-private value 0x0000000000000000 to the target construct
omptarget --> Launching target execution __omp_offloading_fc00_64c3235__QMompvv_libPtest_offloading_probe_l144 with pointer 0x0000000024e7c760 (index=1).
PluginInterface --> Launching kernel __omp_offloading_fc00_64c3235__QMompvv_libPtest_offloading_probe_l144 with [1,1,1] blocks and [256,1,1] threads in Generic-SPMD mode
PluginInterface --> MemoryManagerTy::allocate: size 16 with host pointer 0x0.
PluginInterface --> findBucket: Size 16 is floored to 16.
PluginInterface --> Cannot find a node in the FreeLists. Allocate on device.
PluginInterface --> Node address 0x24e8be00, target pointer 0x741ff261f000, size 16
omptarget --> Looking up mapping(HstPtrBegin=0x0000000000312fb0, Size=4)...
omptarget --> Mapping exists with HstPtrBegin=0x0000000000312fb0, TgtPtrBegin=0x0000741fec400000, Size=4, DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0
omptarget --> There are 4 bytes allocated at target address 0x0000741fec400000 - is last
omptarget --> Tracking released entry: HstPtr=0x0000000000312fb0, Size=4, ForceDelete=0
omptarget --> Moving 4 bytes (tgt:0x0000741fec400000) -> (hst:0x0000000000312fb0)
omptarget --> Call to omp_get_num_devices returning 1
omptarget --> Call to omp_get_initial_device returning 1
PluginInterface --> MemoryManagerTy::allocate: size 4 with host pointer 0x0.
PluginInterface --> findBucket: Size 4 is floored to 4.
PluginInterface --> findBucket: Size 4 goes to bucket 0
PluginInterface --> Cannot find a node in the FreeLists. Allocate on device.
PluginInterface --> Node address 0x24e8bd20, target pointer 0x741ff0819000, size 4
PluginInterface --> MemoryManagerTy::free: target memory 0x741ff261f000.
PluginInterface --> findBucket: Size 16 is floored to 16.
PluginInterface --> Found its node 0x24e8be00. Insert it to bucket 3.
PluginInterface --> MemoryManagerTy::free: target memory 0x741ff0819000.
PluginInterface --> findBucket: Size 4 is floored to 4.
PluginInterface --> findBucket: Size 4 goes to bucket 0
PluginInterface --> Found its node 0x24e8bd20. Insert it to bucket 0.
omptarget --> Removing map entry with HstPtrBegin=0x0000000000312fb0, TgtPtrBegin=0x0000741fec400000, Size=4, Name=loc(fused<#fir>["/home/mickruse/git/aomp-test/OpenMP_VV/ompvv/ompvv.F90":122:25, "/work/mickruse/git/aomp-test/OpenMP_VV/tests/5.0/parallel_for/test_parallel_for_allocate.F90":16:1])
omptarget --> Deleting tgt data 0x0000741fec400000 of size 4 by freeing allocation starting at 0x0000741fec400000
PluginInterface --> MemoryManagerTy::free: target memory 0x741fec400000.
PluginInterface --> findBucket: Size 4 is floored to 4.
PluginInterface --> findBucket: Size 4 goes to bucket 0
PluginInterface --> Found its node 0x24e8bd90. Insert it to bucket 0.
omptarget --> Notifying about an unmapping: HstPtr=0x0000000000312fb0
[header test_parallel_for_allocate.F90:26] Test is running on device
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
free(): invalid next size (normal)
Aborted (core dumped)

This may indicate some heap smashing

@luporl

Contributor guide

Open the contributing guide

Research direction

Reproduce tests/5.0/parallel_for/test_parallel_for_allocate.F90 with flang, OpenMP 5.0, AMDGPU offload, and the shown runtime settings. Compare commit a30a8e9474f75000d9746b5d02800d2e47903f44 with parent d5f7acdbc15fd15244bf6f3e4d4e3ea5a7bd2781, using the LIBOMPTARGET_DEBUG output to locate the regression. Done means the test no longer reports invalid frees or aborts.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.