[GH-ISSUE #241] SIGSEGV on Linux (Debian 9.0) #195

Closed
opened 2026-05-05 11:53:32 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @hdijkema on GitHub (Aug 14, 2019).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/241

Originally assigned to: @jmcnamara on GitHub.

When I issue a 'workbook_close' on linux, I get a segmentation fault when zipOpen is called:

Line 109 in packager.c:

    /* Create a zip container for the xlsx file. */
#ifdef _WIN32
    packager->zipfile = _open_zipfile_win32(packager->filename);
#else
-->    packager->zipfile = zipOpen(packager->filename, 0);
#endif

I don't understand why. I built the latest github clone, using the following commands:

mkdir buildd
cd buildd
cmake .. -DMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug

Build log:

hans@rhialto:~/devel/libxlsxwriter/buildd$ cmake .. -DCMAKE_BUILD_TYPE=Debug 
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
zlib version: 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hans/devel/libxlsxwriter/buildd

Actual building:

hans@rhialto:~/devel/libxlsxwriter/buildd$ cmake --build . --config Debug
Scanning dependencies of target xlsxwriter
[  4%] Building C object CMakeFiles/xlsxwriter.dir/src/app.c.o
[  9%] Building C object CMakeFiles/xlsxwriter.dir/src/chart.c.o
[ 13%] Building C object CMakeFiles/xlsxwriter.dir/src/chartsheet.c.o
[ 18%] Building C object CMakeFiles/xlsxwriter.dir/src/content_types.c.o
[ 22%] Building C object CMakeFiles/xlsxwriter.dir/src/core.c.o
[ 27%] Building C object CMakeFiles/xlsxwriter.dir/src/custom.c.o
[ 31%] Building C object CMakeFiles/xlsxwriter.dir/src/drawing.c.o
[ 36%] Building C object CMakeFiles/xlsxwriter.dir/src/format.c.o
[ 40%] Building C object CMakeFiles/xlsxwriter.dir/src/hash_table.c.o
[ 45%] Building C object CMakeFiles/xlsxwriter.dir/src/packager.c.o
[ 50%] Building C object CMakeFiles/xlsxwriter.dir/src/relationships.c.o
[ 54%] Building C object CMakeFiles/xlsxwriter.dir/src/shared_strings.c.o
[ 59%] Building C object CMakeFiles/xlsxwriter.dir/src/styles.c.o
[ 63%] Building C object CMakeFiles/xlsxwriter.dir/src/theme.c.o
[ 68%] Building C object CMakeFiles/xlsxwriter.dir/src/utility.c.o
[ 72%] Building C object CMakeFiles/xlsxwriter.dir/src/workbook.c.o
[ 77%] Building C object CMakeFiles/xlsxwriter.dir/src/worksheet.c.o
[ 81%] Building C object CMakeFiles/xlsxwriter.dir/src/xmlwriter.c.o
[ 86%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/ioapi.c.o
[ 90%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o
[ 95%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o
[100%] Linking C static library libxlsxwriter.a
[100%] Built target xlsxwriter
hans@rhialto:~/devel/libxlsxwriter/buildd$

On windows the code works without any problems.

Originally created by @hdijkema on GitHub (Aug 14, 2019). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/241 Originally assigned to: @jmcnamara on GitHub. When I issue a 'workbook_close' on linux, I get a segmentation fault when zipOpen is called: Line 109 in packager.c: ``` /* Create a zip container for the xlsx file. */ #ifdef _WIN32 packager->zipfile = _open_zipfile_win32(packager->filename); #else --> packager->zipfile = zipOpen(packager->filename, 0); #endif ``` I don't understand why. I built the latest github clone, using the following commands: ``` mkdir buildd cd buildd cmake .. -DMAKE_BUILD_TYPE=Debug cmake --build . --config Debug ``` Build log: ``` hans@rhialto:~/devel/libxlsxwriter/buildd$ cmake .. -DCMAKE_BUILD_TYPE=Debug -- The C compiler identification is GNU 6.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- The CXX compiler identification is GNU 6.3.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") zlib version: -- Configuring done -- Generating done -- Build files have been written to: /home/hans/devel/libxlsxwriter/buildd ``` Actual building: ``` hans@rhialto:~/devel/libxlsxwriter/buildd$ cmake --build . --config Debug Scanning dependencies of target xlsxwriter [ 4%] Building C object CMakeFiles/xlsxwriter.dir/src/app.c.o [ 9%] Building C object CMakeFiles/xlsxwriter.dir/src/chart.c.o [ 13%] Building C object CMakeFiles/xlsxwriter.dir/src/chartsheet.c.o [ 18%] Building C object CMakeFiles/xlsxwriter.dir/src/content_types.c.o [ 22%] Building C object CMakeFiles/xlsxwriter.dir/src/core.c.o [ 27%] Building C object CMakeFiles/xlsxwriter.dir/src/custom.c.o [ 31%] Building C object CMakeFiles/xlsxwriter.dir/src/drawing.c.o [ 36%] Building C object CMakeFiles/xlsxwriter.dir/src/format.c.o [ 40%] Building C object CMakeFiles/xlsxwriter.dir/src/hash_table.c.o [ 45%] Building C object CMakeFiles/xlsxwriter.dir/src/packager.c.o [ 50%] Building C object CMakeFiles/xlsxwriter.dir/src/relationships.c.o [ 54%] Building C object CMakeFiles/xlsxwriter.dir/src/shared_strings.c.o [ 59%] Building C object CMakeFiles/xlsxwriter.dir/src/styles.c.o [ 63%] Building C object CMakeFiles/xlsxwriter.dir/src/theme.c.o [ 68%] Building C object CMakeFiles/xlsxwriter.dir/src/utility.c.o [ 72%] Building C object CMakeFiles/xlsxwriter.dir/src/workbook.c.o [ 77%] Building C object CMakeFiles/xlsxwriter.dir/src/worksheet.c.o [ 81%] Building C object CMakeFiles/xlsxwriter.dir/src/xmlwriter.c.o [ 86%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/ioapi.c.o [ 90%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o [ 95%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o [100%] Linking C static library libxlsxwriter.a [100%] Built target xlsxwriter hans@rhialto:~/devel/libxlsxwriter/buildd$ ``` On windows the code works without any problems.
gitea-mirror 2026-05-05 11:53:32 -06:00
Author
Owner

@jmcnamara commented on GitHub (Aug 14, 2019):

What is the return code/error when you compile and run the anatomy.c program in the examples directory?:

https://github.com/jmcnamara/libxlsxwriter/blob/master/examples/anatomy.c

<!-- gh-comment-id:521279446 --> @jmcnamara commented on GitHub (Aug 14, 2019): What is the return code/error when you compile and run the anatomy.c program in the examples directory?: https://github.com/jmcnamara/libxlsxwriter/blob/master/examples/anatomy.c
Author
Owner

@hdijkema commented on GitHub (Aug 14, 2019):

I tried using the system minizip, e.g. it could be using the wrong minizip functions at runtime?

hans@rhialto:~/devel/libxlsxwriter/third_party/minizip$ aptitude search minizip
p   libminizip-dev                                               - compression library - minizip development files                        
i A libminizip1                                                  - compression library - minizip library                                  
p   minizip                                                      - compression library - minizip tools        

because minizip is installed as library on the system?

So I installed libminizip-dev and compiled again using -DUSE_SYSTEM_MINIZIP=On

But it didn't change the behaviour.

<!-- gh-comment-id:521281842 --> @hdijkema commented on GitHub (Aug 14, 2019): I tried using the system minizip, e.g. it could be using the wrong minizip functions at runtime? ``` hans@rhialto:~/devel/libxlsxwriter/third_party/minizip$ aptitude search minizip p libminizip-dev - compression library - minizip development files i A libminizip1 - compression library - minizip library p minizip - compression library - minizip tools ``` because minizip is installed as library on the system? So I installed libminizip-dev and compiled again using -DUSE_SYSTEM_MINIZIP=On But it didn't change the behaviour.
Author
Owner

@hdijkema commented on GitHub (Aug 14, 2019):

https://github.com/jmcnamara/libxlsxwriter/blob/master/examples/anatomy.c

works fine.

It could be some overlap. Multiple minizip's in the linked libraries (included as "third party"). I'm also using QuaZip in my project.

<!-- gh-comment-id:521288779 --> @hdijkema commented on GitHub (Aug 14, 2019): https://github.com/jmcnamara/libxlsxwriter/blob/master/examples/anatomy.c works fine. It could be some overlap. Multiple minizip's in the linked libraries (included as "third party"). I'm also using QuaZip in my project.
Author
Owner

@jmcnamara commented on GitHub (Aug 14, 2019):

anatomy.c works fine.

In that case it is probably a build/link issue in your app and I'm probably not going to be able to help you much.

But if you can reproduce it with a simple program or find an issue in the CMake build let me know and I'll take a look.

Closing for now.

<!-- gh-comment-id:521293467 --> @jmcnamara commented on GitHub (Aug 14, 2019): > anatomy.c works fine. In that case it is probably a build/link issue in your app and I'm probably not going to be able to help you much. But if you can reproduce it with a simple program or find an issue in the CMake build let me know and I'll take a look. Closing for now.
Author
Owner

@hdijkema commented on GitHub (Aug 15, 2019):

You can leave it closed. It was indeed a problem with multiple linked libraries that were included as 'third-party' (clash quazip / libxlsxwriter).

<!-- gh-comment-id:521597732 --> @hdijkema commented on GitHub (Aug 15, 2019): You can leave it closed. It was indeed a problem with multiple linked libraries that were included as 'third-party' (clash quazip / libxlsxwriter).
Author
Owner

@jmcnamara commented on GitHub (Aug 15, 2019):

@hdijkema Thanks for letting me know.

<!-- gh-comment-id:521604853 --> @jmcnamara commented on GitHub (Aug 15, 2019): @hdijkema Thanks for letting me know.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#195
No description provided.