Segmentation fault on Linux using Cells 24.10

I am currently using Aspose.Cells both on Windows and Linux.

Since I only require Cells in some situations, I have a thin wrapper that allows me to dynamically load Aspose.Cells only if it is required and allows me to reduce the size of packages by not including Aspose.Cells when it is not required.

This works well, both on Windows and some Linux machines. However, on a couple of Linux installs (both on a Linux machine and in Docker) the code seg faults as soon as Aspose::Cells::Startup is called.

The tail of the output from running tests through strace is below for a failing build, which will hopefully provide some insight as to what is happening when the seg fault occurs. Please advise how I can resolve this issue?

Thanks,
Liam

[pid 2488374] newfstatat(AT_FDCWD, “/etc/localtime”, {st_mode=S_IFREG|0644, st_size=3664, …}, 0) = 0
[pid 2488374] readlink(“/etc/localtime”, “/usr/share/zoneinfo/Europe/Londo”…, 4095) = 33
[pid 2488374] — SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x55ec2cd358} —
[pid 2488374] rt_sigaction(SIGSEGV, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3f148545d0}, NULL, 8) = 0

@lbj821

It seems you are encountering a segmentation fault when calling Aspose::Cells::Startup on certain Linux installations, including Docker environments. This issue can be quite challenging to diagnose, especially since it works on some systems but not others.

Here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Dependencies: Ensure that all required dependencies for Aspose.Cells are installed on the problematic Linux systems. Sometimes, missing libraries can lead to segmentation faults.

  2. Environment Consistency: Verify that the environment (including the OS version, installed libraries, and configurations) is consistent across the working and non-working systems. Differences in the environment can lead to unexpected behavior.

  3. Docker Configuration: If you are running this in a Docker container, ensure that the container has the necessary permissions and configurations. Sometimes, Docker containers may have restrictions that could affect library loading.

  4. Debugging: Use debugging tools like gdb to get more insight into where the segmentation fault occurs. This can provide a stack trace that may help identify the root cause.

  5. Logging: Implement logging around the Aspose::Cells::Startup call to capture any additional context or errors that may occur before the segmentation fault.

  6. Contact Support: If the issue persists, consider reaching out to Aspose support with detailed information about your environment, the exact steps to reproduce the issue, and any logs or stack traces you have gathered.

While there are no direct solutions available in the provided context, these steps may help you identify and resolve the segmentation fault issue you are experiencing.

If you have further details or specific error messages, feel free to share them for more targeted assistance.

@lbj821
Please provide detailed code and the specific Linux version and language, time zone, etc. where the problem occurs, so that the problem can be reproduced.
In addition, if Aspose.Cells is used without dynamic loading, will the problem occur on Linux?
Thank you.

I can’t see a way to attach code, so I will paste a .cpp and a makefile at the bottom. They are based heavily on the provided examples so should be simple enough to run. The issue appears to be related to hooks which are called when an SSL context is destroyed. The versions I have are curl 8.8.0-1 and ssl 3.2.2-1.

example.cpp

#include
#include <curl/curl.h>

#include “Aspose.Cells.h”

using namespace Aspose::Cells;

int main()
{

CURL* curl;
CURLcode res;

curl = curl_easy_init();
if (curl) {
	curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
	res = curl_easy_perform(curl);
	if (res != CURLE_OK)
		fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
	///// The below line causes a segfault!            /////
	///// But only if we have linked with Aspose.Cells /////
	curl_easy_cleanup(curl);
}
std::cout << "Done Curling!" << std::endl;

Aspose::Cells::Startup();
License lic;
lic.SetLicense(u"Aspose.Cells.lic");

Workbook workbook(FileFormatType::Xlsx);
Worksheet sheet = workbook.GetWorksheets().Get(0);
Cells cells = sheet.GetCells();
cells.Get(u"A1").PutValue(u"Hello World");
cells.Get(0, 1).PutValue(u"Income");
cells.Get(1, 0).PutValue(u"Company A");
cells.Get(2, 0).PutValue(u"Company B");
cells.Get(3, 0).PutValue(u"Company C");
cells.SetColumnWidth(0, 20);
cells.Get(1, 1).PutValue(10000);
cells.Get(2, 1).PutValue(20000);
cells.Get(3, 1).PutValue(30000);

int chartIndex = sheet.GetCharts().Add(ChartType::Column, 9, 9, 21, 15);
Chart chart = sheet.GetCharts().Get(chartIndex);
chart.GetNSeries().Add(u"B2:B4", true);
chart.GetNSeries().SetCategoryData(u"A2:A4");
Series aSeries = chart.GetNSeries().Get(0);
aSeries.SetName(u"=B1");
chart.SetShowLegend(true);
chart.GetTitle().SetText(u"Income Analysis");
ImageOrPrintOptions options;
options.SetHorizontalResolution(300);
options.SetVerticalResolution(300);
chart.ToImage(u"output.png", options);

workbook.Save(u"output.xlsx");
workbook.Save(u"output.pdf");

std::cout << "Hello World" << std::endl;
Aspose::Cells::Cleanup();

}

CMakeLists.txt

cmake_minimum_required (VERSION 3.8)
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0110 NEW)

include(GenerateExportHeader)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
set (CMAKE_CXX_STANDARD 23)

project(“example”)

if( NOT DEFINED BUILD_DEPS )
set(BUILD_DEPS “/path/to/folder/with/libcurl”)
endif()

set(CMAKE_APPBUNDLE_PATH “${BUILD_DEPS}/lib/cmake” “${BUILD_DEPS}/share/cmake” “${BUILD_DEPS}/cmake”)
link_directories(“${BUILD_DEPS}/lib”)

include_directories(“${BUILD_DEPS}/include”)
include(FindCURL)
find_package(CURL 8.5.0 REQUIRED)

find_package(Aspose.Cells REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR}/… NO_DEFAULT_PATH)

set(SRC_ROOT “${CMAKE_CURRENT_SOURCE_DIR}”)
include_directories(“${SRC_ROOT}/src”)

file(GLOB_RECURSE SOURCE “${SRC_ROOT}/src/*.cpp”)
add_executable(${PROJECT_NAME} ${SOURCE})
target_link_libraries(${PROJECT_NAME} Aspose.Cells CURL::libcurl)

@lbj821,

Thank you for sharing the sample code snippet and additional environment information. We will assess your issue and get back to you soon. By the way, you may zip the (complete) sample code/app and attach the zipped archive here.

@lbj821
I compiled curl-8.8.0 and openssl-3.2.2 from source code, modified CMakeLists.txt
CMakeLists.zip (585 Bytes), and tested in the following environment without any problems:
ubuntu 20.04
ubuntu 22.04
ubuntu 24.04
debian 12.5

Build curl:
./config --prefix=/home/dev/Documents/libs/openssl-3.2.2 no-shared no-zlib
make -j
make install

Build openssl:
./configure -prefix=/home/dev/Documents/libs/curl-8.8.0 --disable-shared --with-openssl=/home/dev/Documents/libs/openssl-3.2.2
make -j
make install

Note: I use static linking to link libcurl and openssl.

Thanks for looking into this. I have attached a dockerfile that recreates the problem.

example 1.zip (1.7 KB)

@lbj821
Thanks for further details. Let us investigate and analyze your issue in details. Once we have any new information, we will share it with you. We will get back to you soon.

@lbj821
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSCPP-1134

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@lbj821,

We are pleased to inform you that the issue (Ticket ID: “CELLSCPP-1134”) has been resolved. The fix will be included in the upcoming release (Aspose.Cells for C++ v24.12), which we plan to release in the next few days. We will notify you when the new version is released.

The issues you have found earlier (filed as CELLSCPP-1134) have been fixed in this update.