-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Signed-off-by: Steven Hahn <[email protected]>
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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?
Signed-off-by: Steven Hahn <[email protected]>
No description provided.