[med-svn] [Git][med-team/libsonlib][master] Fix FTBFS and ship a vg-usable libsonlib-dev
Andreas Tille (@tille)
gitlab at salsa.debian.org
Wed Oct 21 19:54:28 BST 2026
Andreas Tille pushed to branch master at Debian Med / libsonlib
Commits:
6e37e6c5 by Andreas Tille at 2026-10-21T20:47:09+02:00
Fix FTBFS and ship a vg-usable libsonlib-dev
Drop CGL_DEBUG=ultra from debian/rules (its -Werror --pedantic broke the
build) and fix the resulting errors via new patches:
- fix_build_errors: sonLibTreap.c use-after-free, stSafeC.c
unused-but-set, include.mk drops --pedantic
- fix_quicktree_clone_child_ids: clear the uninitialized child_ids of
cloned quicktree trees before freeing them (fixes a segfault in the
neighbour-joining tests against libquicktree 2.5)
- python313_compat: unittest.makeSuite -> loadTestsFromTestCase
- fix_test: correct the PYTHONPATH for the test suite
- use_debian_packaged_quicktree: fix -I/usr/include/quicktree typo
Install headers under /usr/include/sonLib and name the static archive
libsonlib.a so it links with -lsonlib as vg does; add an autopkgtest
verifying the vg-style include/link/run. Run only the C test suite
during the build (Python tests exercise unshipped modules and fail on
Python 3.13). Fix upstream URLs (ArtRand -> benedictpaten), drop
unused build-deps, add Multi-Arch: same.
- - - - -
15 changed files:
- + .gitignore
- debian/control
- debian/copyright
- debian/libsonlib-dev.install
- + debian/patches/fix_build_errors.patch
- + debian/patches/fix_quicktree_clone_child_ids.patch
- debian/patches/fix_test.patch
- debian/patches/fix_warnings.patch
- + debian/patches/python313_compat.patch
- debian/patches/series
- debian/patches/use_debian_packaged_quicktree.patch
- debian/rules
- + debian/tests/compile-link
- + debian/tests/control
- debian/upstream/metadata
Changes:
=====================================
.gitignore
=====================================
@@ -0,0 +1 @@
+/.pc/
=====================================
debian/control
=====================================
@@ -3,28 +3,25 @@ Standards-Version: 4.7.4
Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
Uploaders:
Andreas Tille <tille at debian.org>,
+Priority: optional
Section: science
Build-Depends:
debhelper-compat (= 14),
- dh-exec,
- dh-sequence-python3,
libbz2-dev,
libquicktree-dev,
libtokyocabinet-dev,
- python3,
- python3-setuptools,
zlib1g-dev,
Vcs-Browser: https://salsa.debian.org/med-team/libsonlib
Vcs-Git: https://salsa.debian.org/med-team/libsonlib.git
-Homepage: https://github.com/ArtRand/sonLib
+Homepage: https://github.com/benedictpaten/sonLib
Package: libsonlib-dev
Architecture: any
+Multi-Arch: same
Section: libdevel
Depends:
libquicktree-dev,
${misc:Depends},
- ${python3:Depends},
${shlibs:Depends},
Description: compact C/Python library for sequence analysis in bioinformatics
SonLib is a small general purpose library for C and Python for sequence
=====================================
debian/copyright
=====================================
@@ -1,6 +1,6 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: sonlib
-Source: https://github.com/ArtRand/sonLib
+Source: https://github.com/benedictpaten/sonLib
Files-Excluded: externalTools/quicktree*
*/*.swp
*/.git*
=====================================
debian/libsonlib-dev.install
=====================================
@@ -1,2 +1 @@
-#include/*.h usr/include/sonlib
-lib/* usr/lib/${DEB_HOST_MULTIARCH}
+lib/sonLib.a usr/lib/${DEB_HOST_MULTIARCH}/
=====================================
debian/patches/fix_build_errors.patch
=====================================
@@ -0,0 +1,48 @@
+Author: Andreas Tille <tille at debian.org>
+Description: Fix build errors and make the library build cleanly:
+ - C/impl/sonLibTreap.c: stTreap_remove read rmnode after freeing it
+ (use-after-free); save the parent pointer before free().
+ - C/impl/stSafeC.c: nbytes was set but not used (with
+ -Werror=unused-but-set-variable this fails the build).
+ - include.mk: drop --pedantic from the release flags; sonLibList.c
+ uses sort_r which needs object<->function pointer casts that ISO C
+ forbids under -pedantic.
+Assisted-By: scaleway/deepseek-v4-flash-0731
+
+--- a/C/impl/sonLibTreap.c
++++ b/C/impl/sonLibTreap.c
+@@ -326,9 +326,9 @@ int stTreap_remove(long key, stTreap *tr
+ rmnode->parent->right = NULL;
+ }
+ }
+- free(rmnode);
+ //update parent counts
+ stTreap *p = rmnode->parent;
++ free(rmnode);
+ while(p) {
+ p->count -= 1;
+ p = p->parent;
+--- a/C/impl/stSafeC.c
++++ b/C/impl/stSafeC.c
+@@ -25,8 +25,8 @@ void stSafeCErr(const char *msg, ...) {
+ va_end(args);
+ // n.b.: check number of bytes here is a hack around not being able
+ // to turn off gcc -Wunused-result for this special case
+- int nbytes = write(2, buf, strlen(buf));
+- nbytes += write(2, "\n", 1);
++ int nbytes = write(2, buf, strlen(buf)) + write(2, "\n", 1);
++ (void)nbytes;
+ _exit(128);
+ }
+
+--- a/include.mk
++++ b/include.mk
+@@ -41,7 +41,7 @@ endif
+ # linker input files. See <http://stackoverflow.com/a/8266512/402891>.
+
+ #Release compiler flags
+-cflags_opt = -O3 -g -Wall --pedantic -funroll-loops -DNDEBUG
++cflags_opt = -O3 -g -Wall -funroll-loops -DNDEBUG
+ #-fopenmp
+ cppflags_opt = -O3 -g -Wall -funroll-loops -DNDEBUG
+
=====================================
debian/patches/fix_quicktree_clone_child_ids.patch
=====================================
@@ -0,0 +1,46 @@
+Description: Clear uninitialized child_ids before freeing cloned quicktree trees
+ quicktree >= 2.5's clone_Tnode() (used by get_root_Tnode()) does not
+ initialize the child_ids member of the cloned nodes. free_Tnode()
+ frees child_ids whenever it is non-NULL, so freeing the tree returned by
+ get_root_Tnode() with free_Tree() frees uninitialized pointers and
+ corrupts the heap (seen as a segfault / heap corruption in the
+ sonLibTests neighbour-joining tests). Clear child_ids on the cloned
+ tree before freeing it.
+Author: Andreas Tille <tille at debian.org>
+Origin: vendor
+Forwarded: no
+Last-Update: 2026-10-21
+Reviewed-By: Andreas Tille <tille at debian.org>
+Assisted-By: scaleway/deepseek-v4-flash-0731
+
+--- a/C/impl/stPhylogeny.c
++++ b/C/impl/stPhylogeny.c
+@@ -195,6 +195,20 @@ static stTree *quickTreeToStTreeR(struct
+ // stTree. The tree is rooted halfway along the longest branch if
+ // outgroups is NULL, otherwise it's rooted halfway along the longest
+ // branch to an outgroup.
++
++// quicktree >= 2.5's clone_Tnode() (used by get_root_Tnode()) does not
++// initialize the child_ids member of the cloned nodes. free_Tnode()
++// frees child_ids whenever it is non-NULL, so freeing the cloned tree
++// with free_Tree() would free uninitialized pointers and corrupt the
++// heap. Recursively clear child_ids on the cloned tree first.
++static void quickTreeClearChildIds(struct Tnode *node) {
++ if (node != NULL) {
++ node->child_ids = NULL;
++ quickTreeClearChildIds(node->left);
++ quickTreeClearChildIds(node->right);
++ }
++}
++
+ static stTree *quickTreeToStTree(struct Tree *tree, stList *outgroups) {
+ struct Tree *rootedTree = get_root_Tnode(tree);
+ stTree *ret = quickTreeToStTreeR(rootedTree->child[0]);
+@@ -225,6 +239,7 @@ static stTree *quickTreeToStTree(struct
+ ret = reRooted;
+ }
+ free_Tree(tree);
++ quickTreeClearChildIds(rootedTree->child[0]);
+ free_Tree(rootedTree);
+ return ret;
+ }
=====================================
debian/patches/fix_test.patch
=====================================
@@ -2,6 +2,7 @@ Author: Andreas Tille <tille at debian.org>
Last-Update: 2020-06-16
Description: Somehow the test suite was non-functional. Fix some PATHs here
+Assisted-By: scaleway/deepseek-v4-flash-0731
--- libsonlib.orig/C/Makefile
+++ libsonlib/C/Makefile
@@ -59,4 +59,4 @@
@@ -9,7 +10,7 @@ Description: Somehow the test suite was non-functional. Fix some PATHs here
test:
- python3 allTests.py --testLength=SHORT --logLevel CRITICAL
-+ PYTHONPATH=../src/sonLib python3 allTests.py --testLength=SHORT --logLevel CRITICAL
++ PYTHONPATH=.. python3 allTests.py --testLength=SHORT --logLevel CRITICAL
--- libsonlib.orig/Makefile
+++ libsonlib/Makefile
@@ -21,7 +21,7 @@
@@ -17,7 +18,7 @@ Description: Somehow the test suite was non-functional. Fix some PATHs here
test : all
- PYTHONPATH=.. PATH=../../bin:$$PATH python3 allTests.py --testLength=SHORT --logLevel=CRITICAL
-+ PYTHONPATH=$(CURDIR)/src:$(CURDIR)/src/sonLib PATH=$(CURDIR)/bin:$$PATH python3 allTests.py --testLength=SHORT --logLevel=CRITICAL
++ PYTHONPATH=$(CURDIR) PATH=$(CURDIR)/bin:$$PATH python3 allTests.py --testLength=SHORT --logLevel=CRITICAL
${binPath}/sonLib_daemonize.py : sonLib_daemonize.py cP
cp sonLib_daemonize.py ${binPath}/sonLib_daemonize.py
=====================================
debian/patches/fix_warnings.patch
=====================================
@@ -1,7 +1,9 @@
Author: Andreas Tille <tille at debian.org>
-Description: When compiling with CGL_DEBUG=ultra the build ends in
- error: comparison between pointer and zero character constant "[-Werror=pointer-compare]"
- This should be fixed here.
+Description: Fix comparison between pointer and zero character constant
+ ([-Werror=pointer-compare]) in C/impl/bioioC.c: the code compared the
+ pointer *string against the character constant '\0', which is always
+ true; it must compare the pointed-to character **string.
+Assisted-By: scaleway/deepseek-v4-flash-0731
--- a/C/impl/bioioC.c
+++ b/C/impl/bioioC.c
=====================================
debian/patches/python313_compat.patch
=====================================
@@ -0,0 +1,32 @@
+Author: Andreas Tille <tille at debian.org>
+Description: unittest.makeSuite() was removed in Python 3.13; use
+ unittest.defaultTestLoader.loadTestsFromTestCase() instead so the test
+ suite runs on current Python.
+Assisted-By: scaleway/deepseek-v4-flash-0731
+
+--- a/allTests.py
++++ b/allTests.py
+@@ -30,16 +30,16 @@ class TestCase(unittest.TestCase):
+ system("sonLibTests %s" % getLogLevelString())
+
+ def allSuites():
+- bioioSuite = unittest.makeSuite(bioioTest.TestCase, 'test')
+- cigarsSuite = unittest.makeSuite(cigarsTest.TestCase, 'test')
+- treeSuite = unittest.makeSuite(treeTest.TestCase, 'test')
+- kvdbSuite = unittest.makeSuite(kvdbTest.TestCase, 'test')
+- cuTestsSuite = unittest.makeSuite(TestCase, 'test')
++ bioioSuite = unittest.defaultTestLoader.loadTestsFromTestCase(bioioTest.TestCase)
++ cigarsSuite = unittest.defaultTestLoader.loadTestsFromTestCase(cigarsTest.TestCase)
++ treeSuite = unittest.defaultTestLoader.loadTestsFromTestCase(treeTest.TestCase)
++ kvdbSuite = unittest.defaultTestLoader.loadTestsFromTestCase(kvdbTest.TestCase)
++ cuTestsSuite = unittest.defaultTestLoader.loadTestsFromTestCase(TestCase)
+ if not networkx_installed:
+ allTests = unittest.TestSuite((bioioSuite, cigarsSuite, treeSuite, kvdbSuite, cuTestsSuite))
+ else:
+- nxtreeSuite = unittest.makeSuite(nxtreeTest.TestCase, 'test')
+- nxnewickSuite = unittest.makeSuite(nxnewickTest.TestCase, 'test')
++ nxtreeSuite = unittest.defaultTestLoader.loadTestsFromTestCase(nxtreeTest.TestCase)
++ nxnewickSuite = unittest.defaultTestLoader.loadTestsFromTestCase(nxnewickTest.TestCase)
+ allTests = unittest.TestSuite((bioioSuite, cigarsSuite, treeSuite, kvdbSuite, cuTestsSuite,
+ nxtreeSuite, nxnewickSuite))
+ return allTests
=====================================
debian/patches/series
=====================================
@@ -1,5 +1,8 @@
+fix_build_errors.patch
use_debian_packaged_quicktree.patch
2to3.patch
fix_test.patch
rpath.patch
fix_warnings.patch
+python313_compat.patch
+fix_quicktree_clone_child_ids.patch
=====================================
debian/patches/use_debian_packaged_quicktree.patch
=====================================
@@ -3,6 +3,7 @@ Last-Update: 2020-06-16
Description: To avoid a code copy of quicktree here inside the quicktree
package a static lib is built and used to link here
+Assisted-By: scaleway/deepseek-v4-flash-0731
--- libsonlib.orig/externalTools/Makefile
+++ libsonlib/externalTools/Makefile
@@ -1,20 +1,14 @@
@@ -41,7 +42,7 @@ Description: To avoid a code copy of quicktree here inside the quicktree
testProgs = ${binPath}/sonLibTests ${binPath}/sonLib_kvDatabaseTest ${binPath}/sonLib_cigarTest ${binPath}/sonLib_fastaCTest
-cflags += ${tokyoCabinetIncl} ${kyotoTycoonIncl} ${tokyoTyrantIncl} ${mysqlIncl} ${pgsqlIncl} -I${quickTreeLibPath} $(CFLAGS)
-+cflags += ${tokyoCabinetIncl} ${kyotoTycoonIncl} ${tokyoTyrantIncl} ${mysqlIncl} ${pgsqlIncl} -I$/usr/include/quicktree $(CFLAGS)
++cflags += ${tokyoCabinetIncl} ${kyotoTycoonIncl} ${tokyoTyrantIncl} ${mysqlIncl} ${pgsqlIncl} -I/usr/include/quicktree $(CFLAGS)
cppflags += ${kyotoTycoonIncl}
all : ${libPath}/sonLib.a ${testProgs}
=====================================
debian/rules
=====================================
@@ -3,23 +3,34 @@
# DH_VERBOSE := 1
export LC_ALL=C.UTF-8
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
%:
dh $@
override_dh_auto_build:
- # Somehow Makefile does not deal with this ...
- #mkdir -p bin
- #cp -a src/sonLib/test/sonLib_daemonize.py .
- CGL_DEBUG=ultra dh_auto_build
+ dh_auto_build
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
- CGL_DEBUG=ultra dh_auto_test || true
+ # Run the C test suite, which covers the shipped library. The
+ # upstream Python test suite (allTests.py) exercises Python modules
+ # that are not shipped in libsonlib-dev and currently fails on
+ # Python 3.13, so it is deliberately not run here.
+ ./bin/sonLibTests CRITICAL
endif
override_dh_install:
dh_install
- mkdir -p debian/libsonlib-dev/usr/include/sonlib
- mv debian/libsonlib-dev/usr/lib/*/*.h debian/libsonlib-dev/usr/include/sonlib
+ # Install the public headers under /usr/include/sonLib (vg includes
+ # <sonLib/sonLib.h>); the bundled CuTest test harness is not shipped.
+ mkdir -p debian/libsonlib-dev/usr/include/sonLib
+ for header in lib/*.h; do \
+ [ "$$header" = "lib/CuTest.h" ] || install -m 0644 "$$header" debian/libsonlib-dev/usr/include/sonLib/; \
+ done
+ # Name the static archive so that it can be linked with -lsonlib (as
+ # vg's Makefile does), not only with its upstream name sonLib.a.
+ mv debian/libsonlib-dev/usr/lib/$(DEB_HOST_MULTIARCH)/sonLib.a \
+ debian/libsonlib-dev/usr/lib/$(DEB_HOST_MULTIARCH)/libsonlib.a
=====================================
debian/tests/compile-link
=====================================
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+# Verify that a consumer (as vg does) can #include <sonLib/sonLib.h>
+# and link against the shipped static library.
+cat > smoke.c <<'EOF'
+#include <sonLib/sonLib.h>
+#include <assert.h>
+#include <stdio.h>
+
+int main(void) {
+ stList *list = stList_construct();
+ stList_append(list, (void *)1);
+ stList_append(list, (void *)2);
+ assert(stList_length(list) == 2);
+ stList_destruct(list);
+ printf("sonlib link smoke test OK\n");
+ return 0;
+}
+EOF
+
+cc -o smoke smoke.c -lsonlib -lquicktree -ltokyocabinet -lz -lbz2 -lpthread -lm -lstdc++
+./smoke
=====================================
debian/tests/control
=====================================
@@ -0,0 +1,2 @@
+Tests: compile-link
+Depends: libsonlib-dev, build-essential, libquicktree-dev, libtokyocabinet-dev, zlib1g-dev, libbz2-dev
=====================================
debian/upstream/metadata
=====================================
@@ -1,5 +1,5 @@
-Bug-Database: https://github.com/ArtRand/sonLib/issues
+Bug-Database: https://github.com/benedictpaten/sonLib/issues
Registry:
- Name: conda:bioconda
Entry: sonlib
-Repository-Browse: https://github.com/ArtRand/sonLib
+Repository-Browse: https://github.com/benedictpaten/sonLib
View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/commit/6e37e6c5c2e5e40543ddc439aa0c7c61902be5a5
--
View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/commit/6e37e6c5c2e5e40543ddc439aa0c7c61902be5a5
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261021/0f0abd9d/attachment-0001.htm>
More information about the debian-med-commit
mailing list