Skip to content

meson introspect breaks on QEMU (node.ast_id assert in resolve_node fires) #14667

@thesamesam

Description

@thesamesam

QEMU fails to build for me with recent meson from git. It bisects to e8f27f5.

At e8f27f5, I get:

$  ~/git/meson/meson.py introspect --buildoptions /var/tmp/portage/app-emulation/qemu-7.2.17-r1/work/qemu-7.2.17/meson.build
DEPRECATION: Project uses feature that was always broken, and is now deprecated since '1.3.0': str.format: Value other than strings, integers, bools, options, dictionaries and lists ther
eof..
Unable to evaluate subdir([]) in AstInterpreter --> Skipping
Traceback (most recent call last):
  File "/home/sam/git/meson/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/sam/git/meson/mesonbuild/mintro.py", line 558, in run
    intr.analyze()
    ~~~~~~~~~~~~^^
  File "/home/sam/git/meson/mesonbuild/ast/introspection.py", line 384, in analyze
    self.run()
    ~~~~~~~~^^
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 178, in run
    self.evaluate_codeblock(self.ast, start=1)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 203, in evaluate_codeblock
    raise e
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 195, in evaluate_codeblock
    self.evaluate_statement(cur)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 213, in evaluate_statement
    self.assignment(cur)
    ~~~~~~~~~~~~~~~^^^^^
  File "/home/sam/git/meson/mesonbuild/ast/interpreter.py", line 397, in assignment
    self.assign_vals[node.var_name.value] = self.evaluate_statement(node.value) # Evaluate the value just in case
                                            ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 209, in evaluate_statement
    return self.function_call(cur)
           ~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/sam/git/meson/mesonbuild/interpreterbase/interpreterbase.py", line 536, in function_call
    res = func(node, func_args, kwargs)
  File "/home/sam/git/meson/mesonbuild/ast/introspection.py", line 340, in func_static_lib
    return self.build_target(node, args, kwargs, StaticLibrary)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sam/git/meson/mesonbuild/ast/introspection.py", line 258, in build_target
    kwargs = self.flatten_kwargs(kwargs_raw, True)
  File "/home/sam/git/meson/mesonbuild/ast/introspection.py", line 409, in flatten_kwargs
    resolved = self.resolve_node(val, include_unknown_args)
  File "/home/sam/git/meson/mesonbuild/ast/interpreter.py", line 489, in resolve_node
    result = self.resolve_node(result, include_unknown_args, id_loop_detect)
  File "/home/sam/git/meson/mesonbuild/ast/interpreter.py", line 435, in resolve_node
    assert node.ast_id
           ^^^^^^^^^^^
AssertionError

../../../../var/tmp/portage/app-emulation/qemu-7.2.17-r1/work/qemu-7.2.17/meson.build:3365:13: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!
$ git bisect bad
e8f27f5912f1266adb0390fbf54aa3b14f9bf7da is the first bad commit
commit e8f27f5912f1266adb0390fbf54aa3b14f9bf7da (HEAD)
Author:     Volker Weißmann <volker.weissmann@gmx.de>
AuthorDate: Fri Mar 14 20:54:46 2025 +0100
Commit:     Dylan Baker <dylan@pnwbakers.com>
CommitDate: Thu May 29 09:20:27 2025 -0700

    rewriter: Replace assignments with cur_assignments

    Replace the variable tracking of `AstInterpreter.assignments`
    with a slightly better variable tracking called
    `AstInterpreter.cur_assignments`.
    We now have a class `UnknownValue` for more explicit handling
    of situations that are too complex/impossible.

 mesonbuild/ast/interpreter.py             | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
 mesonbuild/ast/introspection.py           |  12 ++++++------
 mesonbuild/interpreterbase/__init__.py    |   4 ++++
 mesonbuild/interpreterbase/baseobjects.py |   6 ++++++
 mesonbuild/rewriter.py                    |  19 +++++++++----------
 5 files changed, 147 insertions(+), 29 deletions(-)

cc @Volker-Weissmann @dcbaker

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions