Skip to content

fix: remove unwrap() from extism_compiled_plugin_new#794

Merged
chrisdickinson merged 1 commit intomainfrom
chris/20241125-catch-compiled-plugin-errors
Nov 26, 2024
Merged

fix: remove unwrap() from extism_compiled_plugin_new#794
chrisdickinson merged 1 commit intomainfrom
chris/20241125-catch-compiled-plugin-errors

Conversation

@chrisdickinson
Copy link
Copy Markdown
Contributor

extism_compiled_plugin_new would panic on bad manifest input (there's a test in the python sdk 1 that hits this directly.) Catch the error and set errmsg appropriately instead.

Additionally: golf the function pointer casting for the various plugin_new calls, with the goal of reducing the number of allocations by leaning on iterator size hints (and reducing the scope of unsafe{} use.) This introduces a breaking change. Previously NULL values were silently accepted in the functions** list; now they fail. This maintains consistency with behavior on "consumed" ExtismFunction pointer.

`extism_compiled_plugin_new` would panic on bad manifest input (there's
a test in the python sdk [1] that hits this directly.) Catch the error and
set `errmsg` appropriately instead.

Additionally: golf the function pointer casting for the various `plugin_new` calls,
with the goal of reducing the number of allocations by leaning on iterator size
hints (and reducing the scope of `unsafe{}` use.) This part can be severed: it
introduces a breaking change. Previously `NULL` values were silently accepted in
the `functions**` list; now they fail. This maintains consistency with behavior on
"consumed" `ExtismFunction` pointer.

[1]: https://github.com/extism/python-sdk/blob/main/tests/test_extism.py#L50-L53
Copy link
Copy Markdown
Contributor

@zshipko zshipko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@chrisdickinson chrisdickinson merged commit 4db57de into main Nov 26, 2024
@chrisdickinson chrisdickinson deleted the chris/20241125-catch-compiled-plugin-errors branch November 26, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants