NOAA-PMEL / Ferret

The Ferret program from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
55 stars 20 forks source link

Ferret crash with string function strindex mathematics inside substring #1343

Open karlmsmith opened 7 years ago

karlmsmith commented 7 years ago

Reported by @karlmsmith on 24 May 2013 20:49 UTC Strange crash when I try to was playing with some Ferret string functions using the latest version (6.85) of Ferret. Obviously low priority as the obvious work-around is demonstrated below prior to the crash. Just wondering if this might indicate some bigger issue hiding somewhere.

list substring("($netcdf_version)",1,strindex("($netcdf_version)"," "))
 !-> list substring("4.3.0 of May  9 2013 10:39:37 $",1,strindex("4.3.0 of May  9 2013 10:39:37 $"," "))
             VARIABLE : SUBSTRING("4.3.0 of May  9 2013 10:39:37 $",1,STRINDEX("4.3.0 of May  9 2013 10:39:37 $"," "))
        "4.3.0 "
let idx = strindex("($netcdf_version)"," ")
 !-> DEFINE VARIABLE idx = strindex("4.3.0 of May  9 2013 10:39:37 $"," ")
list substring("($netcdf_version)",1,idx)
 !-> list substring("4.3.0 of May  9 2013 10:39:37 $",1,idx)
             VARIABLE : SUBSTRING("4.3.0 of May  9 2013 10:39:37 $",1,IDX)
        "4.3.0 "
list substring("($netcdf_version)",1,idx-1)
 !-> list substring("4.3.0 of May  9 2013 10:39:37 $",1,idx-1)
             VARIABLE : SUBSTRING("4.3.0 of May  9 2013 10:39:37 $",1,IDX-1)
        "4.3.0"
let idx = strindex("($netcdf_version)"," ") - 1
 !-> DEFINE VARIABLE idx = strindex("4.3.0 of May  9 2013 10:39:37 $"," ") - 1
list substring("($netcdf_version)",1,idx)
 !-> list substring("4.3.0 of May  9 2013 10:39:37 $",1,idx)
             VARIABLE : SUBSTRING("4.3.0 of May  9 2013 10:39:37 $",1,IDX)
        "4.3.0"
list substring("($netcdf_version)",1,strindex("($netcdf_version)"," ") - 1)
 !-> list substring("4.3.0 of May  9 2013 10:39:37 $",1,strindex("4.3.0 of May  9 2013 10:39:37 $"," ") - 1)
 uvar_stk_err
 uvar_stk_err
 usr_v_gd
STOP gcf_get_axis_srcs

Migrated-From: http://dunkel.pmel.noaa.gov/trac/ferret/ticket/2071

karlmsmith commented 7 years ago

Comment by @AnsleyManke on 30 May 2013 23:37 UTC It's always good to hear about any crash or unexplained STOP.

Another workaround is to put the third argument in grave accents:

list substring("($netcdf_version)",1,strindex("($netcdf_version)"," ")-1)

The behavior, getting a result from strindex and feeding it in as an argument to another string function, is not new. Even with oldest versions of Ferret,

yes? def sym  a_string = 4.3 is the version
yes? list substring("($a_string)",1,strindex("($a_string)"," ") - 1)
 !-> list substring("4.3 is the version",1,strindex("4.3 is the version"," ") - 1)
 uvar_stk_err
 uvar_stk_err
 usr_v_gd
STOP gcf_get_axis_srcs statement executed

Because it's not new and does not happen with numeric variables, say for instance,

let a = 12
let b = a/2
list substring("($netcdf_version)",1,b-1)
 !-> list substring("4.3.0 of May  3 2013 16:02:47 $",1,b-1)
             VARIABLE : SUBSTRING("4.3.0 of May  3 2013 16:02:47 $",1,B-1)
        "4.3.0"

I would say that the issue lurking around is confined to something having to do with the context and stack handling of expressions involving strings. Let's leave this as a low priority.

karlmsmith commented 7 years ago

Comment by @AnsleyManke on 30 May 2013 23:39 UTC That should have been, with the workaround of putting the strindex expression in grave accents,

list substring("($netcdf_version)",1,`strindex("($netcdf_version)"," ")-1`)
 !-> list substring("4.3.0 of May  3 2013 16:02:47 $",1,5)
             VARIABLE : SUBSTRING("4.3.0 of May  3 2013 16:02:47 $",1,5)
        "4.3.0"