Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: PyExc_SystemError #81

Open
jenner opened this issue Nov 8, 2019 · 4 comments
Open

undefined symbol: PyExc_SystemError #81

jenner opened this issue Nov 8, 2019 · 4 comments

Comments

@jenner
Copy link

jenner commented Nov 8, 2019

OS: Debian Buster
mod_python: master HEAD (7af8011)

/usr/src/mod_python# ./configure --with-python=/usr/bin/python3
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for main in -lm... yes
checking for an ANSI C-conforming const... yes
checking your blood pressure... a bit high, but we can proceed
configure: checking whether apxs is available...
checking for apxs2... /usr/bin/apxs2
checking Apache version... 2.4.38
checking for Apache libexec directory... /usr/lib/apache2/modules
checking for Apache include directory... -I/usr/include/apache2
checking for --with-python... /usr/bin/python3
checking Python version... 3.7
checking for --with-mutex-dir... no
Using MUTEX_DIR /tmp
checking for --with-max-locks... no
Using 8 MAX_LOCKS.
checking for --with-flex... no
checking for flex... /usr/bin/flex
found /usr/bin/flex, we'll use this. Use --with-flex to specify another.
checking flex version... configure: WARNING: Flex version 2.6.4 found.
    Version 2.5.31 or greater is required.  You can generally ignore this
    warning unless you need to regenerate psp_parser.c from psp_parse.l.
    If you do need regenerate psp_parser.c, use --with-flex to specify the
    location of the correct flex version. See the README for more information.
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating Doc/Makefile
config.status: creating src/include/mod_python.h
config.status: creating test/Makefile
config.status: creating dist/setup.py
config.status: creating dist/Makefile
config.status: creating scripts/Makefile
config.status: creating scripts/mod_python

Running make test yields following errors: apache2: Syntax error on line 57 of /usr/src/mod_python/test/conf/test.conf: Cannot load /usr/src/mod_python/src/mod_python.so into server: /usr/src/mod_python/src/mod_python.so: undefined symbol: PyExc_SystemError

Seems like libpython is not linked properly:

:/usr/src/mod_python# ldd src/mod_python.so 
	linux-vdso.so.1 (0x00007fffd907c000)
	libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f4494320000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f44942ff000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f44942f0000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f44942e0000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4494110000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f449439d000)

Any hints on how to solve this?

Thanks in advance
Igor

@jenner
Copy link
Author

jenner commented Nov 8, 2019

Found the problem: in ecbdcf1 print(distutils.sysconfig.get_config_var("LDLIBRARY")) yields libpython3.7m.so, which is not a valid linker argument. Replacing it with print(distutils.sysconfig.get_config_var("BLDLIBRARY")) works though:

~# python3.7 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_config_var("BLDLIBRARY"))'
-lpython3.7m

I guess the config var depends on the platform.

@ewah
Copy link

ewah commented Feb 10, 2020

BLDLIBRARY isn't consistent depending on the how the original python got built.

> python  -m sysconfig | grep BLDLIB
	BLDLIBRARY = "-L. -lpython2.7"
> python  -m sysconfig | grep BLDLIB
	BLDLIBRARY = ""
> python -m sysconfig | grep BLDLIB
	BLDLIBRARY = "libpython3.8.a"

locally i've reverted the config code back to pre-ecbdcf17884551b823fcef12cd5bd91103bde1fc (nov 7, 2019)

+    if test "$PyMAJVERSION" -eq "3"; then
+        LDLIBS1="-lpython${PyMAJVERSION}"
+    else
+        LDLIBS1="-lpython${PyVERSION}"
+    fi
-    LDLIBS1=`${PYTHON_BIN} -c 'import distutils.sysconfig;\
-        print(distutils.sysconfig.get_config_var("LDLIBRARY"))'`

@thkatsou
Copy link

thkatsou commented Dec 2, 2020

trying to compile mod-python on ubuntu 20.10 against python 2.7 .
Compilation and installation goes ok but apache2 does not start with same error.

apachectl configtest
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/python.load: Cannot load /usr/lib/apache2/modules/mod_python.so into server: /usr/lib/apache2/modules/mod_python.so: undefined symbol: PyExc_SystemError
Action 'configtest' failed.
The Apache error log may have more information.

tried all of the patches on makefile.in still no luck.

update: this modification on configure script worked ana apache2 started.
0e436f1
now I am facing
ImportError: Import by filename is not supported.

@diegobill
Copy link

any update from this error? I am still seeing on Docker in Ubuntu 16.04:

FROM python:2.7.18-slim

# Install packages
RUN apt-get -yqq update && \
    apt-get -yqq install mercurial git vim apache2 apache2-dev libapache2-mod-python openssl libmariadb-dev fonts-freefont-ttf libssl-dev cron logrotate lynx htop zabbix-agent && \
    apt-get clean

WORKDIR /usr/local/src
RUN git clone git+https://github.com/grisha/mod_python.git@e7ec956eaeba9f75e33f5d0036a6699ac3f0d816
WORKDIR /usr/local/src/mod_python
COPY patches/patch-Py_Initialize.txt /tmp
RUN LIBS="-lpython2.7" ./configure && \
    # configure gets the libpython2.7.so link argument wrong, so fix it
    sed -i.bak 's/libpython2.7.so/-lpython2.7/g' /usr/local/src/mod_python/src/Makefile && \
    patch -p1 < /tmp/patch-Py_Initialize.txt && \
    LIBS="-lpython2.7" make && \
    make install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants