graphql-python / graphql-python/graphql-core

Segfault during schema parsing

未關閉
#208 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
531
分支
146
PR 合併指標
30 天內沒有已合併 PR

描述

Hey there,

The package is great and has been super reliable for us so far. However, we're running into an intermittent issue where the python exits with code 139 (segfault).

The relevant part of the stack trace, obtained with Python's builtin `faulthandler`:
```
main Fatal Python error: Segmentation fault
│ main
│ main Current thread 0x00007f9672f54740 (most recent call first):
│ main Garbage-collecting
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/ast.py", line 361 in __setattr__
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/ast.py", line 332 in __init__
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 730 in parse_field_definition
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 1134 in optional_many
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 717 in parse_fields_definition
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 697 in parse_object_type_definition
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 288 in parse_definition
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 1153 in many
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 241 in parse_document
│ main File "/usr/local/lib/python3.11/site-packages/graphql/language/parser.py", line 113 in parse
│ main File "/usr/local/lib/python3.11/site-packages/gql/client.py", line 105 in __init__
```

* This happens when trying to parse a GraphQL schema as a string, loaded from a network request.
* The schema is around 2800 lines, which I presume is considered fairly large.
* The entry point is through the `gql` library, but the issue seems to be inside `graphql-core`
* I couldn't find what could go wrong based on some digging through the stack trace.
* The package version we're using is 3.2.3.

Could this be a mislabeled OOM error? I don't think so, but worth considering. Is there anything I could do to profile this better? It's a bit hard as it's running inside a Kubernetes pod and we can't reproduce locally, but I can try.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先從 graphql/language/ast.py 和 graphql/language/parser.py 中回報的堆疊框架開始,接著檢查 gql/client.py,也就是 schema 解析開始的地方。使用 faulthandler 重現解析大型 schema 字串,並比較 parser 和 AST 的行為。找出可重現的原因,並記錄或測試修正方案,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend-api-design
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。