Skip to content
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

Address Sanitizer found issues with egyro_test #20

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Conversation

quantumsteve
Copy link
Collaborator

No description provided.

@@ -718,8 +718,7 @@ subroutine read_namelist(params,infile,echo_in,outdir)
!write(6,*) TRIM(magnetic_field_filename),len(TRIM(magnetic_field_filename))

tmp=len(TRIM(magnetic_field_filename))
if (magnetic_field_filename(tmp-2:tmp).ne.'.h5'.and. &
magnetic_field_filename(tmp-5:tmp-5).ne.'.') then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbeidler3 @cianciosa What is this line trying to check? The default filename length is too short for this slice.

Copy link
Collaborator

@cianciosa cianciosa Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably checking for nimrod input files or something else that has an extension of 5 characters. I'm surprised that second conditional is even getting evaluate since by default the first conditional should be false. There's no need to evaluate the second conditional. If this was written as

if (magnetic_field_filename(tmp-2:tmp).ne.'.h5') then
    if (magnetic_field_filename(tmp-5:tmp-5).ne.'.') then

This wouldn't trigger since it would never evaluate the inner if statement on the default case.

However for correctness there should be a check of tmp first to make sure we are not outside the string bounds in any case. If magnetic_field_filename = 'aa' for instance that first conditional would read out of bounds too.

The only thing I can guess that this looking for is really long filenames with the full path. This could end up longer than the 150 characters allowed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a bounds check before the array slicing, which I think will at least fix the asan issue.

CMakeLists.txt Outdated
@@ -102,7 +102,7 @@ target_link_libraries (korc_depends
INTERFACE

sanitizer
$<$<BOOL:${OpenMP_Fortran_FOUND}>:OpenMP::OpenMP_Fortran>
$<$<BOOL:${OpenMP_Fortran_FOUND}>:OpenMP::OpenMP_Fortran>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we have tabs to spaces issue here. Can we realign this?

@quantumsteve quantumsteve merged commit a72182d into main Feb 29, 2024
2 checks passed
@quantumsteve quantumsteve deleted the fix_egyro_test branch February 29, 2024 22:46
mbeidler3 pushed a commit that referenced this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants