Python ABI mismatch

If you're using Delphi with FMXLinux on a recent Linux distribution such as Ubuntu 26.04, you may find that attempting to debug fails immediately.

In my case, PAServer itself was working and Delphi could deploy and run the application. The problem appeared only when starting a debugging session.

The error was:

PAServer-37.0/lldb/bin/lldb-mi: symbol lookup error:
PAServer-37.0/lldb/bin/../lib/liblldb.so.20.1: undefined symbol: _Py_IsFinalizing

The problem turned out to be a Python ABI mismatch between the LLDB supplied with PAServer 37 and the version of Python supplied by Ubuntu/Kubuntu 26.04.

Fortunately, the fix is fairly straightforward.


Identifying the problem

PAServer 37 includes its own LLDB installation. We can see which Python library liblldb is loading with:

ldd ~/Apps/PAServer-37.0/lldb/lib/liblldb.so.20.1 | grep -i python

In my case, this reported:

libpython3.so => /home/david/Apps/PAServer-37.0/lldb/lib/../lib/libpython3.so

Next, inspect that library:

ls -l ~/Apps/PAServer-37.0/lldb/lib/libpython3.so

On Kubuntu 26.04, mine was pointing to the system Python 3.14 library:

libpython3.so -> /usr/lib/x86_64-linux-gnu/libpython3.14.so.1.0

The system Python version confirmed this:

python3 --version

# Python 3.14.4

This is where the problem lies.

PAServer 37's LLDB expects a Python 3.10-compatible runtime, but on Ubuntu/Kubuntu 26.04 the bundled libpython3.so link can end up pointing at Python 3.14.

The _Py_IsFinalizing symbol expected by LLDB is not available with the ABI it is getting from Python 3.14, causing lldb-mi to fail before the Delphi application even starts under the debugger.


Installing Python 3.10 on Ubuntu/Kubuntu 26.04

Python 3.10 is no longer available from the standard Ubuntu 26.04 repositories, so we need an additional repository.

The Deadsnakes PPA provides Python 3.10 packages for Ubuntu 26.04 (Resolute), including the shared library required by LLDB.

# First, add the Deadsnakes PPA:
sudo add-apt-repository ppa:deadsnakes/ppa

# Update the package lists:
sudo apt update

# Optionally verify that Python 3.10 is available:
apt-cache policy python3.10 libpython3.10 libpython3.10-stdlib

# Install Python 3.10 and the libraries required by LLDB:
sudo apt install python3.10 libpython3.10 libpython3.10-stdlib

This installs Python 3.10 alongside the system Python. There is no need to replace Ubuntu's default Python 3.14 installation.


Verify the Python 3.10 library

Check where the package installed the shared library:

dpkg -L libpython3.10 | grep 'libpython3.10.so'

On an x86-64 installation, you should see entries including:

/usr/lib/x86_64-linux-gnu/libpython3.10.so.1.0
/usr/lib/x86_64-linux-gnu/libpython3.10.so.1

The important one for PAServer is:

/usr/lib/x86_64-linux-gnu/libpython3.10.so.1

Point PAServer's LLDB at Python 3.10

Now change the libpython3.so link inside the PAServer LLDB installation.

# Adjust the PAServer path below if yours is installed somewhere else:
cd ~/Apps/PAServer-37.0/lldb/lib

# Preserve the existing link as a precaution:
mv libpython3.so libpython3.so.original

# Then create a new link pointing to Python 3.10:
ln -s /usr/lib/x86_64-linux-gnu/libpython3.10.so.1 libpython3.so

# Verify it:
ls -l libpython3.so

# It should now show something similar to:
libpython3.so -> /usr/lib/x86_64-linux-gnu/libpython3.10.so.1

Test LLDB before trying Delphi

Before going back to the Delphi IDE, it's worth testing PAServer's debugger directly:

cd ~/Apps/PAServer-37.0
./lldb/bin/lldb-mi --version

A successful result looks like:

Version: GNU gdb (GDB) 7.4
(This is a MI stub on top of LLDB and not GDB)
All rights reserved.

Don't be concerned by the reference to GDB. lldb-mi presents a GDB/MI-compatible interface while using LLDB underneath. The important part is that there is no longer an error such as:

undefined symbol: _Py_IsFinalizing

At this point, debugging from Delphi should work normally.


The complete fix

For reference, once the problem has been identified, the essential commands are:

# Add the Deadsnakes repository
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

# Install Python 3.10 alongside the system Python
sudo apt install python3.10 libpython3.10 libpython3.10-stdlib

# Configure PAServer 37's LLDB to use Python 3.10
cd ~/Apps/PAServer-37.0/lldb/lib

mv libpython3.so libpython3.so.original
ln -s /usr/lib/x86_64-linux-gnu/libpython3.10.so.1 libpython3.so

# Test the debugger
cd ~/Apps/PAServer-37.0
./lldb/bin/lldb-mi --version

Obviously, change ~/Apps/PAServer-37.0 if your PAServer installation lives somewhere else.


Why this works

The key point is that we are not downgrading Ubuntu's system Python.

Ubuntu/Kubuntu 26.04 can continue using Python 3.14 normally. We simply install Python 3.10 alongside it and tell the copy of LLDB supplied with PAServer 37 to load the Python 3.10 shared library it expects.

That isolates the workaround to PAServer:

Ubuntu/Kubuntu
    └── Python 3.14 ← remains the normal system Python

PAServer 37
    └── LLDB 20.1
          └── libpython3.so
                └── Python 3.10

After making this change on Kubuntu 26.04, Delphi was once again able to start a Linux debugging session successfully.

The same solution should apply to Ubuntu 26.04, since Kubuntu and Ubuntu share the same underlying Ubuntu package repositories and Python runtime packages.

Debugging in Linux is now working nicely:

FMX Debugging