CARTAvis / carta-backend

Source code repository for the backend component of CARTA, a new visualization tool designed for the ALMA, the VLA and the SKA pathfinders.
https://cartavis.github.io/
GNU General Public License v3.0
22 stars 10 forks source link

[backend crash] loading non-existent HDU via URL causing the backend crashing #1365

Closed kswang1029 closed 2 months ago

kswang1029 commented 3 months ago

Describe the bug Assuming we have a FITS image with image HDUs at indices 1, 6, 7, if we access

http://localhost:3002/?file=Users/kswang/set_QA_e2e_v2/spire500_ext.fits[6]

the 6th HDU image loads properly. However, if we access

http://localhost:3002/?file=Users/kswang/set_QA_e2e_v2/spire500_ext.fits[2]

(ie HDU 2 which is not an image), the backend will crash with error messages:

[CARTA] [critical] ArrayBase::diagonal() - diagonal out of range zsh: segmentation fault

The macOS crash report shows:
Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libcasa_casa.7.dylib                   0x1049fc61c std::__1::__shared_ptr_pointer<casacore::RegularFileIO*, std::__1::shared_ptr<casacore::ByteIO>::__shared_ptr_default_delete<casacore::ByteIO, casacore::RegularFileIO>, std::__1::allocator<casacore::RegularFileIO>>::__on_zero_shared() + 12
1   libcasa_casa.7.dylib                   0x1049babdc std::__1::shared_ptr<casacore::MultiFileBase>::~shared_ptr() + 72
2   libsystem_c.dylib                      0x1946d9ec4 __cxa_finalize_ranges + 476
3   libsystem_c.dylib                      0x1946d9c4c exit + 44
4   libdyld.dylib                          0x194834554 dyld4::LibSystemHelpers::exit(int) const + 20
5   dyld                                   0x1944c3f7c start + 2320

To Reproduce Steps to reproduce the behavior:

  1. try to load a FITS image with multiple image HDUs with the URL approach
  2. try to load a non-existent HDU index and see crash

Expected behavior The backend should not crash and handle this exception gracefully.

Screenshots or videos If applicable, add screenshots/videos to help explain your problem.

Platform info (please complete the following information):

Additional context Add any other context about the problem here.