首页 > 解决方案 > python3.8.10 源代码构建错误 [Makefile:617: sharedmods] 错误 139

问题描述

在构建 python3.8.10 源代码上浪费时间。

构建环境:

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

让我解释。为了监视连接两个这样的字符串时会发生什么:

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

所以,我在函数中插入了一些额外的代码,PyUnicode_Append我希望这可以帮助我将参数存储到文件中。

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=%s\n", 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);
}

重新制作此代码时,会发生错误。

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

如果有人遇到这个问题,请帮助我。</p>

标签: pythonmakefile

解决方案


推荐阅读