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 11 forks source link

CARTA crashes when using beam tables with 64-bit floats #1166

Closed Jordatious closed 1 year ago

Jordatious commented 2 years ago

An issue was discovered by @amirkazemim where certain FITS cubes he was producing with a custom script would not open on the IDIA CARTA server. CARTA would crash trying to read the FITS file in file browser, after which it would display a "Connection lost" error. Amir reduced the issue to the beam table being written as 64-bit floats (the astropy default), whereas when 32-bit beam tables were used, they opened just fine in CARTA. The cubes which have beam tables as 64-bit floats open fine in ds9, and were converted fine to IDIA's HDF5 schema. Therefore it seems like this might be a CARTA bug.

I was hoping one of the CARTA developers could reproduce the issue, but if not, please let us know and we can produce a cube.

kswang1029 commented 1 year ago

@Jordatious would you be able to provide a test cube for investigation please?

Jordatious commented 1 year ago

Perhaps @amirkazemim can (privately, assuming it's proprietary data)?

kswang1029 commented 1 year ago

Perhaps @amirkazemim can (privately, assuming it's proprietary data)?

a cutout (noisy sky) would be just useful if it is proprietary

amirkazemim commented 1 year ago

I created a random noise array, saved it once with a 32-bit beam table and another time with the astropy-default (I think 64-bit) beam table.

There are two fits files in the zipped attachment, noise_cube_32.fits can be opened with CARTA. However, CARTA v3.0.1 stalls on noise_cube_64.fits because of its beam table. Hope this helps.

noise_cubes.zip

kswang1029 commented 1 year ago

I created a random noise array, saved it once with a 32-bit beam table and another time with the astropy-default (I think 64-bit) beam table.

There are two fits files in the zipped attachment, noise_cube_32.fits can be opened with CARTA. However, CARTA stalls on noise_cube_64.fits because of its beam table. Hope this helps.

noise_cubes.zip

Thank you for supplying the test images.

kswang1029 commented 1 year ago

@amirkazemim @Jordatious could you try the v4-beta release to see if the issue persists? I tried but both test images can be loaded just fine.

Jordatious commented 1 year ago

Are you able to check v4-beta @amirkazemim?

amirkazemim commented 1 year ago

Unfortunately, I am not able to check with v4-beta, @Jordatious.

Jordatious commented 1 year ago

I'm unable to load the 64-bit image provided above in either v3.0.1 or v4.0-beta.1 using the IDIA controller / server version. Whenever I try to open it, or click on it within the file browser, the backend disconnects.

kswang1029 commented 1 year ago

ok. with macOS Apple silicon chip, it works with v4-beta. However, with macOS intel chip, it crashes.

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000d00000000 Exception Codes: 0x0000000000000001, 0x0000000d00000000 Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [76499]

VM Region Info: 0xd00000000 is not in any region. Bytes after previous region: 51227545601 Bytes before following region: 123089651085312 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL VM_ALLOCATE (reserved) 112998000-11299b000 [ 12K] r--/r-- SM=NUL ...(unallocated) ---> GAP OF 0x6ffef8540000 BYTES Stack Guard 70000aedb000-70000aedc000 [ 4K] ---/rwx SM=NUL

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libcasa_fits.6.dylib 0x10befd289 casacore::BinaryTableExtension::~BinaryTableExtension() + 313 1 libcasa_fits.6.dylib 0x10bf42809 casacore::BinaryTable::BinaryTable(casacore::FitsInput&, void ()(char const, casacore::FITSError::ErrorLevel), bool, bool) + 19465 2 libcasa_images.6.dylib 0x10c5fe509 casacore::ImageFITSConverter::readBeamsTable(casacore::ImageInfo&, casacore::String const&, casacore::DataType) + 2729 3 libcasa_images.6.dylib 0x10c5436aa casacore::FITSImage::setup() + 954 4 libcasa_images.6.dylib 0x10c543225 casacore::FITSImage::FITSImage(casacore::String const&, unsigned int, unsigned int) + 245 5 carta_backend 0x10a41ae81 carta::FitsLoader::OpenFile(std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&) + 961 6 carta_backend 0x10a380761 carta::FileExtInfoLoader::FillFileInfoFromImage(CARTA::FileInfoExtended&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator >&) + 49 7 carta_backend 0x10a3805ed carta::FileExtInfoLoader::FillFileExtInfo(CARTA::FileInfoExtended&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator >&) + 477 8 carta_backend 0x10a378b72 carta::FileExtInfoLoader::FillFitsFileInfoMap(std::1::map<std::1::basic_string<char, std::1::char_traits, std::1::allocator >, CARTA::FileInfoExtended, std::1::less<std::__1::basic_string<char, std::1::char_traits, std::1::allocator > >, std::1::allocator<std::1::pair<std::1::basic_string<char, std::1::char_traits, std::1::allocator > const, CARTA::FileInfoExtended> > >&, std::1::basic_string<char, std::1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::1::char_traits, std::__1::allocator >&) + 594 9 carta_backend 0x10a5a0fda carta::Session::FillExtendedFileInfo(std::1::map<std::1::basic_string<char, std::__1::char_traits, std::1::allocator >, CARTA::FileInfoExtended, std::1::less<std::1::basic_string<char, std::1::char_traits, std::1::allocator > >, std::1::allocator<std::1::pair<std::1::basic_string<char, std::1::char_traits, std::1::allocator > const, CARTA::FileInfoExtended> > >&, CARTA::FileInfo&, std::1::basic_string<char, std::1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::1::char_traits, std::1::allocator > const&, std::1::basic_string<char, std::1::char_traits, std::1::allocator >&) + 362 10 carta_backend 0x10a5a2a02 carta::Session::OnFileInfoRequest(CARTA::FileInfoRequest const&, unsigned int) + 194 11 carta_backend 0x10a5c50c2 carta::SessionManager::OnMessage(uWS::WebSocket<false, true, carta::PerSocketData>*, std::1::basic_string_view<char, std::__1::char_traits >, uWS::OpCode) + 4386 12 carta_backend 0x10a5d3374 uWS::WebSocketContext<false, true, carta::PerSocketData>::handleFragment(char, unsigned long, unsigned int, int, bool, uWS::WebSocketState, void) + 1300 13 carta_backend 0x10a5d2607 bool uWS::WebSocketProtocol<true, uWS::WebSocketContext<false, true, carta::PerSocketData> >::consumeMessage<6u, unsigned char>(unsigned char, char&, unsigned int&, uWS::WebSocketState, void) + 711 14 carta_backend 0x10a5d2290 uWS::WebSocketProtocol<true, uWS::WebSocketContext<false, true, carta::PerSocketData> >::consume(char, unsigned int, uWS::WebSocketState, void) + 272 15 carta_backend 0x10a5d212e auto uWS::WebSocketContext<false, true, carta::PerSocketData>::init()::'lambda'(auto, char, int)::operator()(auto, char*, int) const + 142 16 carta_backend 0x10a6900a5 us_loop_run + 133 17 carta_backend 0x10a5c6d57 carta::SessionManager::RunApp() + 343 18 carta_backend 0x10a507a41 main + 3809 19 dyld 0x1128e852e start + 462