bugGNU Octave - Bugs: bug #64999, [octave forge] (netcdf) Octave...

 
 

bug #64999: [octave forge] (netcdf) Octave segfaults on exit after running test_netcdf

Submitter:  Rafael Laboissière <rlaboiss>
Submitted:  Fri 08 Dec 2023 08:19:50 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  lostbard
Originator Name:  Open/Closed:  * Closed
Release:  * other Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 20 Dec 2023 03:46:18 PM UTC, comment #20: 

They merged in my pull request, so it should appear on the next version of the netcdf library.

Closing this

John Donoghue <lostbard>
Group Member
Wed 13 Dec 2023 05:07:49 AM UTC, comment #19: 

Forget my last comment, please. I wrote it without seeing that a fix has been already proposed upstream by John.

Rafael Laboissière <rlaboiss>
Wed 13 Dec 2023 05:03:29 AM UTC, comment #18: 

I confirm that using -DENABLE_BYTERANGE=OFF when building the netcdf library on Debian makes the crash disappear.

I would be willing to report this bug to the upstream authors of netcdf, in the case we can find a minimal code that produces the crash.

Rafael Laboissière <rlaboiss>
Tue 12 Dec 2023 11:27:03 PM UTC, comment #17: 

I found what I believe is the issue and sent a patch up to netcdf for the issue [1]


[1] https://github.com/Unidata/netcdf-c/pull/2827

John Donoghue <lostbard>
Group Member
Mon 11 Dec 2023 08:35:35 PM UTC, comment #16: 

In mxe-octave the netcdf is being build with cmake using options:

       -DBUILD_UTILITIES=OFF \
        -DENABLE_EXAMPLES=OFF \
        -DENABLE_TESTS=OFF \
        -DENABLE_PARALLEL_TESTS=OFF \
        -DENABLE_DAP_REMOTE_TESTS=OFF \
        -DENABLE_DAP=ON \
        -DENABLE_NETCDF_4=ON \
        -DENABLE_BYTERANGE=OFF \
        -DENABLE_LOGGING=ON \
        -DBUILD_TESTING=no \

If I use the same options when building the library for my fedora machine, I dont have any issues running the netcdf octave package.

If I use the same options but with ENABLE_BYTERANGE=ON, then I see the same crash.

Looking at netcdf 4.9.0, the BYTERANGE option defaulted to off. FOr 4.9.2, it defaults to ON.

John Donoghue <lostbard>
Group Member
Mon 11 Dec 2023 08:28:04 PM UTC, comment #15: 

netcdf library

John Donoghue <lostbard>
Group Member
Mon 11 Dec 2023 06:35:41 PM UTC, comment #14: 


comment #13:

> I did notice that netcdf build with -DENABLE_BYTERANGE=OFF does not appear to crash.


Do you mean the netdcf library or the netcdf package?

Rafael Laboissière <rlaboiss>
Mon 11 Dec 2023 01:41:45 PM UTC, comment #13: 

I did notice that netcdf build with -DENABLE_BYTERANGE=OFF does not appear to crash.

John Donoghue <lostbard>
Group Member
Sun 10 Dec 2023 04:29:41 PM UTC, comment #12: 


comment #9:

> How about something like:
>
>
> ncid = netcdf.open('filethatdoesntexists.nc','NC_NOWRITE');
> exit
>
>


Crash:


octave:1> pkg load netcdf
octave:2> ncid = netcdf.open('filethatdoesntexists.nc','NC_NOWRITE');
error: No such file or directory
error: called from
    open at line 24 column 28
octave:3> exit
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault (core dumped)


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sun 10 Dec 2023 01:48:44 PM UTC, comment #11: 

According to this bug report [1] it has been happening for a while, and appeared with the update of the netcdf library from 4.9.0 to 4.9.1. From the bug report hdf5 was still at 1.12.1 during the time it was happening.



[1] https://github.com/Unidata/netcdf-c/issues/2617

John Donoghue <lostbard>
Group Member
Sun 10 Dec 2023 01:31:41 PM UTC, comment #10: 

I guess also, is there anyway to tell with version of hdf5 octave was compiled with vs what version netcdf is using ?

John Donoghue <lostbard>
Group Member
Sun 10 Dec 2023 01:07:09 PM UTC, comment #9: 

How about something like:


ncid = netcdf.open('filethatdoesntexists.nc','NC_NOWRITE');
exit





John Donoghue <lostbard>
Group Member
Sun 10 Dec 2023 07:34:37 AM UTC, comment #8: 

No crash

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sun 10 Dec 2023 04:02:22 AM UTC, comment #7: 

I wonder if its h5 in general or some interaction with h5 from netcdf?

ie: does something like


x = [1 2 3 4]
save -hdf5 test.h5
exit



also crash ?

John Donoghue <lostbard>
Group Member
Sat 09 Dec 2023 08:10:44 PM UTC, comment #6: 

Attached is a backtrace with debug symbols. The relevant part seams to be:

Thread 1 "octave-gui" received signal SIGSEGV, Segmentation fault.
0x00007fffe01301b0 in ?? ()
(gdb) thread apply all bt
<...deleted...>
Thread 1 (Thread 0x7fffeb8bf880 (LWP 343770) "octave-gui"):
#0  0x00007fffe01301b0 in ??? ()
#1  0x00007ffff38fefec in H5FD__free_cls (cls=0x7fffc8119a30) at ../../../src/H5FD.c:188
#2  0x00007ffff395c288 in H5I__mark_node (key=0x0, _udata=<synthetic pointer>, _info=0x5555555c0550) at ../../../src/H5Iint.c:340
#3  H5I_clear_type (type=<optimized out>, force=false, app_ref=<optimized out>) at ../../../src/H5Iint.c:286
#4  0x00007ffff38fef90 in H5FD_term_package () at ../../../src/H5FD.c:147
#5  0x00007ffff3845f1c in H5_term_library () at ../../../src/H5.c:338
#6  0x00007ffff38463e1 in H5close () at ../../../src/H5.c:1006
#7  0x00007ffff75182e1 in octave::load_save_system::~load_save_system (this=this@entry=0x7fffc80022c0, __in_chrg=<optimized out>) at ../libinterp/corefcn/load-save.cc:271
#8  0x00007ffff74f4b9c in octave::interpreter::~interpreter (this=this@entry=0x7fffc8001470, __in_chrg=<optimized out>) at ../libinterp/corefcn/interpreter.cc:635
#9  0x00007ffff6d6fccb in std::default_delete<octave::interpreter>::operator() (this=this@entry=0x7fffffffddf8, __ptr=0x7fffc8001470) at /usr/include/c++/13/bits/unique_ptr.h:99
#10 0x00007ffff6d6fcf1 in std::unique_ptr<octave::interpreter, std::default_delete<octave::interpreter> >::~unique_ptr (this=0x7fffffffddf8, __in_chrg=<optimized out>) at /usr/include/c++/13/tuple:125
#11 0x00007ffff6d6d34c in octave::application::~application (this=this@entry=0x7fffffffdbf0, __in_chrg=<optimized out>) at ../libinterp/octave.cc:298
#12 0x00005555555566fa in octave::qt_application::~qt_application (this=0x7fffffffdbf0, __in_chrg=<optimized out>) at ../libgui/src/qt-application.h:61
#13 main (argc=1, argv=<optimized out>) at ../src/main-gui.cc:164
(gdb)


The problem indeed apearst o be in hdf library.

Dmitri.
--


(file #55426)

Dmitri A. Sergatskov <dasergatskov>
Sat 09 Dec 2023 06:53:37 PM UTC, comment #5: 

I do not see the problem on Fedora 39 or Centos Stream 9 (hdf5-1.12.1-7.el9.1.x86_64), but I see on ubuntu 23.10 (libhdf5-103-1/mantic,now 1.10.8+repack1-1ubuntu1)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 09 Dec 2023 06:28:39 PM UTC, comment #4: 

trying with fedora 39 with octave 8.4.0 and libnetcdf 4.9.0 works ok for me.

What version of hdf5 is being used ?

John Donoghue <lostbard>
Group Member
Sat 09 Dec 2023 02:10:39 PM UTC, comment #3: 

ok - how about an explicit pkg unload before calling exit ?

John Donoghue <lostbard>
Group Member
Sat 09 Dec 2023 02:05:19 PM UTC, comment #2: 

I do not know when the bug started happening.

I get this with your code (after changing “name” ⇒ “fname”):


$ octave-cli --silent
octave:1> pkg load netcdf
octave:2> fname = [tempname '-octave-netcdf.nc'];
octave:3> ncid = netcdf.create(fname,'NC_CLOBBER');
octave:4> dimid = netcdf.defDim(ncid,'time',0);
octave:5> varidd = netcdf.defVar(ncid,'time','double',[dimid]);
octave:6> netcdf.close(ncid)
octave:7> exit
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault


Rafael Laboissière <rlaboiss>
Sat 09 Dec 2023 01:37:59 PM UTC, comment #1: 

Has it started doing it with a new version of octave or libnetcdf or the netcdf package or thats not known?

Just to reverify that its a issue in the read rather thansomething appening prior with the write, can you run:



name = [tempname '-octave-netcdf.nc'];

ncid = netcdf.create(fname,'NC_CLOBBER');
dimid = netcdf.defDim(ncid,'time',0);
varidd = netcdf.defVar(ncid,'time','double',[dimid]);
netcdf.close(ncid)


And then provide the generated file?

John Donoghue <lostbard>
Group Member
Fri 08 Dec 2023 08:19:50 AM UTC, original submission:  

I am experiencing segmentation faults when using the netcdf package.

I am using:

  • Octave 8.4.0
  • netcdf package 1.0.17
  • libnetcdf 4.9.2
  • g++ 13.2.0


This is what happens for me:


$ octave-cli --silent
octave:1> pkg load netcdf
octave:2> test_netcdf
Using NetCDF library version "4.9.2 of Sep  4 2023 05:51:05 $"
run test_netcdf_constant..............   OK
run test_netcdf_create................   OK
run test_netcdf_low_level_interface...   OK
run test_netcdf_unlim................. warning: variable size 0 or currently too large to process
warning: called from
    getVar at line 31 column 28
    test_netcdf_unlim at line 30 column 3
    test_netcdf at line 50 column 7

  OK
run test_netcdf_datatypes.............   OK
run test_netcdf_scalar_variable.......   OK
run test_netcdf_attributes............   OK
run test_netcdf_high_level_interface..   OK
run test_netcdf_ncwriteschema.........   OK
run test_netcdf_ncwriteschema_unlim...   OK
run test_netcdf_ncwriteschema_chunking   OK
run test_netcdf_ncwriteschema_group...   OK
run test_netcdf_user_types............   OK
run bug_47014.........................   OK
octave:3> exit
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault


The same thing happens when feeding the commands through a pipe:


$ echo 'pkg load netcdf; test_netcdf' | octave-cli --silent
Using NetCDF library version "4.9.2 of Sep  4 2023 05:51:05 $"
run test_netcdf_constant..............   OK
run test_netcdf_create................   OK
run test_netcdf_low_level_interface...   OK
run test_netcdf_unlim................. warning: variable size 0 or currently too large to process
warning: called from
    getVar at line 31 column 28
    test_netcdf_unlim at line 30 column 3
    test_netcdf at line 50 column 7

  OK
run test_netcdf_datatypes.............   OK
run test_netcdf_scalar_variable.......   OK
run test_netcdf_attributes............   OK
run test_netcdf_high_level_interface..   OK
run test_netcdf_ncwriteschema.........   OK
run test_netcdf_ncwriteschema_unlim...   OK
run test_netcdf_ncwriteschema_chunking   OK
run test_netcdf_ncwriteschema_group...   OK
run test_netcdf_user_types............   OK
run bug_47014.........................   OK
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault


Here is the backtrace in gdb:


$ gdb octave-cli
(gdb) run < tmp
Starting program: /usr/bin/octave-cli < tmp
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffed5ff6c0 (LWP 2322115)]
[New Thread 0x7fffe49ff6c0 (LWP 2322116)]
Using NetCDF library version "4.9.2 of Sep  4 2023 05:51:05 $"
run test_netcdf_constant..............   OK
run test_netcdf_create................   OK
run test_netcdf_low_level_interface...   OK
run test_netcdf_unlim................. warning: variable size 0 or currently too large to process
warning: called from
    getVar at line 31 column 28
    test_netcdf_unlim at line 30 column 3
    test_netcdf at line 50 column 7

  OK
run test_netcdf_datatypes.............   OK
run test_netcdf_scalar_variable.......   OK
run test_netcdf_attributes............   OK
run test_netcdf_high_level_interface..   OK
run test_netcdf_ncwriteschema.........   OK
run test_netcdf_ncwriteschema_unlim...   OK
run test_netcdf_ncwriteschema_chunking   OK
run test_netcdf_ncwriteschema_group...   OK
run test_netcdf_user_types............   OK
run bug_47014.........................   OK

Thread 1 "octave-cli" received signal SIGSEGV, Segmentation fault.
0x00007fffe3ff3ea0 in ?? ()
(gdb) bt
#0  0x00007fffe3ff3ea0 in ?? ()
#1  0x00007ffff551279c in ?? () from /lib/x86_64-linux-gnu/libhdf5_serial.so.103
#2  0x00007ffff55761a5 in H5I_clear_type () from /lib/x86_64-linux-gnu/libhdf5_serial.so.103
#3  0x00007ffff55128ce in H5FD_term_package () from /lib/x86_64-linux-gnu/libhdf5_serial.so.103
#4  0x00007ffff544d1cc in H5_term_library () from /lib/x86_64-linux-gnu/libhdf5_serial.so.103
#5  0x00007ffff544e5c1 in H5close () from /lib/x86_64-linux-gnu/libhdf5_serial.so.103
#6  0x00007ffff79c7ffd in octave::load_save_system::~load_save_system() () from /usr/lib/x86_64-linux-gnu/octave/8.4.0/liboctinterp.so.11
#7  0x00007ffff79a05e6 in octave::interpreter::~interpreter() () from /usr/lib/x86_64-linux-gnu/octave/8.4.0/liboctinterp.so.11
#8  0x00007ffff70b4abf in octave::application::~application() () from /usr/lib/x86_64-linux-gnu/octave/8.4.0/liboctinterp.so.11
#9  0x00005555555563cb in ?? ()
#10 0x00007ffff58456ca in __libc_start_call_main (main=main@entry=0x5555555561b0, argc=argc@entry=1, argv=argv@entry=0x7fffffffde58) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x00007ffff5845785 in __libc_start_main_impl (main=0x5555555561b0, argc=1, argv=0x7fffffffde58, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde48)
    at ../csu/libc-start.c:360
#12 0x00005555555564e1 in ?? ()
-verbatin-

Rafael Laboissière <rlaboiss>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55426:  bt_netcdf.txt.gz added by dasergatskov (2KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by rlaboiss (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-12-20 lostbard StatusNone Fixed
        Assigned toNone lostbard
        Open/ClosedOpen Closed
    2023-12-09 dasergatskov Attached File- Added bt_netcdf.txt.gz, #55426
    2023-12-08 jwe Summary[octave forge] (netcff) Octave segfaults on exit after running test_netcdf [octave forge] (netcdf) Octave segfaults on exit after running test_netcdf

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code