spacetelescope / drizzle

A package for combining dithered images into a single image
https://spacetelescope-drizzle.readthedocs.io/en/latest/
Other
51 stars 26 forks source link

Segfault in drizzle 1.14.x #118

Closed jdavies-st closed 1 year ago

jdavies-st commented 1 year ago

I'm seeing a very consistent segfault in drizzle for all 1.14.x versions, which also means it happens for all jwst 1.12.x versions as well, which require this version of drizzle. I.e. the current release. To reproduce:

from astroquery.mast import Observations
from jwst.step import ResampleStep

filename = "jw01345002001_14201_00001_nrcalong_cal.fits"
uri = f"mast:JWST/product/{filename}"
Observations.download_file(uri)

result = ResampleStep.call(filename)

and the result:

2023-09-28 16:26:11,835 - stpipe.ResampleStep - INFO - ResampleStep instance created.
2023-09-28 16:26:12,042 - stpipe.ResampleStep - INFO - Step ResampleStep running with args ('jw01345002001_14201_00001_nrcalong_cal.fits',).
2023-09-28 16:26:12,043 - stpipe.ResampleStep - INFO - Step ResampleStep parameters are: {'pre_hooks': [], 'post_hooks': [], 'output_file': None, 'output_dir': None, 'output_ext': '.fits', 'output_use_model': False, 'output_use_index': True, 'save_results': True, 'skip': False, 'suffix': None, 'search_output_file': True, 'input_dir': '', 'pixfrac': 1.0, 'kernel': 'square', 'fillval': 'INDEF', 'weight_type': 'ivm', 'output_shape': None, 'crpix': None, 'crval': None, 'rotation': None, 'pixel_scale_ratio': 1.0, 'pixel_scale': None, 'output_wcs': '', 'single': False, 'blendheaders': True, 'allowed_memory': None, 'in_memory': True}
2023-09-28 16:26:12,309 - stpipe.ResampleStep - INFO - Using drizpars reference file: /data/beegfs/astro-storage/groups/jwst/common/crds_cache/jwst_ops/references/jwst/nircam/jwst_nircam_drizpars_0001.fits
2023-09-28 16:26:12,341 - stpipe.ResampleStep - INFO - Driz parameter kernel: square
2023-09-28 16:26:12,341 - stpipe.ResampleStep - INFO - Driz parameter pixfrac: 1.0
2023-09-28 16:26:12,341 - stpipe.ResampleStep - INFO - Driz parameter fillval: INDEF
2023-09-28 16:26:12,341 - stpipe.ResampleStep - INFO - Driz parameter weight_type: ivm
2023-09-28 16:26:12,342 - stpipe.ResampleStep - INFO - Output pixel scale ratio: 1.0
2023-09-28 16:26:12,488 - stpipe.ResampleStep - INFO - Resampling science data
2023-09-28 16:26:15,795 - stpipe.ResampleStep - INFO - Drizzling (2048, 2048) --> (2068, 2075)
Segmentation fault

It is segfaulting on CentOS Linux release 7.9.2009 (Core), and the system info of the machine:

In [1]: import platform; print(platform.platform())
   ...: import sys; print("Python", sys.version)
   ...: import astropy; print("astropy", astropy.__version__)
   ...: import numpy; print("Numpy", numpy.__version__)
   ...: import drizzle; print("drizzle", drizzle.__version__)
Linux-3.10.0-1160.76.1.el7.x86_64-x86_64-with-glibc2.17
Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
astropy 5.3.3
Numpy 1.25.2
drizzle 1.14.2

It runs fine on the following (no segfault) on the same machine with drizzle 1.13.7:

In [1]: import platform; print(platform.platform())
   ...: import sys; print("Python", sys.version)
   ...: import astropy; print("astropy", astropy.__version__)
   ...: import numpy; print("Numpy", numpy.__version__)
   ...: import drizzle; print("drizzle", drizzle.__version__)
Linux-3.10.0-1160.76.1.el7.x86_64-x86_64-with-glibc2.17
Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
astropy 5.3.3
Numpy 1.25.2
drizzle 1.13.7

No segfaults at all on my Mac laptop.

jdavies-st commented 1 year ago

Not knowing much about the C code in this repo, I ran valgrind on the command that was segfaulting:

$ valgrind --leak-check=yes strun resample jw01345002001_14201_00001_nrcalong_cal.fits
==177752== Memcheck, a memory error detector                                                                                                                 
==177752== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.                                                                                   
==177752== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info                                                                                
==177752== Command: /home/jdavies/miniconda3/envs/drizzle/bin/strun resample jw01345002001_14201_00001_nrcalong_cal.fits                                     
==177752==                                                                                                                                                   
<snip>
==177752== 
==177752== HEAP SUMMARY:
==177752==     in use at exit: 7,127,850 bytes in 5,822 blocks
==177752==   total heap usage: 89,435 allocs, 83,613 frees, 1,654,616,203 bytes allocated
==177752== 
==177752== 10 bytes in 1 blocks are definitely lost in loss record 50 of 952
==177752==    at 0x403389F: realloc (vg_replace_malloc.c:1451)
==177752==    by 0xDC3361A: realloc (alloc.rs:140)
==177752==    by 0xDC3361A: shrink (alloc.rs:308)
==177752==    by 0xDC3361A: shrink<u8, alloc::alloc::Global> (raw_vec.rs:440)
==177752==    by 0xDC3361A: shrink_to_fit<u8, alloc::alloc::Global> (raw_vec.rs:357)
==177752==    by 0xDC3361A: shrink_to_fit<u8, alloc::alloc::Global> (mod.rs:1043)
==177752==    by 0xDC3361A: alloc::vec::Vec<T,A>::into_boxed_slice (mod.rs:1102)
==177752==    by 0xDC32DFA: alloc::ffi::c_str::CString::_from_vec_unchecked (c_str.rs:348)
==177752==    by 0xDBF6884: <T as alloc::ffi::c_str::CString::new::SpecNewImpl>::spec_new_impl (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBED0D4: pyo3::pyclass::create_type_object::PyTypeBuilder::build (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE55A2: pyo3::pyclass::create_type_object::create_type_object (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBCB3E3: pyo3::sync::GILOnceCell<T>::init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEB555: pyo3::impl_::pyclass::lazy_type_object::LazyTypeObjectInner::get_or_try_init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBD9706: rpds::rpds_py (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEEDF0: pyo3::impl_::pymodule::ModuleDef::make_module (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE6D48: PyInit_rpds (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0x5F597F: UnknownInlinedFun (importdl.c:169)
==177752==    by 0x5F597F: UnknownInlinedFun (import.c:2386)
==177752==    by 0x5F597F: _imp_create_dynamic (import.c.h:446)
==177752== 
==177752== 17 bytes in 1 blocks are definitely lost in loss record 94 of 952
==177752==    at 0x403389F: realloc (vg_replace_malloc.c:1451)
==177752==    by 0xDC32A6F: realloc (alloc.rs:140)
==177752==    by 0xDC32A6F: grow_impl (alloc.rs:217)
==177752==    by 0xDC32A6F: grow (alloc.rs:270)
==177752==    by 0xDC32A6F: alloc::raw_vec::finish_grow (raw_vec.rs:472)
==177752==    by 0xDC32D8F: grow_exact<u8, alloc::alloc::Global> (raw_vec.rs:423)
==177752==    by 0xDC32D8F: try_reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:342)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:333)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (mod.rs:939)
==177752==    by 0xDC32D8F: alloc::ffi::c_str::CString::_from_vec_unchecked (c_str.rs:346)
==177752==    by 0xDBF6884: <T as alloc::ffi::c_str::CString::new::SpecNewImpl>::spec_new_impl (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBED0D4: pyo3::pyclass::create_type_object::PyTypeBuilder::build (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE5902: pyo3::pyclass::create_type_object::create_type_object (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBCB3E3: pyo3::sync::GILOnceCell<T>::init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEB555: pyo3::impl_::pyclass::lazy_type_object::LazyTypeObjectInner::get_or_try_init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBD9533: rpds::rpds_py (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEEDF0: pyo3::impl_::pymodule::ModuleDef::make_module (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE6D48: PyInit_rpds (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0x5F597F: UnknownInlinedFun (importdl.c:169)
==177752==    by 0x5F597F: UnknownInlinedFun (import.c:2386)
==177752==    by 0x5F597F: _imp_create_dynamic (import.c.h:446)
==177752== 
==177752== 17 bytes in 1 blocks are definitely lost in loss record 95 of 952
==177752==    at 0x403389F: realloc (vg_replace_malloc.c:1451)
==177752==    by 0xDC32A6F: realloc (alloc.rs:140)
==177752==    by 0xDC32A6F: grow_impl (alloc.rs:217)
==177752==    by 0xDC32A6F: grow (alloc.rs:270)
==177752==    by 0xDC32A6F: alloc::raw_vec::finish_grow (raw_vec.rs:472)
==177752==    by 0xDC32D8F: grow_exact<u8, alloc::alloc::Global> (raw_vec.rs:423)
==177752==    by 0xDC32D8F: try_reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:342)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:333)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (mod.rs:939)
==177752==    by 0xDC32D8F: alloc::ffi::c_str::CString::_from_vec_unchecked (c_str.rs:346)
==177752==    by 0xDBF6884: <T as alloc::ffi::c_str::CString::new::SpecNewImpl>::spec_new_impl (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBED0D4: pyo3::pyclass::create_type_object::PyTypeBuilder::build (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE523F: pyo3::pyclass::create_type_object::create_type_object (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBCB3E3: pyo3::sync::GILOnceCell<T>::init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEB555: pyo3::impl_::pyclass::lazy_type_object::LazyTypeObjectInner::get_or_try_init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBD968E: rpds::rpds_py (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEEDF0: pyo3::impl_::pymodule::ModuleDef::make_module (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE6D48: PyInit_rpds (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0x5F597F: UnknownInlinedFun (importdl.c:169)
==177752==    by 0x5F597F: UnknownInlinedFun (import.c:2386)
==177752==    by 0x5F597F: _imp_create_dynamic (import.c.h:446)
==177752== 
==177752== 17 bytes in 1 blocks are definitely lost in loss record 96 of 952
==177752==    at 0x403389F: realloc (vg_replace_malloc.c:1451)
==177752==    by 0xDC32A6F: realloc (alloc.rs:140)
==177752==    by 0xDC32A6F: grow_impl (alloc.rs:217)
==177752==    by 0xDC32A6F: grow (alloc.rs:270)
==177752==    by 0xDC32A6F: alloc::raw_vec::finish_grow (raw_vec.rs:472)
==177752==    by 0xDC32D8F: grow_exact<u8, alloc::alloc::Global> (raw_vec.rs:423)
==177752==    by 0xDC32D8F: try_reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:342)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (raw_vec.rs:333)
==177752==    by 0xDC32D8F: reserve_exact<u8, alloc::alloc::Global> (mod.rs:939)
==177752==    by 0xDC32D8F: alloc::ffi::c_str::CString::_from_vec_unchecked (c_str.rs:346)
==177752==    by 0xDBF6884: <T as alloc::ffi::c_str::CString::new::SpecNewImpl>::spec_new_impl (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBED0D4: pyo3::pyclass::create_type_object::PyTypeBuilder::build (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE5C5F: pyo3::pyclass::create_type_object::create_type_object (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBCB3E3: pyo3::sync::GILOnceCell<T>::init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBEB555: pyo3::impl_::pyclass::lazy_type_object::LazyTypeObjectInner::get_or_try_init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE2BAD: pyo3::impl_::pyclass::lazy_type_object::LazyTypeObject<T>::get_or_init (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBE2198: pyo3::pyclass_init::PyClassInitializer<T>::create_cell (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBD5DB2: rpds::_::<impl rpds::HashTrieSetPy>::__pymethod___iter____ (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752==    by 0xDBD0819: pyo3::impl_::trampoline::trampoline (in /home/jdavies/miniconda3/envs/drizzle/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so)
==177752== 
==177752== 600 bytes in 1 blocks are possibly lost in loss record 455 of 952
==177752==    at 0x402E725: malloc (vg_replace_malloc.c:393)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:101)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:586)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:2003)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:1996)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:712)
==177752==    by 0x4F483F: UnknownInlinedFun (gcmodule.c:2283)
==177752==    by 0x4F483F: _PyObject_GC_NewVar (gcmodule.c:2318)
==177752==    by 0x4F342C: UnknownInlinedFun (tupleobject.c:50)
==177752==    by 0x4F342C: PyTuple_New (tupleobject.c:75)
==177752==    by 0x509D54: r_object (marshal.c:1222)
==177752==    by 0x50999C: r_object (marshal.c:1406)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x5C7A63: read_object (marshal.c:1535)
==177752==    by 0x5EF071: UnknownInlinedFun (marshal.c:1842)
==177752==    by 0x5EF071: marshal_loads (marshal.c.h:148)
==177752==    by 0x50F43A: _PyEval_EvalFrameDefault (ceval.c:5025)
==177752== 
==177752== 624 bytes in 1 blocks are possibly lost in loss record 461 of 952
==177752==    at 0x402E725: malloc (vg_replace_malloc.c:393)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:101)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:586)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:2003)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:1996)
==177752==    by 0x4F483F: UnknownInlinedFun (obmalloc.c:712)
==177752==    by 0x4F483F: UnknownInlinedFun (gcmodule.c:2283)
==177752==    by 0x4F483F: _PyObject_GC_NewVar (gcmodule.c:2318)
==177752==    by 0x4F342C: UnknownInlinedFun (tupleobject.c:50)
==177752==    by 0x4F342C: PyTuple_New (tupleobject.c:75)
==177752==    by 0x509D54: r_object (marshal.c:1222)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x5C7A63: read_object (marshal.c:1535)
==177752==    by 0x5EF071: UnknownInlinedFun (marshal.c:1842)
==177752==    by 0x5EF071: marshal_loads (marshal.c.h:148)
==177752==    by 0x50F43A: _PyEval_EvalFrameDefault (ceval.c:5025)
==177752== 
==177752== 1,192 bytes in 2 blocks are possibly lost in loss record 695 of 952
==177752==    at 0x402E725: malloc (vg_replace_malloc.c:393)
==177752==    by 0x51B395: UnknownInlinedFun (obmalloc.c:101)
==177752==    by 0x51B395: UnknownInlinedFun (obmalloc.c:586)
==177752==    by 0x51B395: UnknownInlinedFun (obmalloc.c:2003)
==177752==    by 0x51B395: UnknownInlinedFun (obmalloc.c:1996)
==177752==    by 0x51B395: UnknownInlinedFun (obmalloc.c:712)
==177752==    by 0x51B395: UnknownInlinedFun (object.c:189)
==177752==    by 0x51B395: _PyCode_New (codeobject.c:481)
==177752==    by 0x509B3D: r_object (marshal.c:1463)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x509E91: r_object (marshal.c:1228)
==177752==    by 0x509986: r_object (marshal.c:1403)
==177752==    by 0x5C7A63: read_object (marshal.c:1535)
==177752==    by 0x5EF071: UnknownInlinedFun (marshal.c:1842)
==177752==    by 0x5EF071: marshal_loads (marshal.c.h:148)
==177752==    by 0x50F43A: _PyEval_EvalFrameDefault (ceval.c:5025)
==177752== 
==177752== 1,856 bytes in 16 blocks are definitely lost in loss record 758 of 952
==177752==    at 0x402E725: malloc (vg_replace_malloc.c:393)
==177752==    by 0x4014857: dl_open_worker (in /usr/lib64/ld-2.17.so)
==177752==    by 0x400F7D3: _dl_catch_error (in /usr/lib64/ld-2.17.so)
==177752==    by 0x4013B8A: _dl_open (in /usr/lib64/ld-2.17.so)
==177752==    by 0x4C40FAA: dlopen_doit (in /usr/lib64/libdl-2.17.so)
==177752==    by 0x400F7D3: _dl_catch_error (in /usr/lib64/ld-2.17.so)
==177752==    by 0x4C415AC: _dlerror_run (in /usr/lib64/libdl-2.17.so)
==177752==    by 0x4C41040: dlopen@@GLIBC_2.2.5 (in /usr/lib64/libdl-2.17.so)
==177752==    by 0x5F6BC5: _PyImport_FindSharedFuncptr (dynload_shlib.c:80)
==177752==    by 0x5F5933: UnknownInlinedFun (importdl.c:139)
==177752==    by 0x5F5933: UnknownInlinedFun (import.c:2386)
==177752==    by 0x5F5933: _imp_create_dynamic (import.c.h:446)
==177752==    by 0x52BC6A: cfunction_vectorcall_FASTCALL (methodobject.c:427)
==177752==    by 0x517786: UnknownInlinedFun (ceval.c:7329)
==177752==    by 0x517786: _PyEval_EvalFrameDefault (ceval.c:5381)
==177752== 
==177752== 139,207 bytes in 77 blocks are possibly lost in loss record 941 of 952
==177752==    at 0x402E725: malloc (vg_replace_malloc.c:393)
==177752==    by 0x54B365: UnknownInlinedFun (obmalloc.c:101)
==177752==    by 0x54B365: UnknownInlinedFun (obmalloc.c:586)
==177752==    by 0x54B365: UnknownInlinedFun (obmalloc.c:2003)
==177752==    by 0x54B365: UnknownInlinedFun (obmalloc.c:1996)
==177752==    by 0x54B365: UnknownInlinedFun (obmalloc.c:712)
==177752==    by 0x54B365: UnknownInlinedFun (unicodeobject.c:1425)
==177752==    by 0x54B365: UnknownInlinedFun (unicodeobject.c:2371)
==177752==    by 0x54B365: PyUnicode_Substring (unicodeobject.c:12593)
==177752==    by 0x510071: _PyEval_EvalFrameDefault (ceval.c:5330)
==177752==    by 0x5C82CD: UnknownInlinedFun (pycore_ceval.h:73)
==177752==    by 0x5C82CD: _PyEval_Vector (ceval.c:6439)
==177752==    by 0x5C79CE: PyEval_EvalCode (ceval.c:1154)
==177752==    by 0x5E1622: UnknownInlinedFun (bltinmodule.c:1077)
==177752==    by 0x5E1622: builtin_exec (bltinmodule.c.h:465)
==177752==    by 0x51C106: cfunction_vectorcall_FASTCALL_KEYWORDS (methodobject.c:443)
==177752==    by 0x517786: UnknownInlinedFun (ceval.c:7329)
==177752==    by 0x517786: _PyEval_EvalFrameDefault (ceval.c:5381)
==177752==    by 0x535102: UnknownInlinedFun (pycore_ceval.h:73)
==177752==    by 0x535102: UnknownInlinedFun (ceval.c:6439)
==177752==    by 0x535102: _PyFunction_Vectorcall (call.c:393)
==177752==    by 0x524A52: UnknownInlinedFun (pycore_call.h:92)
==177752==    by 0x524A52: object_vacall (call.c:819)
==177752==    by 0x553A4B: PyObject_CallMethodObjArgs (call.c:879)
==177752==    by 0x552E4B: UnknownInlinedFun (import.c:1737)
==177752==    by 0x552E4B: PyImport_ImportModuleLevelObject (import.c:1836)
==177752== 
==177752== LEAK SUMMARY:
==177752==    definitely lost: 1,917 bytes in 20 blocks
==177752==    indirectly lost: 0 bytes in 0 blocks
==177752==      possibly lost: 141,623 bytes in 81 blocks
==177752==    still reachable: 6,984,310 bytes in 5,721 blocks
==177752==                       of which reachable via heuristic:
==177752==                         stdstring          : 38 bytes in 1 blocks
==177752==         suppressed: 0 bytes in 0 blocks
==177752== Reachable blocks (those to which a pointer was found) are not shown.
==177752== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==177752== 
==177752== For lists of detected and suppressed errors, rerun with: -s
==177752== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)
jdavies-st commented 1 year ago

I also ran git bisect, and it appears the bug was introduced here

$ git bisect bad
5618520d77feca11163e5859982308b15e8c5bed is the first bad commit
commit 5618520d77feca11163e5859982308b15e8c5bed
Author: Mihai Cara <mihail.cara@gmail.com>
Date:   Sun Jul 9 17:35:55 2023 -0400

    Do not error on invalid pixmap for polygon intersection

 src/cdrizzlebox.c  | 1394 ++++++++++++++++++++++++----------------------------
 src/cdrizzlemap.c  |  156 +++---
 src/cdrizzlemap.h  |   18 +-
 src/cdrizzleutil.h |   33 +-
 4 files changed, 746 insertions(+), 855 deletions(-)
jdavies-st commented 1 year ago

So I compiled the drizzle C extension in debug mode

$ git diff
diff --git a/setup.py b/setup.py
index 62a586c..cc31bb8 100755
--- a/setup.py
+++ b/setup.py
@@ -22,6 +22,7 @@ def get_extensions():
         'include_dirs': [],
         'libraries': [],
         'define_macros': [],
+        'extra_compile_args': ["-g"],
     }
     cfg['include_dirs'].append(numpy.get_include())
     cfg['include_dirs'].append(srcdir)

And then ran the unit tests under gdb, and get the same (probably) segfault:

$ gdb -ex run -ex bt -ex quit --args python -m pytest
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/jdavies/miniconda3/envs/drizzle/bin/python3.11...
<snip>
========================================================================= test session starts =========================================================================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/jdavies/dev/drizzle
configfile: pyproject.toml
plugins: jwst-1.12.1, cov-4.1.0, asdf-2.15.1
collected 48 items                                                                                                                                                    

drizzle/tests/test_cdrizzle.py 
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7158f63 in setbuffer () from /lib64/libc.so.6
#0  0x00007ffff7158f63 in setbuffer () from /lib64/libc.so.6
#1  0x00007fff4e10ca3a in driz_log_init (handle=<optimized out>) at /home/jdavies/dev/drizzle/src/cdrizzleutil.h:210
#2  driz_log_message (message=0x7fff4e117a84 "starting do_kernel_square") at /home/jdavies/dev/drizzle/src/cdrizzleutil.h:223
#3  do_kernel_square (p=p@entry=0x1649030) at /home/jdavies/dev/drizzle/src/cdrizzlebox.c:857
#4  0x00007fff4e1146e8 in utest_cdrizzle (argc=argc@entry=1, argv=argv@entry=0x7fffffffb830) at /home/jdavies/dev/drizzle/src/tests/utest_cdrizzle.c:806
#5  0x00007fff4e105f4a in test_cdrizzle (self=<optimized out>, args=<optimized out>) at /home/jdavies/dev/drizzle/src/cdrizzleapi.c:440
#6  0x0000000000525f30 in cfunction_call ()
#7  0x0000000000502d54 in _PyObject_MakeTpCall.localalias ()
#8  0x000000000050f025 in _PyEval_EvalFrameDefault ()
#9  0x0000000000535103 in _PyFunction_Vectorcall ()
#10 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#11 0x0000000000535103 in _PyFunction_Vectorcall ()
#12 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#13 0x0000000000535103 in _PyFunction_Vectorcall ()
#14 0x0000000000506418 in _PyObject_FastCallDictTstate.localalias ()
#15 0x000000000053cf46 in _PyObject_Call_Prepend ()
#16 0x000000000060d273 in slot_tp_call ()
#17 0x0000000000502d54 in _PyObject_MakeTpCall.localalias ()
#18 0x000000000050f025 in _PyEval_EvalFrameDefault ()
#19 0x0000000000535103 in _PyFunction_Vectorcall ()
#20 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#21 0x0000000000535103 in _PyFunction_Vectorcall ()
#22 0x0000000000506418 in _PyObject_FastCallDictTstate.localalias ()
#23 0x000000000053cf46 in _PyObject_Call_Prepend ()
#24 0x000000000060d273 in slot_tp_call ()
#25 0x000000000053f2fc in PyObject_Call ()
#26 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#27 0x0000000000535103 in _PyFunction_Vectorcall ()
#28 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#29 0x0000000000535103 in _PyFunction_Vectorcall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.el7_9.x86_64
---Type <return> to continue, or q <return> to quit---
#30 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#31 0x0000000000535103 in _PyFunction_Vectorcall ()
#32 0x0000000000506418 in _PyObject_FastCallDictTstate.localalias ()
#33 0x000000000053cf46 in _PyObject_Call_Prepend ()
#34 0x000000000060d273 in slot_tp_call ()
#35 0x0000000000502d54 in _PyObject_MakeTpCall.localalias ()
#36 0x000000000050f025 in _PyEval_EvalFrameDefault ()
#37 0x0000000000535103 in _PyFunction_Vectorcall ()
#38 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#39 0x0000000000535103 in _PyFunction_Vectorcall ()
#40 0x0000000000506418 in _PyObject_FastCallDictTstate.localalias ()
#41 0x000000000053cf46 in _PyObject_Call_Prepend ()
#42 0x000000000060d273 in slot_tp_call ()
#43 0x0000000000502d54 in _PyObject_MakeTpCall.localalias ()
#44 0x000000000050f025 in _PyEval_EvalFrameDefault ()
#45 0x0000000000535103 in _PyFunction_Vectorcall ()
#46 0x0000000000512d5a in _PyEval_EvalFrameDefault ()
#47 0x0000000000535103 in _PyFunction_Vectorcall ()
#48 0x0000000000506418 in _PyObject_FastCallDictTstate.localalias ()
#49 0x000000000053cf46 in _PyObject_Call_Prepend ()
#50 0x000000000060d273 in slot_tp_call ()
#51 0x0000000000502d54 in _PyObject_MakeTpCall.localalias ()
#52 0x000000000050f025 in _PyEval_EvalFrameDefault ()
#53 0x00000000005c82ce in _PyEval_Vector ()
#54 0x00000000005c79cf in PyEval_EvalCode ()
#55 0x00000000005e1623 in builtin_exec ()
#56 0x000000000051c107 in cfunction_vectorcall_FASTCALL_KEYWORDS ()
#57 0x000000000051bff1 in PyObject_Vectorcall ()
#58 0x000000000050f025 in _PyEval_EvalFrameDefault ()
#59 0x0000000000535103 in _PyFunction_Vectorcall ()
#60 0x00000000005f343f in pymain_run_module ()
#61 0x00000000005f2e4a in Py_RunMain.localalias ()
#62 0x00000000005b6e19 in Py_BytesMain ()
#63 0x00007ffff710a555 in __libc_start_main () from /lib64/libc.so.6
#64 0x00000000005b6c6f in _start ()
A debugging session is active.

    Inferior 1 [process 266838] will be killed.

Hopefully this helps.