Skip to content

Fix FAST_CreateCheckpoint in c++ interface #2881

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

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

marchdf
Copy link
Contributor

@marchdf marchdf commented Jun 23, 2025

FAST_CreateCheckpoint expects a fixed sized char buffer of size 1025: CHARACTER(KIND=C_CHAR), INTENT(IN ) :: CheckpointRootName_c(IntfStrLen). However the c++ is taking a 1 char string and sending a pointer to that data to the Fortran. The Fortran TRANSFER function then throws a good old:

==2684227==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x5120002144e8 at pc 0x557e98358a61 bp 0x7ffc0f87ea90 sp 0x7ffc0f87e248
READ of size 1025 at 0x5120002144e8 thread T0
    #0 0x557e98358a60 in memcpy /mnt/vdb/home/jrood/goose/spack/var/spack/stage/spack-stage-llvm-17.0.6-fzo52dlnsdgyyb3wgxrrlxmnvepk6esa/spack-src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115:5
    #1 0x7f0d5b25c311 in FAST_CreateCheckpoint /mnt/vdb/home/mhenryde/exawind/exawind-manager/environments/nalu-wind-dev/openfast/modules/openfast-library/src/FAST_Library.f90:445:76
    #2 0x7f0d5f5ea22e in fast::OpenFAST::step(bool)
    /mnt/vdb/home/mhenryde/exawind/exawind-manager/environments/nalu-wind-dev/openfast/glue-codes/openfast-cpp/src/OpenFAST.cpp:1436:17

This PR fixes this error.

FAST_CreateCheckpoint expects a fixed sized char buffer of size 1025:
`CHARACTER(KIND=C_CHAR), INTENT(IN ) ::
CheckpointRootName_c(IntfStrLen)`. However the c++ is taking a 1 char
string and sending a pointer to that data to the Fortran. The Fortran
`TRANSFER` function then throws a good old:

```
==2684227==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x5120002144e8 at pc 0x557e98358a61 bp 0x7ffc0f87ea90 sp 0x7ffc0f87e248
READ of size 1025 at 0x5120002144e8 thread T0
    #0 0x557e98358a60 in memcpy /mnt/vdb/home/jrood/goose/spack/var/spack/stage/spack-stage-llvm-17.0.6-fzo52dlnsdgyyb3wgxrrlxmnvepk6esa/spack-src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115:5
    OpenFAST#1 0x7f0d5b25c311 in FAST_CreateCheckpoint /mnt/vdb/home/mhenryde/exawind/exawind-manager/environments/nalu-wind-dev/openfast/modules/openfast-library/src/FAST_Library.f90:445:76
    OpenFAST#2 0x7f0d5f5ea22e in fast::OpenFAST::step(bool)
    /mnt/vdb/home/mhenryde/exawind/exawind-manager/environments/nalu-wind-dev/openfast/glue-codes/openfast-cpp/src/OpenFAST.cpp:1436:17
```

This PR fixes this error.
@deslaughter deslaughter changed the base branch from main to rc-4.1.1 June 24, 2025 00:16
@andrew-platt andrew-platt added this to the v4.1.1 milestone Jun 24, 2025
@deslaughter deslaughter merged commit 514da37 into OpenFAST:rc-4.1.1 Jun 25, 2025
12 checks passed
@deslaughter deslaughter self-assigned this Jun 25, 2025
@marchdf marchdf deleted the fix-cpp-createchkp branch June 25, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants