加载散景到嵌入式python DLL崩溃

问题描述 投票:0回答:1

python(3.7.3)通过C-API嵌入到可执行文件中。当Python脚本加载函数PyImport_Import()并且脚本包含散景导入时,即from bokeh.plotting import figure,加载过程会过早地以浮点异常结束。

可执行文件是用Delphi编写的,但它的python API几乎与原始的C-API相同。我已经加载了许多其他模块而没有任何问题。散景是第一个无法加载的。

调用Delphi程序,python dll已经加载到exe进程中

  // module name as PPyObject
  pPyName := delpy.PyString_FromString(PAnsiChar(AnsiString(module)));
  // import module
  pPyModule := delpy.PyImport_Import(pPyName);

和python脚本

import ptvsd
import pandas as pd
from bokeh.plotting import figure

def main_fnc():
    ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
    ptvsd.wait_for_attach()
    breakpoint()
    print('Hello World!')

以下事件日志列出了加载到进程中的dll,仅显示最后的条目 - 通过命名判断 - 与图形函数相关。最后抛出的错误。

Loading Module: spline.cp37-win32.pyd. Without Debug-Infos. Base address: $2BD70000. Process XYZ.exe (8512)
Loading Module: _nd_image.cp37-win32.pyd. Without Debug-Infos. Base address: $2BDD0000. Process XYZ.exe (8512)
Loading Module: _ni_label.cp37-win32.pyd. Without Debug-Infos. Base address: $2BE00000. Process XYZ.exe (8512)
Loading Module: _spectral.cp37-win32.pyd. Without Debug-Infos. Base address: $2BE90000. Process XYZ.exe (8512)
Loading Module: _peak_finding_utils.cp37-win32.pyd. Without Debug-Infos. Base address: $2BEB0000. Process XYZ.exe (8512)
Loading Module: _hamilton_filter.cp37-win32.pyd. Without Debug-Infos. Base address: $2BFB0000. Process XYZ.exe (8512)
Loading Module: _kim_smoother.cp37-win32.pyd. Without Debug-Infos. Base address: $2BFF0000. Process XYZ.exe (8512)
Loading Module: linbin.cp37-win32.pyd. Without Debug-Infos. Base address: $2C030000. Process XYZ.exe (8512)
Loading Module: _smoothers_lowess.cp37-win32.pyd. Without Debug-Infos. Base address: $2C050000. Process XYZ.exe (8512)
Loading Module: _contour.cp37-win32.pyd. Without Debug-Infos. Base address: $2C280000. Process XYZ.exe (8512)
Loading Module: ft2font.cp37-win32.pyd. Without Debug-Infos. Base address: $2C2B0000. Process XYZ.exe (8512)
Loading Module: _png.cp37-win32.pyd. Without Debug-Infos. Base address: $2C450000. Process XYZ.exe (8512)
Loading Module: kiwisolver.cp37-win32.pyd. Without Debug-Infos. Base address: $2C4D0000. Process XYZ.exe (8512)
Loading Module: _image.cp37-win32.pyd. Without Debug-Infos. Base address: $2C580000. Process XYZ.exe (8512)
Loading Module: _tri.cp37-win32.pyd. Without Debug-Infos. Base address: $2C680000. Process XYZ.exe (8512)
Loading Module: _qhull.cp37-win32.pyd. Without Debug-Infos. Base address: $2C6B0000. Process XYZ.exe (8512)
First Chance Exception at $20762F54. Exception-Class $C0000090 with Message 'floating point invalid operation at 0x20762f54'. Process XYZ.exe (8512)

python delphi bokeh c-api
1个回答
1
投票

这通常在使用外部库时发生。在这种情况下,调用SetExceptionMask来掩盖浮点异常可能会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.