pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
1.83k stars 300 forks source link

Python run_method API segfaults if given non-existent method #5648

Open swolchok opened 2 days ago

swolchok commented 2 days ago

🐛 Describe the bug

Repro: 1) install executorch with ./install_requirements.sh --pybind 2)

>>> from executorch.extension.pybindings import portable_lib as exec_lib
>>> mod = exec_lib._load_for_executorch("some.pte")
>>> mod.run_method("idontexist")
fish: Job 1, 'python' terminated by signal SIGSEGV (Address boundary error)

Versions

latest executorch main, commit hash cd4672101a59e562121293828dbb41f1dfc6289b

Olivia-liu commented 1 day ago

@JacobSzwejbka @dbort Iiuc, this is an ask for better error handling when the user tries to run a method that doesn't exist.

dbort commented 1 day ago

We should definitely throw a python exception instead of segfaulting.

JacobSzwejbka commented 1 day ago

Looking

JacobSzwejbka commented 1 day ago

https://github.com/pytorch/executorch/blob/main/extension/pybindings/pybindings.cpp#L252 lol