ruby / ruby/fiddle

The clone method of Fiddle::CStruct object is shallow copy

Open
#66 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
195
Forks
53
Avg merge
23h 57m
Merged PRs (30d)
1

Description

Fiddle

require 'fiddle/import'

S = Fiddle::Importer.struct(["int i"])

a = S.malloc

a.i = 10

b = a.clone

b.i = 20

p a.i # 20
p b.i # 20

Ruby-FFI

require 'ffi'

class S < FFI::Struct
  layout :i, :int
end

a = S.new

a[:i] = 10

b = a.clone

b[:i] = 20

p a[:i] # 10
p b[:i] # 20

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Fiddle::CStruct and Ruby-FFI examples in the issue and compare the clone results. Trace the Fiddle::CStruct clone behavior and determine how copied values should be isolated; done means changing the cloned struct no longer changes the original, while the Ruby-FFI comparison remains the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.