You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
argv is imported from sys and used. If an arg is accessed that is outside the range of provided arguments, the program crashes without a handled exception
Expected behavior
When an argument outside the range of provided argv is accessed, either an exception is raised or some kind of empty value is returned.
Steps to reproduce
Run the following program from the CLI. Call the script without arguments. It should crash. If you provide an argument, it should not crash.
from sys import argv
def main():
var arguments = argv()
print(len(arguments))
print(arguments[0])
print(arguments[1])
System information
Provide the system information by running magic info.
Magic version: 0.7.0
System
Dependency count: 1
Dependencies: max
Target platforms: linux-64
Provide version information for MAX (includes Mojo) by pasting the output of magic list max.
Package Version Build Size Kind Source
max 25.2.0.dev2025022805 release 9.7 KiB conda max
max-core 25.2.0.dev2025022805 release 238.3 MiB conda max-core
max-python 25.2.0.dev2025022805 release 117.9 MiB conda max-python
The text was updated successfully, but these errors were encountered:
I think this is only temporary, and we probably can't do better until much later. argv returns a VariadicList, and an out-of-bounds index is unfortunately UB.
Bug description
Actual behavior
argv is imported from sys and used. If an arg is accessed that is outside the range of provided arguments, the program crashes without a handled exception
Expected behavior
When an argument outside the range of provided argv is accessed, either an exception is raised or some kind of empty value is returned.
Steps to reproduce
Run the following program from the CLI. Call the script without arguments. It should crash. If you provide an argument, it should not crash.
System information
magic info
.Magic version: 0.7.0
System
Virtual packages: __unix=0=0
: __linux=5.15.146.1=0
: __glibc=2.35=0
: __archspec=1=skylake
Cache dir: /home/mojo/.cache/rattler/cache
Auth storage: /home/mojo/.rattler/credentials.json
Config locations: No config files found
Global
Project
Environments
Dependency count: 1
Dependencies: max
Target platforms: linux-64
magic list max
.Package Version Build Size Kind Source
max 25.2.0.dev2025022805 release 9.7 KiB conda max
max-core 25.2.0.dev2025022805 release 238.3 MiB conda max-core
max-python 25.2.0.dev2025022805 release 117.9 MiB conda max-python
The text was updated successfully, but these errors were encountered: