Skip to content

FFI::addr() cannot create a reference to a temporary pointer #28

Closed

Description

@victorratts13

Your question

I'm working on a personal project where I'm trying to load a simple model for testing. I'm having some problems with FFI where I get the error:

FFI::addr() cannot create a reference to a temporary pointer

Enviroment:

  • PHP 8.3
  • Laravel 11
  • MacOs 13.6.6 (22G630)

Context (optional)

No response

Reference (optional)

No response

Activity

  1. CodeWithKyrian commented on Apr 30, 2024

    @CodeWithKyrian
    Owner

    Can you provide more information about the model, and some code on how you set things up so I can try to reproduce the error?

  2. victorratts13 commented on Apr 30, 2024

    @victorratts13
    Author

    Basically, I'm doing a test, but using Laravel Framework in the most current version (11.0). Previously I did a test using a hugface text-to-text model, however, I changed it to the "Hello world" that the transformersphp documentation suggests:

    So the code looked like this:

    <?php
    
    use Illuminate\Support\Facades\Route;
    
    use function Codewithkyrian\Transformers\Pipelines\pipeline;
    
    Route::get('/', function () {
        // return phpinfo();
        $pipe = pipeline('sentiment-analysis');
        return $pipe('I love transformers!');
    });

    As you may have noticed, I used phpinfo() to check if the suggested extensions were installed:

    Captura de Tela 2024-04-30 às 03 06 24

  3. victorratts13 commented on Apr 30, 2024

    @victorratts13
    Author

    UPDATE:

    When I was debugging the code I came across this PHP alert

     PHP Warning:  PHP Startup: Unable to load dynamic library 'ffi' (tried: /usr/local/lib/php/pecl/20230831/ffi (dlopen(/usr/local/lib/php/pecl/20230831/ffi, 0x0009): tried: '/usr/local/lib/php/pecl/20230831/ffi' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20230831/ffi' (no such file), '/usr/local/lib/php/pecl/20230831/ffi' (no such file)), /usr/local/lib/php/pecl/20230831/ffi.so (dlopen(/usr/local/lib/php/pecl/20230831/ffi.so, 0x0009): tried: '/usr/local/lib/php/pecl/20230831/ffi.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20230831/ffi.so' (no such file), '/usr/local/lib/php/pecl/20230831/ffi.so' (no such file))) in Unknown on line 0

    I imagined it was something with the FFI library, so I decided to install it using perl, however, the message appears to me:

    Captura de Tela 2024-04-30 às 03 09 43

  4. CodeWithKyrian commented on May 3, 2024

    @CodeWithKyrian
    Owner

    Hello @victorratts13. Does the problem still persist? It appears to be a problem with your FFI setup. If I may ask, how did you php? Herd, Brew or apt-get?

  5. victorratts13 commented on May 3, 2024

    @victorratts13
    Author

    I just found the problem.

    1 - I installed an ubuntu-server VM to test outside my work environment.

    2 - I installed all the development packages that transformersphp uses

    sudo apt update && sudo apt install -y libffi-dev libz-dev libpng-dev git libzip-dev

    3 - I ran the code again and it worked

    Conclusion

    It remained to install the dependencies that make FFI work within the command line

  6. CodeWithKyrian commented on May 6, 2024

    @CodeWithKyrian
    Owner

    Oh, that's great. I was going to suggest installing php-ffi using apt-get actually. I'm glad it's all resolved

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

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions