[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

960206: [netCDFPerl-1.0.4] core dump

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: 960206: [netCDFPerl-1.0.4] core dump
  • Date: Tue, 06 Feb 96 08:46:24 -0700

Mark,

>Date: 05 Feb 1996 15:47:10 -0700 
>From: Mark Borges <address@hidden>
>Organization: CIRES, University of Colorado 
>To: <address@hidden>
>Subject: [netCDFPerl-1.0.4] core dump 
>Keywords: 199602052247.AA21977 

In the above message you wrote:

> This simple script:
> 
> ------------------------------------------------------------------------------
> #!/usr/local/bin/perl
> use NetCDF;
> $ncid = NetCDF::open($ARGV[0], NetCDF::NOWRITE);
> die "Couldn't open netCDF file\n" if $ncid < 0;
>  NetCDF::attget($ncid, NetCDF::GLOBAL, "history", \$attval);
> print "globalATT=$attval\n";
> exit;
> ------------------------------------------------------------------------------
> 
> produces a core dump:
> 
>       $ ./pstub /Datasets/nmc/uwnd.92.nc
>       Segmentation Fault(coredump)
>       $ uname -a
>       SunOS solberg 5.3 Generic_101318-70 sun4m sparc
>       $ /usr/local/bin/perl -v
>       
>       This is perl, version 5.001
> 
>               Unofficial patchlevel 1m.
> 
>       Copyright 1987-1994, Larry Wall
> 
> (where pstub is the executable containing the lines above).

For technical reasons having to do with the API for writing perl
extension modules, variables that are passed by reference to NetCDFPerl
functions must exist.  In the above code, the `\$attval' argument to
NetCDF::attget() doesn't really exist -- resulting in a core dump.  The
solution (as you've already discovered) is to assign the variable a
dummy value, e.g.

    $attval="";
    NetCDF::attget($ncid, NetCDF::GLOBAL, "history", \$attval);

--------
Steve Emmerson   <address@hidden>