python3.8.10 source build with error [Makefile:617: sharedmods] Error 139

  makefile, python

Wasted losts of time on build python3.8.10 source.

Build ENV:

gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)

Linux localhost.localdomain 4.18.0-305.19.1.el8_4.x86_64 #1 SMP Wed Sep 15 15:39:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux(centos8 x86_64)

File:./Objects/unicodeobject.c

Error:make: *** [Makefile:617: sharedmods] Error 139

Let me explain. In order to monitor what happens when connect two strings like this:

src_str = "hello "
dst_str = src_str + "world"

So, I inserted some extra code in PyUnicode_Append function and i hope this can help me store the parameter into file.

void
PyUnicode_Append_Handler(PyObject *left, PyObject *right)
{
    FILE* fp = fopen("/home/pyiast/append.log","a+");
    if (NULL == fp){
        return;
    }
    
    PyObject *data = PyUnicode_FromFormat("append:dst=%s, src=%sn", PyUnicode_AsUTF8(left),PyUnicode_AsUTF8(right));
    if (data != NULL){
        PyObject_Print(data, fp, 0);
        Py_DECREF(data);
    }
    fclose(fp);
}

void
PyUnicode_Append(PyObject **p_left, PyObject *right)
{
    //... other code
    assert(_PyUnicode_CheckConsistency(*p_left, 1));
    
    // this is my code
    PyUnicode_Append_Handler(left, right);
}

When re-make this code, the error occurs.

if test $? -ne 0 ; then 
        echo "generate-posix-vars failed" ; 
        rm -f ./pybuilddir.txt ; 
        exit 1 ; 
fi
 CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall'      _TCLTK_INCLUDES='' _TCLTK_LIBS=''       ./python -E ./setup.py  build
/bin/sh: line 9: 30341 Segmentation fault      (core dumped) CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py $quiet build
make: *** [Makefile:617: sharedmods] Error 139

If anyone has encountered this problem, please help me。

Source: Python Questions

LEAVE A COMMENT