#1107330 openbabel: autopkgtest uses incredible amount of memory on s390x

#1107330#5
Date:
2025-06-05 17:41:32 UTC
From:
To:
Hi,

I was debugging performance issues on ci.debian.net today, and noticed
that s390x was running into memory problems. openbabel quickly became a
suspect and indeed it turns out to use an insane amount of it during the
test.

I have spotted at least this (not the worse) in top:
     PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+
COMMAND
  653405 xxxxx     20   0   90.1g  26.7g   9908 D   6.3  85.0  10:04.02
python3

And the peak I spotted while looping free -h was 72 GB added by the test
and then I killed the test run.

I'll add openbabel to the reject_list and will remove it again when this
bug report is closed.

Paul

#1107330#10
Date:
2025-06-06 07:07:22 UTC
From:
To:
Hello,

Certain modes of operation of openbabel are known to leak memory, for
example [1][2][3]. I did not investigate further, but running tests
under valgrind might be the first step to that direction.

Best,
Andrius

[1] https://github.com/openbabel/openbabel/issues/2370
[2] https://github.com/openbabel/openbabel/pull/2772
[3] https://github.com/openbabel/openbabel/pull/2735

#1107330#15
Date:
2025-06-06 16:51:05 UTC
From:
To:
Hi


It seems this doesn't only affect s390x, but ppc64el as well. Added a
block on that architecture too.

Paul

#1107330#20
Date:
2025-06-11 05:53:36 UTC
From:
To:
Hi,


And arm64.

Paul

#1107330#27
Date:
2025-07-28 14:52:15 UTC
From:
To:
Hi Paul,

I was currently looking into this package.
In line no. 166 of getinchi.cpp there is a while loop that goes like the following:

while((ch=is.get())!=EOF)

Here ch is of type char. Whether char is signed or unsigned depends on the implementation.
Looks like in s390x char is of unsigned nature and the value of EOF is -1. Hence the condition always
evaluates to true (255 != -1) causing the control to be trapped inside the loop resulting in the memory hog.
Changing the variable's declaration to unsigned char seems to fix the memory consumption issue.
But I am still seeing the autopkgtest as failed due to some other reason.

I will update on the same as soon as I find anything.

Thanks,
Pranav

#1107330#32
Date:
2025-07-28 17:41:14 UTC
From:
To:
Hi Paul,

Sorry. I had typed in `unsigned char` in the previous mail instead of `signed char`.
The following is the git diff.

diff --git a/src/formats/getinchi.cpp b/src/formats/getinchi.cpp
index abda0a244..58c53cdac 100644
--- a/src/formats/getinchi.cpp
+++ b/src/formats/getinchi.cpp
@@ -159,7 +159,7 @@ string GetInChI(istream& is)
   string result;
   enum statetype {before_inchi, match_inchi, unquoted, quoted};
   statetype state = before_inchi;
-  char ch, lastch=0, qch=0;
+  signed char ch, lastch=0, qch=0;
   size_t split_pos = 0;
   bool inelement=false, afterelement=false;

Thanks,
Pranav

#1107330#37
Date:
2025-07-30 21:11:04 UTC
From:
To:
Hi,

Good catch - but I am quite surprised it now hit so hard - according to
git blame, that line (and anything around it) hasn't been changed for 18
years, and I guess the autopkgtest have been in place for a while as
well?


Michael

#1107330#42
Date:
2025-07-31 06:02:27 UTC
From:
To:
Hi,


I can't guarantee that this is new. I was investigating memory issues at
the time I filed this bug as we occasionally have out-of-memory
situations. It might be that this issue has always been there and I just
never drilled it down to openbabel.

Paul

#1107330#47
Date:
2025-08-19 06:02:50 UTC
From:
To:
Hi,

https://github.com/openbabel/openbabel/pull/2816
With this pull request both the memory usage issue and other test case failures should be fixed.

But I had the following issue during autopkgtest:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libchemistry-openbabel-perl : Depends: perl (>= 5.40.1-6) but 5.40.1-3 is to be installed
 libopenbabel7 : Depends: libxml2-16 (>= 2.14.1) but it is not installable
E: Unable to correct problems, you have held broken packages.
python3              FAIL badpkg
blame: arg:/home/pranav/debs/openbabel/libchemistry-openbabel-perl-dbgsym_3.1.1+dfsg-12_s390x.deb deb:libchemistry-openbabel-perl-dbgsym arg:/home/pranav/debs/openbabel/libchemistry-openbabel-perl_3.1.1+dfsg-12_s390x.deb deb:libchemistry-openbabel-perl arg:/home/pranav/debs/openbabel/libopenbabel-dev_3.1.1+dfsg-12_s390x.deb deb:libopenbabel-dev arg:/home/pranav/debs/openbabel/libopenbabel-doc_3.1.1+dfsg-12_all.deb deb:libopenbabel-doc arg:/home/pranav/debs/openbabel/libopenbabel7-dbgsym_3.1.1+dfsg-12_s390x.deb deb:libopenbabel7-dbgsym arg:/home/pranav/debs/openbabel/libopenbabel7_3.1.1+dfsg-12_s390x.deb deb:libopenbabel7 arg:/home/pranav/debs/openbabel/openbabel-dbgsym_3.1.1+dfsg-12_s390x.deb deb:openbabel-dbgsym arg:/home/pranav/debs/openbabel/openbabel-gui-dbgsym_3.1.1+dfsg-12_s390x.deb deb:openbabel-gui-dbgsym arg:/home/pranav/debs/openbabel/openbabel-gui_3.1.1+dfsg-12_s390x.deb deb:openbabel-gui arg:/home/pranav/debs/openbabel/openbabel_3.1.1+dfsg-12_s390x.deb deb:openbabel arg:/home/pranav/debs/openbabel/python3-openbabel-dbgsym_3.1.1+dfsg-12_s390x.deb deb:python3-openbabel-dbgsym arg:/home/pranav/debs/openbabel/python3-openbabel_3.1.1+dfsg-12_s390x.deb deb:python3-openbabel /home/pranav/debs/openbabel/openbabel_3.1.1+dfsg-12.dsc
badpkg: Test dependencies are unsatisfiable. A common reason is that your testbed is out of date with respect to the archive, and you need to use a current testbed or run apt-get update or use -U.
autopkgtest [23:54:16]: @@@@@@@@@@@@@@@@@@@@ summary
python3              FAIL badpkg
blame: arg:/home/pranav/debs/openbabel/libchemistry-openbabel-perl-dbgsym_3.1.1+dfsg-12_s390x.deb deb:libchemistry-openbabel-perl-dbgsym arg:/home/pranav/debs/openbabel/libchemistry-openbabel-perl_3.1.1+dfsg-12_s390x.deb deb:libchemistry-openbabel-perl arg:/home/pranav/debs/openbabel/libopenbabel-dev_3.1.1+dfsg-12_s390x.deb deb:libopenbabel-dev arg:/home/pranav/debs/openbabel/libopenbabel-doc_3.1.1+dfsg-12_all.deb deb:libopenbabel-doc arg:/home/pranav/debs/openbabel/libopenbabel7-dbgsym_3.1.1+dfsg-12_s390x.deb deb:libopenbabel7-dbgsym arg:/home/pranav/debs/openbabel/libopenbabel7_3.1.1+dfsg-12_s390x.deb deb:libopenbabel7 arg:/home/pranav/debs/openbabel/openbabel-dbgsym_3.1.1+dfsg-12_s390x.deb deb:openbabel-dbgsym arg:/home/pranav/debs/openbabel/openbabel-gui-dbgsym_3.1.1+dfsg-12_s390x.deb deb:openbabel-gui-dbgsym arg:/home/pranav/debs/openbabel/openbabel-gui_3.1.1+dfsg-12_s390x.deb deb:openbabel-gui arg:/home/pranav/debs/openbabel/openbabel_3.1.1+dfsg-12_s390x.deb deb:openbabel arg:/home/pranav/debs/openbabel/python3-openbabel-dbgsym_3.1.1+dfsg-12_s390x.deb deb:python3-openbabel-dbgsym arg:/home/pranav/debs/openbabel/python3-openbabel_3.1.1+dfsg-12_s390x.deb deb:python3-openbabel /home/pranav/debs/openbabel/openbabel_3.1.1+dfsg-12.dsc
badpkg: Test dependencies are unsatisfiable. A common reason is that your testbed is out of date with respect to the archive, and you need to use a current testbed or run apt-get update or use -U.

E: Autopkgtest run failed.

Thanks,
Pranav

#1107330#52
Date:
2025-08-19 17:55:50 UTC
From:
To:
Hi Pranav,


Thanks.


We're currently in the libxml2 transition [1], so breakage like this is
to be expected in unstable. Sometimes using testing during this kind of
work is easier.

Paul

[1] https://release.debian.org/transitions/html/libxml2.html

#1107330#57
Date:
2025-08-20 04:36:57 UTC
From:
To:
Hi Paul,

Thanks a lot!

#1107330#62
Date:
2026-01-01 16:26:45 UTC
From:
To:
Hi
And now I ran into this on riscv64. The issue seems to be intermittent.

Paul

https://ci.debian.net/packages/o/openbabel/testing/riscv64/67437005/

216s *** Open Babel Warning  in ParseRingBond
216s   Warning: Tetrahedral stereo specified for atom with more than 4
connections.
216s ==============================
216s *** Open Babel Warning  in ParseSmiles
216s   Failed to kekulize aromatic SMILES
216s
19979s ...terminate called after throwing an instance of 'std::bad_alloc'
19979s   what():  std::bad_alloc
20000s
/tmp/autopkgtest-lxc.qiiewp51/downtmp/build.cyq/src/debian/tests/python3:
line 9:  4650 Aborted                    python3 ${TEST}
20001s Ignoring test/testbindings.py on riscv64 ...
20001s Running test/testcdjsonformat.py ...
20001s
/tmp/autopkgtest-lxc.qiiewp51/downtmp/build.cyq/src/test/testcdjsonformat.py:5:
SyntaxWarning: invalid escape sequence '\P'
20001s   "C:\Program Files\CMake 2.6\bin\ctest.exe" -C CTestTestfile.cmake
20001s ..........
20001s
----------------------------------------------------------------------
20001s Ran 10 tests in 0.023s
20001s
20001s OK
20002s Running test/testdistgeom.py ...
20002s
/tmp/autopkgtest-lxc.qiiewp51/downtmp/build.cyq/src/test/testdistgeom.py:7:
SyntaxWarning: invalid escape sequence '\P'
20002s   "C:\Program Files\CMake 2.6\bin\ctest.exe" -C CTestTestfile.cmake
20002s /usr/lib/python3.13/subprocess.py:1023: RuntimeWarning: line
buffering (buffering=1) isn't supported in binary mode, the default
buffer size will be used
20002s   self.stdin = io.open(p2cwrite, 'wb', bufsize)
20002s /usr/lib/python3.13/subprocess.py:1029: RuntimeWarning: line
buffering (buffering=1) isn't supported in binary mode, the default
buffer size will be used
20002s   self.stdout = io.open(c2pread, 'rb', bufsize)
20002s /usr/lib/python3.13/subprocess.py:1034: RuntimeWarning: line
buffering (buffering=1) isn't supported in binary mode, the default
buffer size will be used
20002s   self.stderr = io.open(errread, 'rb', bufsize)
20128s autopkgtest [16:24:25]: ERROR: timed out

#1107330#67
Date:
2026-01-28 18:44:59 UTC
From:
To:
Hi,

If everything seems good then can this PR: https://github.com/openbabel/openbabel/pull/2816
be merged as to fix the issue?

Thanks,
Pranav