Skip to content

[Bug]: Failed to import python library which depends on C-native extensions after CWD is removed for java posix backend #1153

Description

@xiongxoy

Describe the bug

Failed to import python library which depends on C-native extensions after CWD is removed for java posix backend

Operating system

Linux

CPU architecture

x86_64

GraalPy version

graalpy3.12-25.1.3-linux-amd64

JDK version

No response

Context configuration

No response

Steps to reproduce

way to reproduce:

  1. create a temp dir and set cwd to it, then remove the dir
    import os
    import time
def userFunction(params):
    path = "/tmp/my_work_dir"
    os.makedirs(path, exist_ok=True)   
    os.chdir(path)                    
    os.rmdir(path)                      
    time.sleep(5)
    return {"data": "test"}
  1. then try to import a python library which depends on C-native extension
def userFunction(params):
    from openpyxl import load_workbook
    return {"data": "openpyxl import succeeded"} 
  1. then you can get the following error
    SystemError: SystemError: Failed to start patchelfto set SONAME: Cannot run program "/mindsynth/codes/graalpy/venv/bin/patchelf" (in directory "/tmp/my_work_dir"): Exec failed, error: 2 (No such file or directory) . IsolateNativeModules option needspatchelftool to copy libraries. Make sure you have it available on PATH or installed in your venv.

if I set the posix backend to "native", I cannot reproduce the above problem, I think it's better the java posix backend supports the same scenario and do not report an error.

builder.option("python.PosixModuleBackend", "native");

Expected behavior

I think it's better the java posix backend supports the same scenario and do not report an error.

Stack trace

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions