Hi Orion,
I agree that something has gone awry before you get into the _Nclstr_match_ic function.  For what it's worth, I ran the same code in gdb here at NCAR as follows:
ncl 0>  class_out = NhlGetClassResources("contourPlotClass", "")
ncl 1> print(dimsizes(class_out))
(0)     610
ncl 2> cnConst = str_match_ic(class_out, "cnConst")
Breakpoint 1, _Nclstr_match_ic () at userAddFuncs.c:3760
3760	    int has_missing = 0;
(gdb) n
3771	    ng_size_t output_str_size = 0;
(gdb) 
3780	    input_strs = (string *) NclGetArgValue(
(gdb) 
3790	    if (input_strs == NULL)
(gdb) 
3796	    if(type != NCL_string)
(gdb) 
3802	    if(has_missing_input_strs)
(gdb) 
3804	        ret_missing.stringval = missing_input_strs.stringval;
(gdb) 
3805	        has_missing = 1;
(gdb) 
3812	    input_expr = (string *) NclGetArgValue(
(gdb) 
3822	    if (input_expr == NULL)
(gdb) 
3828	    if(type == NCL_string)
(gdb) 
3830	        char *reg_exp = NrmQuarkToString(input_expr[0]);
(gdb) 
3835	        if(strlen(reg_exp) > 0)
(gdb) 
3837	            if(regcomp(&expr,reg_exp,REG_ICASE|REG_EXTENDED) != 0)
(gdb) 
3850	    str_size = 1;
(gdb) 
3851	    for(i=0; i<ndim_input_strs; i++)
(gdb) 
3852	        str_size *= dimsz_input_strs[i];
(gdb) p dimsz_input_strs   
$1 = {610, 8589934592, 4294967298, 4354594080, 0, 0, 4294971392, 4354594080, 0, 4353687552, 4353032194, 4353069440, 140734799799664, 2048, 140734799799920, 4296697968, 4294967298, 4354594080, 0, 0, 17592186048512, 4354158336, 261993005056, 0, 140734799799776, 4353687552, 0, 4310887584, 0, 0, 0, 0}
(gdb) n
3851	    for(i=0; i<ndim_input_strs; i++)
(gdb) n
3854	    output_strs = (string *) NclMalloc(str_size*sizeof(string));
(gdb) n
3855	    if (! output_strs)
(gdb) p output_strs
$2 = (string *) 0x104106800
(gdb) p str_size*sizeof(string)
$3 = 4880
It would be hard to diagnose this without running the version that is crashing. Now I see that Mary has responded to you as well, but maybe this at least shows you what it should look like for this code fragment. 
 -dave
On Jul 13, 2012, at 4:37 PM, Orion Poplawski wrote:
> Sending this to the ncl-talk list to see if we can get any more insight.
> 
> Summary - seeing a segfault in Fedora/EPEL RPMs of ncl.
> 
> This is where I've tracked it to now.
> 
> In userAddFuncs.c:_Nclstr_match_ic()
> 
>     str_size = 1;
>     for(i=0; i<ndim_input_strs; i++)
>         str_size *= dimsz_input_strs[i];
> 
>     output_strs = (string *) NclMalloc(str_size*sizeof(string));
>     if (! output_strs)
>     {
>         NHLPERROR((NhlFATAL,ENOMEM,NULL));
>         return NhlFATAL;
>     }
> 
> It appears that ndim_input_strs is 1, and
> 
> (gdb) print dimsz_input_strs
> $17 = {0 <repeats 13 times>, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 
> 0, 0, 0}
> 
> so str_size=0, NclMalloc(0) returns null and we return NhlFATAL which somehow 
> ends up segfaulting.
> 
> I can't grok how ncl handles arguments, seems very complicated.
> 
> I believe things have gone awry before this point, but that is the symptom I see.
> 
> continuing:
> 
> 3485            NHLPERROR((NhlFATAL,ENOMEM,NULL));
> (gdb)
> fatal:["userAddFuncs.c":3485]:[errno=12]
> 3486            return NhlFATAL;
> (gdb)
> 3532    }
> (gdb)
> 0x00000000 in ?? ()
> 
> so perhaps the stack is already smashed.
> 
> FWIW - get the same with 6.1.0-beta.
> 
> Any more suggestions for debugging this?
> 
> On 06/22/2012 01:57 AM, Paul Scorer wrote:
>> Greetings,
>> 
>> I write as I have stamped on a bug in both the i686 and x86_64 versions
>> of ncl as distributed with F15 and F16. I have not tested other
>> versions.
>> 
>> The specific packages tested were
>> 
>> ncl-6.0.0-2.fc16.i686
>> and
>> ncl-6.0.0-2.fc15.x86_64
>> 
>> A simple test is to start ncl and enter the script as below. This is an
>> example script from
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/str_match.shtml
>> 
>> $ ncl
>> Copyright (C) 1995-2011 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 6.0.0
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>> ncl 0> class_out = NhlGetClassResources("contourPlotClass", "")
>> ncl 1> cnConst = str_match_ic(class_out, "cnConst")
>> Segmentation fault
>> $
>> 
>> It the same for both str_match() and str_match_ic()
>> 
>> I have taken this up with Mary Haley  <haley@ucar.edu> of
>> ncl-talk@ucar.edu
>> 
>> Clearly, they cannot support a build done by others. However, she has
>> noted that there have been a number of other issues with the RedHat
>> build of ncl, and has suggested that this may relate to the optimiser
>> options used.
>> 
>>> From my point of view the matter has been resolved by downloading a
>> version of the ncl binary from Earth System Grid, but I am sure you
>> would agree that this is something that should get fixed.
>> 
>> HTH
>> 
>> PaulS
>> 
> 
> 
> -- 
> Orion Poplawski
> Technical Manager                     303-415-9701 x222
> NWRA/CoRA Division                    FAX: 303-415-9702
> 3380 Mitchell Lane                  orion@cora.nwra.com
> Boulder, CO 80301              http://www.cora.nwra.com
> 
> 
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 13 17:59:05 2012
This archive was generated by hypermail 2.1.8 : Wed Jul 18 2012 - 14:33:00 MDT