Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV on "import io" (and similar) when compiled without libs #297

Open
SmallJoker opened this issue Feb 24, 2024 · 0 comments
Open

SIGSEGV on "import io" (and similar) when compiled without libs #297

SmallJoker opened this issue Feb 24, 2024 · 0 comments

Comments

@SmallJoker
Copy link

How to reproduce:

  1. Modify Makefile.
    • Append -DPK_NO_LIBS to the CFLAGS
    • Remove the ./src/libs/ from SRC_DIRS
  2. make clean and rebuild
  3. Run ./pocket -c "import io" and observe the segfault

Proposed fix:

diff --git a/src/core/vm.c b/src/core/vm.c
index 8b8eeaa..243dcc5 100644
--- a/src/core/vm.c
+++ b/src/core/vm.c
@@ -466,6 +466,7 @@ Var vmImportModule(PKVM* vm, String* from, String* path) {
   uint32_t search_path_idx = 0;
 
   do {
+    if (!vm->config.resolve_path_fn) break; // when compiled without libs
     // If we reached here. It's not a native module (ie. module's absolute path
     // is required to import and cache).
     _resolved = vm->config.resolve_path_fn(vm, from_path, path->data);
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

No branches or pull requests

1 participant