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

HDF_VD_READ segfault #664

Closed
slayoo opened this issue Nov 11, 2019 · 4 comments
Closed

HDF_VD_READ segfault #664

slayoo opened this issue Nov 11, 2019 · 4 comments

Comments

@slayoo
Copy link
Member

slayoo commented Nov 11, 2019

as reported by @tenomoto:

GDL> $ wget https://opendap.larc.nasa.gov/opendap/CALIPSO/LID_L2_05kmAPro-Standard-V4-20/2017/11/CAL_LID_L2_05kmAPro-Standard-V4-20.2017-11-05T07-40-57ZD.hdf
GDL> infile = 'CAL_LID_L2_05kmAPro-Standard-V4-20.2017-11-05T07-40-57ZD.hdf'
GDL> fid = HDF_OPEN(infile,/read)
GDL> vdref = HDF_VD_FIND(fid,"metadata")
GDL> vdid = HDF_VD_ATTACH(fid,vdref,/READ)
GDL> status = HDF_VD_READ(vdid,altitudes,FIELDS="Lidar_Data_Altitudes")
GDL> print, altitudes
Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault"...
Aborted
@alaingdl
Copy link
Contributor

reproduced on my Debian 9.6 :(

@slayoo
Copy link
Member Author

slayoo commented Dec 5, 2019

backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00000000011e6001 in OutAuto<float> (os=..., val=<error reading variable>, w=13, d=6, code=0) at /home/slayoo/devel/gdl/src/ofmt.hpp:220
220	 if (std::isfinite(val)) {
(gdb) bt
#0  0x00000000011e6001 in OutAuto<float>(std::ostream&, float const&, int, int, int) (os=..., val=<error reading variable>, w=13, d=6, code=0)
    at /home/slayoo/devel/gdl/src/ofmt.hpp:220
#1  0x0000000001216e9a in Data_<SpDFloat>::ToStream(std::ostream&, unsigned long long, unsigned long long*) (this=
    0x201adc0, o=..., w=150, actPosPtr=0x7fffffffb0a8) at /home/slayoo/devel/gdl/src/default_io.cpp:1002
#2  0x0000000001909421 in lib::print_os(std::ostream*, EnvT*, int, unsigned long long) (os=0x7ffff4be23a0 <std::cout>, e=
    0x21a6200, parOffset=0, width=150) at /home/slayoo/devel/gdl/src/print.cpp:206
#3  0x0000000001909593 in lib::print(EnvT*) (e=0x21a6200) at /home/slayoo/devel/gdl/src/print.cpp:136
#4  0x0000000001910a3d in PCALL_LIBNode::Run() (this=0x21a4ca0) at /home/slayoo/devel/gdl/src/prognode.cpp:1091
#5  0x0000000000c4c113 in GDLInterpreter::statement(ProgNode*) (this=0x7fffffffd840, _t=0x21a4ca0)
    at /home/slayoo/devel/gdl/src/GDLInterpreter.cpp:96
#6  0x0000000000c4bfc8 in GDLInterpreter::interactive(ProgNode*) (this=0x7fffffffd840, _t=0x21a4ca0)
    at /home/slayoo/devel/gdl/src/GDLInterpreter.cpp:39
#7  0x00000000013c6d39 in DInterpreter::ExecuteLine(std::istream*, unsigned long long) (this=0x7fffffffd840, in=0x0, lineOffset=0)
    at /home/slayoo/devel/gdl/src/dinterpreter.cpp:1286
#8  0x00000000013cb529 in DInterpreter::InterpreterLoop(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    (this=0x7fffffffd840, startup=Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
, batch_files=warning: Type size unknown, assuming 1. Try casting to a known type, or void *.
warning: Type size unknown, assuming 1. Try casting to a known type, or void *.
Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
std::vector of length 0, capacity 0, statement=) at /home/slayoo/devel/gdl/src/dinterpreter.cpp:1774
#9  0x0000000001a0a322 in main(int, char**) (argc=1, argv=0x7fffffffe348) at /home/slayoo/devel/gdl/src/gdl.cpp:461

@slayoo slayoo added the hdf4 label Feb 9, 2020
@slayoo
Copy link
Member Author

slayoo commented Feb 9, 2020

OK, the problem starts when VSread within hdf_vd_read_template() in src/hdf_fun.cpp overwrites housekeeping data of the output variable. If instead of print, altitudes one does print, n_elements(altitudes) no segfaults happens, but GDL outputs a corrupt number (e.g., 4738299825760715383). Apparently, VSread expects a bigger buffer, will try to understand why...

@slayoo
Copy link
Member Author

slayoo commented Feb 9, 2020

Here is a patch: #713
Help welcome on writing a short test that would cover it...

@slayoo slayoo closed this as completed in 30e552b Feb 9, 2020
slayoo added a commit that referenced this issue Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants