Skip to content

Commit 41a2ced

Browse files
temp: verify crash on manylinux aarch64
1 parent 3e1c29e commit 41a2ced

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

.github/workflows/pypi.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Upload to PyPI
22

33
on:
44
push:
5+
branches-ignore: [master]
56
tags: ["v*"]
67

78
jobs:
@@ -49,7 +50,8 @@ jobs:
4950
CIBW_ARCHS: ${{matrix.cibw_arch}}
5051
CIBW_SKIP: "*-musllinux_aarch64"
5152
# FIXME: stop skipping when the tests stop crashing
52-
CIBW_TEST_SKIP: "*-win_* *linux_aarch64"
53+
CIBW_TEST_SKIP: "*-win_*"
54+
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64:2025.07.20-2
5355
- name: Upload wheels
5456
uses: actions/upload-artifact@v4
5557
with:
@@ -58,6 +60,7 @@ jobs:
5860
retention-days: 2
5961

6062
release:
63+
if: github.ref_type == 'tag'
6164
runs-on: ubuntu-latest
6265
needs: [build-sdist, build-wheels]
6366
steps:

setup.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
from sys import platform
1+
from os import name as os_name
2+
from platform import machine
23

34
from setuptools import Extension, setup # type: ignore
45

6+
if os_name != "nt":
7+
cflags = [
8+
"-std=c11",
9+
"-fvisibility=hidden",
10+
"-Wno-cast-function-type",
11+
"-Werror=implicit-function-declaration",
12+
]
13+
# XXX: #330 & #386
14+
if machine().startswith("aarch64"):
15+
cflags.append("--param=early-inlining-insns=9")
16+
else:
17+
cflags = ["/std:c11", "/wd4244"]
18+
519
setup(
620
packages=["tree_sitter"],
721
include_package_data=False,
@@ -36,18 +50,7 @@
3650
("PY_SSIZE_T_CLEAN", None),
3751
("TREE_SITTER_HIDE_SYMBOLS", None),
3852
],
39-
undef_macros=[
40-
"TREE_SITTER_FEATURE_WASM",
41-
],
42-
extra_compile_args=[
43-
"-std=c11",
44-
"-fvisibility=hidden",
45-
"-Wno-cast-function-type",
46-
"-Werror=implicit-function-declaration",
47-
] if platform != "win32" else [
48-
"/std:c11",
49-
"/wd4244",
50-
],
53+
extra_compile_args=cflags,
5154
)
5255
],
5356
)

tree_sitter/binding/parser.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,19 @@ static bool parser_progress_callback(TSParseState *state) {
101101
PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
102102
ModuleState *state = GET_MODULE_STATE(self);
103103
PyObject *source_or_callback;
104-
PyObject *old_tree_obj = NULL;
105-
PyObject *encoding_obj = NULL;
106-
PyObject *progress_callback_obj = NULL;
107-
bool keep_text = true;
104+
PyObject *old_tree_obj = NULL, *encoding_obj = NULL, *progress_callback_obj = NULL;
108105
char *keywords[] = {"", "old_tree", "encoding", "progress_callback", NULL};
109106
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O!OO:parse", keywords, &source_or_callback,
110107
state->tree_type, &old_tree_obj, &encoding_obj,
111108
&progress_callback_obj)) {
112109
return NULL;
113110
}
111+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "After PyArg_ParseTupleAndKeywords (%d)\n", __LINE__);
114112

115113
const TSTree *old_tree = old_tree_obj ? ((Tree *)old_tree_obj)->tree : NULL;
116114
TSInputEncoding input_encoding = TSInputEncodingUTF8;
117115
if (encoding_obj != NULL) {
116+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "Inside encoding_obj (%d)\n", __LINE__);
118117
if (!PyUnicode_CheckExact(encoding_obj)) {
119118
PyErr_Format(PyExc_TypeError, "encoding must be str, not %s",
120119
encoding_obj->ob_type->tp_name);
@@ -140,6 +139,7 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
140139
TSTree *new_tree = NULL;
141140
Py_buffer source_view;
142141
if (PyObject_GetBuffer(source_or_callback, &source_view, PyBUF_SIMPLE) > -1) {
142+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "Inside PyObject_GetBuffer (%d)\n", __LINE__);
143143
if (progress_callback_obj != NULL) {
144144
const char *warning = "The progress_callback is ignored when parsing a bytestring";
145145
if (PyErr_WarnEx(PyExc_UserWarning, warning, 1) < 0) {
@@ -149,9 +149,16 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
149149
// parse a buffer
150150
const char *source_bytes = (const char *)source_view.buf;
151151
uint32_t length = (uint32_t)source_view.len;
152+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "Before ts_parser_parse_string_encoding (%d)\n",
153+
__LINE__);
154+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "Parameters: %p, %p, %s, %u, %d\n", self->parser,
155+
old_tree, source_bytes, length, input_encoding);
152156
new_tree = ts_parser_parse_string_encoding(self->parser, old_tree, source_bytes, length,
153157
input_encoding);
158+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "After ts_parser_parse_string_encoding (%d)\n",
159+
__LINE__);
154160
PyBuffer_Release(&source_view);
161+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "After PyBuffer_Release (%d)\n", __LINE__);
155162
} else if (PyCallable_Check(source_or_callback)) {
156163
// clear the GetBuffer error
157164
PyErr_Clear();
@@ -199,16 +206,18 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
199206
PyErr_SetString(PyExc_ValueError, "Parsing failed");
200207
return NULL;
201208
}
209+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "After PyErr_Occurred (%d)\n", __LINE__);
202210

203211
Tree *tree = PyObject_New(Tree, state->tree_type);
204212
if (tree == NULL) {
205213
return NULL;
206214
}
207215
tree->tree = new_tree;
208216
tree->language = self->language;
209-
tree->source = keep_text ? source_or_callback : Py_None;
217+
tree->source = source_or_callback;
210218
Py_INCREF(tree->source);
211219
Py_INCREF(tree->language);
220+
PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "Before PyObject_Init (%d)\n", __LINE__);
212221
return PyObject_Init((PyObject *)tree, state->tree_type);
213222
}
214223

0 commit comments

Comments
 (0)