Skip to content

[Bug] Docling PDF 预处理阶段,在处理大型 PDF 文件时触发内存分配异常 std::bad_alloc #152

Description

@MarvelICY

Bug 描述

  • 在使用 dayu-cli download 下载 A 股年报(ticker: 600809,FY 2026)时,Docling 在 PDF 预处理阶段(preprocess)对第 68 页及以后的大量页面抛出 std::bad_alloc 内存分配异常,导致对应页面处理失败。
  • 相同问题在下载 600519 年报时亦有复现。
  • 观察生成的json文件,发现有部分解析成功

环境信息

项目 版本/型号
操作系统 Windows 11
CPU AMD Ryzen 9 9700X
GPU NVIDIA RTX 5070 Ti
内存 32 GB
Python 环境 Anaconda
OCR 引擎 RapidOCR + onnxruntime

复现步骤

  1. 安装 dayu-cli 及相关依赖
  2. 执行以下命令:
    dayu-cli download --ticker 600809 --forms FY --start 2025 --end 2026

错误日志

PS D:\PROJECT\MatrixAnalysis>  dayu-cli download --ticker 600809 --forms FY --start 2025 --end 2026
D:\SDK\anaconda3\Lib\site-packages\pandas\core\computation\expressions.py:22: UserWarning: Pandas requires version '2.10.2' or newer of 'numexpr' (version '2.10.1' currently installed).
  from pandas.core.computation.check import NUMEXPR_INSTALLED
[2026-05-04 09:40:56] [INFO] [FINS.CN_PIPELINE] 进入CN/HK下载流程: ticker=600809 market=CN form_type=FY start=2025 end=2026 overwrite=False
[2026-05-04 09:40:58] [INFO] [FINS.CN_PIPELINE] 开始 Docling 转换: ticker=600809 document_id=fil_cn_49e80cc716c0012ee5e5d4f06c35ad98c7fbdf4d form=FY filing_date=2026-04-22 source_file=fil_cn_49e80cc716c0012ee5e5d4f06c35ad98c7fbdf4d.pdf reused_pdf=False
2026-05-04 09:41:05.508886: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2026-05-04 09:41:07.066827: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
D:\SDK\anaconda3\Lib\site-packages\keras\src\export\tf2onnx_lib.py:8: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  if not hasattr(np, "object"):
[INFO] 2026-05-04 09:41:08,606 [RapidOCR] base.py:22: Using engine_name: onnxruntime
[INFO] 2026-05-04 09:41:08,618 [RapidOCR] download_file.py:60: File exists and is valid: D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_det_mobile.onnx
[INFO] 2026-05-04 09:41:08,618 [RapidOCR] main.py:57: Using D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_det_mobile.onnx
[INFO] 2026-05-04 09:41:08,681 [RapidOCR] base.py:22: Using engine_name: onnxruntime
[INFO] 2026-05-04 09:41:08,683 [RapidOCR] download_file.py:60: File exists and is valid: D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_ppocr_mobile_v2.0_cls_mobile.onnx
[INFO] 2026-05-04 09:41:08,683 [RapidOCR] main.py:57: Using D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_ppocr_mobile_v2.0_cls_mobile.onnx
[INFO] 2026-05-04 09:41:08,709 [RapidOCR] base.py:22: Using engine_name: onnxruntime
[INFO] 2026-05-04 09:41:08,724 [RapidOCR] download_file.py:60: File exists and is valid: D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_mobile.onnx
[INFO] 2026-05-04 09:41:08,724 [RapidOCR] main.py:57: Using D:\SDK\anaconda3\Lib\site-packages\rapidocr\models\ch_PP-OCRv4_rec_mobile.onnx
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [68]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [69]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [70]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [71]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [72]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [73]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [74]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [75]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [76]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [77]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [78]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [79]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [80]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [81]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [82]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [83]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [84]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [85]: std::bad_alloc
[2026-05-04 09:41:13] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [86]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [87]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [88]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [89]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [90]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [91]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [92]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [93]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [94]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [95]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [96]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [97]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [98]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [99]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [100]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [101]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [102]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [103]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [104]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [105]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [106]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [107]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [108]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [109]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [110]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [111]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [112]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [113]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [114]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [115]: std::bad_alloc
[2026-05-04 09:41:14] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [116]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [117]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [118]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [119]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [120]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [121]: std::bad_alloc
[2026-05-04 09:41:15] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [122]: std::bad_alloc
[2026-05-04 09:41:16] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [123]: std::bad_alloc
[2026-05-04 09:41:16] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [124]: std::bad_alloc
[2026-05-04 09:41:16] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [125]: std::bad_alloc
[2026-05-04 09:41:16] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [126]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [127]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [128]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [129]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [130]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [131]: std::bad_alloc
[2026-05-04 09:41:17] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [132]: std::bad_alloc
[2026-05-04 09:41:18] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [133]: std::bad_alloc
[2026-05-04 09:41:18] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [134]: std::bad_alloc
[2026-05-04 09:41:18] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [135]: std::bad_alloc
[2026-05-04 09:41:19] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [136]: std::bad_alloc
[2026-05-04 09:41:19] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [137]: std::bad_alloc
[2026-05-04 09:41:19] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [138]: std::bad_alloc
[2026-05-04 09:41:21] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [139]: std::bad_alloc
[2026-05-04 09:41:21] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [140]: std::bad_alloc
[2026-05-04 09:41:21] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [141]: std::bad_alloc
[2026-05-04 09:41:22] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [142]: std::bad_alloc
[2026-05-04 09:41:22] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [143]: std::bad_alloc
[2026-05-04 09:41:22] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [144]: std::bad_alloc
[2026-05-04 09:41:22] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [145]: std::bad_alloc
[2026-05-04 09:41:24] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [154]: std::bad_alloc
[2026-05-04 09:41:24] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [155]: std::bad_alloc
[2026-05-04 09:41:24] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [156]: std::bad_alloc
[2026-05-04 09:41:24] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [157]: std::bad_alloc
[2026-05-04 09:41:25] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [158]: std::bad_alloc
[2026-05-04 09:41:25] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [159]: std::bad_alloc
[2026-05-04 09:41:25] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [160]: std::bad_alloc
[2026-05-04 09:41:25] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [161]: std::bad_alloc
[2026-05-04 09:41:25] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [162]: std::bad_alloc
[2026-05-04 09:41:26] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [163]: std::bad_alloc
[2026-05-04 09:41:26] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [164]: std::bad_alloc
[2026-05-04 09:41:26] [ERROR] [docling.pipeline.standard_pdf_pipeline] Stage preprocess failed for run 1, pages [165]: std::bad_alloc
[2026-05-04 09:41:53] [INFO] [FINS.CN_PIPELINE] filing 下载完成: ticker=600809 document_id=fil_cn_49e80cc716c0012ee5e5d4f06c35ad98c7fbdf4d status=downloaded form=FY filing_date=2026-04-22 report_date=None downloaded_files=2 skipped_files=0 failed_files=0 skip_reason=None reason_code=download_committed reason_message=PDF 与 Docling JSON 已完成落盘并提交 source meta filter_category=None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions