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

Fails to build on Python 3.2 on Windows: 'stackUnderflow' undefined #16

Closed
mgedmin opened this issue May 25, 2015 · 4 comments
Closed

Comments

@mgedmin
Copy link
Member

mgedmin commented May 25, 2015

Here's an excerpt from the build log:

building 'zodbpickle._pickle' extension
creating build\temp.win32-3.2
creating build\temp.win32-3.2\Release
creating build\temp.win32-3.2\Release\src
creating build\temp.win32-3.2\Release\src\zodbpickle
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python32_32\include -Ic:\Python32_32\PC /Tcsrc/zodbpickle/_pickle_32.c /Fobuild\temp.win32-3.2\Release\src/zodbpickle/_pickle_32.obj
_pickle_32.c
src/zodbpickle/_pickle_32.c(5618) : warning C4013: 'stackUnderflow' undefined; assuming extern returning int
creating build\lib.win32-3.2
creating build\lib.win32-3.2\zodbpickle
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\Python32_32\libs /LIBPATH:c:\Python32_32\PCbuild /EXPORT:PyInit__pickle build\temp.win32-3.2\Release\src/zodbpickle/_pickle_32.obj /OUT:build\lib.win32-3.2\zodbpickle\_pickle.pyd /IMPLIB:build\temp.win32-3.2\Release\src/zodbpickle\_pickle.lib /MANIFESTFILE:build\temp.win32-3.2\Release\src/zodbpickle\_pickle.pyd.manifest
   Creating library build\temp.win32-3.2\Release\src/zodbpickle\_pickle.lib and object build\temp.win32-3.2\Release\src/zodbpickle\_pickle.exp
_pickle_32.obj : error LNK2019: unresolved external symbol _stackUnderflow referenced in function _do_noload_setitems
build\lib.win32-3.2\zodbpickle\_pickle.pyd : fatal error LNK1120: 1 unresolved externals
@mgedmin
Copy link
Member Author

mgedmin commented May 25, 2015

_pickle_27.c has a static int stackUnderflow(). _pickle_32.c has a static int stack_underflow(). Looks like the C implementation of noload calls the wrong one:

diff --git a/src/zodbpickle/_pickle_32.c b/src/zodbpickle/_pickle_32.c
index 2e559da..a5076bc 100644
--- a/src/zodbpickle/_pickle_32.c
+++ b/src/zodbpickle/_pickle_32.c
@@ -5615,7 +5615,7 @@ do_noload_setitems(UnpicklerObject *self, Py_ssize_t x)
     Py_ssize_t len;

     if (!( (len=Py_SIZE(self->stack)) >= x
-           && x > 0 ))  return stackUnderflow();
+           && x > 0 ))  return stack_underflow();

     dict=self->stack->data[x-1];
     if (dict == Py_None) {

What's more worrying is that no tests fail when the C module cannot be built. This is why I'm not committing my fix yet.

@mgedmin
Copy link
Member Author

mgedmin commented May 25, 2015

BTW on Linux the undefined name doesn't cause a compile-time error, it causes an import-time error:

$ tox -e py32
...
building 'zodbpickle._pickle' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python3.2mu -c src/zodbpickle/_pickle_32.c -o build/temp.linux-x86_64-3.2/src/zodbpickle/_pickle_32.o
src/zodbpickle/_pickle_32.c: In function ‘do_noload_setitems’:
src/zodbpickle/_pickle_32.c:5618:12: warning: implicit declaration of function ‘stackUnderflow’ [-Wimplicit-function-declaration]
            && x > 0 ))  return stackUnderflow();
            ^
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-3.2/src/zodbpickle/_pickle_32.o -o build/lib.linux-x86_64-3.2/zodbpickle/_pickle.cpython-32mu.so
copying build/lib.linux-x86_64-3.2/zodbpickle/_pickle.cpython-32mu.so -> src/zodbpickle
.............s.........s..............sss......s..........................................
----------------------------------------------------------------------
Ran 90 tests in 0.335s

OK (skipped=6)

$ .tox/py32/bin/python
...
>>> from zodbpickle import _pickle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/mg/src/zopefoundation/zodbpickle/.tox/py32/lib/python3.2/site-packages/zodbpickle/_pickle.cpython-32mu.so: undefined symbol: stackUnderflow

agroszer added a commit to zopefoundation/zope.wineggbuilder that referenced this issue Sep 10, 2015
@mgedmin
Copy link
Member Author

mgedmin commented Sep 21, 2017

Somebody ought to check whether this issue affects Python 3.3 and newer.

@mgedmin
Copy link
Member Author

mgedmin commented Sep 21, 2017

AFAICS this was only affecting Python 3.2, which we're no longer supporting, so closing this bug.

@mgedmin mgedmin closed this as completed Sep 21, 2017
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

1 participant