meson icon indicating copy to clipboard operation
meson copied to clipboard

Incorrect handling of malformed array values in c_args

Open VlaDexa opened this issue 1 year ago • 0 comments

Describe the bug Unhandled python exception during parsing of arrays with values that start with a dash

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 186, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/mconf.py", line 339, in run
    return run_impl(options, builddir)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/mconf.py", line 317, in run_impl
    save = c.set_options(options.cmd_line_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/mconf.py", line 95, in set_options
    return self.coredata.set_options(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 963, in set_options
    dirty |= self.set_option(k, v, first_invocation)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 815, in set_option
    changed = opt.set_value(value)
              ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 139, in set_value
    self.value = self.validate_value(newvalue)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 296, in validate_value
    newvalue = self.listify(value)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 293, in listify
    return self.listify_value(value, self.split_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mesonbuild/coredata.py", line 276, in listify_value
    newvalue = ast.literal_eval(value)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 1
    [-lol=lol]
     ^^^^
SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?

ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

To Reproduce

meson configure -Dc_args="[-lol=lol]"

Expected behavior Either a message that the option is malformed or just threating it as an array with value '-lol=lol'

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?: Native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Arch Linux
  • what Python version are you using e.g. 3.8.0: 3.11.8
  • what meson --version: 1.4.0
  • what ninja --version if it's a Ninja build: 1.11.1

VlaDexa avatar Apr 12 '24 14:04 VlaDexa