[issue41215] AIX: build fails for xlc/xlC since new PEG parser

Pablo Galindo Salgado report at bugs.python.org
Mon Jul 6 07:48:12 EDT 2020


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

Ok, this is definitively something going on with XLC. This patch solves the segfault:

diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c
index 9d3ac575df..e5511bf815 100644
--- a/Parser/pegen/parse.c
+++ b/Parser/pegen/parse.c
@@ -1,6 +1,6 @@
-// @generated by pegen.py from ./Grammar/python.gram
-#include "pegen.h"

+#include "pegen.h"
+// @generated by pegen.py from ./Grammar/python.gram
 #if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
 extern int Py_DebugFlag;
 #define D(x) if (Py_DebugFlag) x;
@@ -9,8 +9,8 @@ extern int Py_DebugFlag;
 #endif
 static const int n_keyword_lists = 15;
 static KeywordToken *reserved_keywords[] = {
-    NULL,
-    NULL,
+    (KeywordToken[]) {{NULL, -1}},
+    (KeywordToken[]) {{NULL, -1}},
     (KeywordToken[]) {
         {"if", 510},
         {"in", 518},
@@ -65,11 +65,11 @@ static KeywordToken *reserved_keywords[] = {
         {"nonlocal", 509},
         {NULL, -1},
     },
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
+    (KeywordToken[]) {{NULL, -1}},
+    (KeywordToken[]) {{NULL, -1}},
+    (KeywordToken[]) {{NULL, -1}},
+    (KeywordToken[]) {{NULL, -1}},
+    (KeywordToken[]) {{NULL, -1}},
     (KeywordToken[]) {
         {"__peg_parser__", 531},
         {NULL, -1},
@@ -24735,7 +24735,6 @@ _PyPegen_parse(Parser *p)
     // Initialize keywords
     p->keywords = reserved_keywords;
     p->n_keyword_lists = n_keyword_lists;
-
     // Run parser
     void *result = NULL;
     if (p->start_rule == Py_file_input) {

Is a C99 violation to have NULL elements in this array? (Michael, could you also double check that this patch solves it for you?)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41215>
_______________________________________


More information about the Python-bugs-list mailing list