Skip to content

Difference with Fiddle::Pointer#ref and FFI backend #182

Closed

Description

@ankane

Hi, with the C backend, the code below updates ptr in-place. However, with the FFI backend, ptr is unchanged (with both JRuby and TruffleRuby).

require "fiddle"

ptr = Fiddle::Pointer["hello"]
i = ptr.to_i

ptr.ref[0, Fiddle::SIZEOF_VOIDP] = Fiddle::Pointer["world"]
p ptr.to_i == i # false for C backend, true for FFI backend

I'm having trouble finding the cause (to try to make the behavior consistent), so wanted to see if anyone had ideas.

Activity

  1. changed the title [-]Difference with `Fiddle::Pointer.ref` and FFI backend[/-] [+]Difference with `Fiddle::Pointer#ref` and FFI backend[/+] on Apr 22, 2025
  2. kou commented on Apr 22, 2025

    @kou
    Member

    In general, the C backend is the referenced implementation. So we should fix the FFI backend.

  3. ankane commented on Apr 22, 2025

    @ankane
    ContributorAuthor

    Submitted a PR in #185.

  4. added a commit that references this issue on Apr 23, 2025
    0becddc
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions