Skip to content

Build fails with Py_STACKREF_DEBUG due to undefined _Py_STACKREF_TRUE/FALSE_INDEX #148718

@corona10

Description

@corona10

While working on #148081, I found the build failure with Py_STACKREF_DEBUG=1

Python/optimizer_analysis.c:497:28: error: use of undeclared identifier '_Py_STACKREF_FALSE_INDEX'
  497 |     uintptr_t false_bits = _Py_STACKREF_FALSE_INDEX;
      |                            ^
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -Werror=unguarded-availability -D_Py_TIER2=1 -D_Py_JIT  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE -o Python/pathconfig.o Python/pathconfig.c
Python/optimizer_analysis.c:498:27: error: use of undeclared identifier '_Py_STACKREF_TRUE_INDEX'
  498 |     uintptr_t true_bits = _Py_STACKREF_TRUE_INDEX;
      |                           ^
Python/optimizer_analysis.c:514:27: error: use of undeclared identifier '_Py_STACKREF_TRUE_INDEX'
  514 |     uintptr_t true_bits = _Py_STACKREF_TRUE_INDEX;
      |                           ^

Simple patch would be

+#define _Py_STACKREF_FALSE_INDEX (3 << Py_TAGGED_SHIFT)
+#define _Py_STACKREF_TRUE_INDEX (4 << Py_TAGGED_SHIFT)
+#define PyStackRef_False ((_PyStackRef){ .index = _Py_STACKREF_FALSE_INDEX })
+#define PyStackRef_True ((_PyStackRef){ .index = _Py_STACKREF_TRUE_INDEX })

But I am not sure the patch is actually correct, because even if the build succeeds with the fix, the tests still fail on the main branch. There may have been some regression introduced at some point.

: Invalid StackRef with ID 53148 at Python/ceval.c:1932

Python runtime state: core initialized
Fatal Python error: _Py_stackref_close: Fatal Python error: _Py_stackref_close: Invalid StackRef with ID 53148 at Python/ceval.c:1932
Invalid StackRef with ID 53124 at Python/ceval.c:1932


Python runtime state: Python runtime state: core initializedcore initialized

Fatal Python error: _Py_stackref_close: Invalid StackRef with ID 53148 at Python/ceval.c:1932

Python runtime state: core initialized
make: *** [Python/frozen_modules/_collections_abc.h] Abort trap: 6
Fatal Python error: _Py_stackref_close: Invalid StackRef with ID 53148 at Python/ceval.c:1932

Python runtime state: core initialized
make: *** Waiting for unfinished jobs....
make: *** [Python/frozen_modules/codecs.h] Abort trap: 6
make: *** [Python/frozen_modules/encodings.aliases.h] Abort trap: 6
make: *** [Python/frozen_modules/encodings.h] Abort trap: 6
make: *** [Python/frozen_modules/abc.h] Abort trap: 6
make: *** [Python/frozen_modules/encodings._win_cp_codecs.h] Abort trap: 6
make: *** [Python/frozen_modules/encodings.utf_8.h] Abort trap: 6
make: *** [Python/frozen_modules/io.h] Abort trap: 6

cc @markshannon @Fidget-Spinner

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions