Skip to content

Segfault when tool method returns a Hash containing a non-primitive value #3

@tleish

Description

@tleish

When a tool method returns a Hash where one of the values is a non-primitive type, calling eval causes a segfault instead of returning an error result.

Reproduction

require "enclave"

class Tools
  Opaque = Struct.new(:x)

  def bad_hash
    { "ok" => "fine", "bad" => Opaque.new("x") }
  end
end

enclave = Enclave.new(tools: Tools.new)
enclave.eval("bad_hash")

Expected: result.error returns "TypeError: unsupported type for sandbox: Tools::Opaque"

Actual: Segfault

[BUG] Segmentation fault at 0x0000000000000020
ruby 3.1.7p261 [arm64-darwin]

-- Ruby level backtrace information ----------------------------------------
test.rb:12:in `<main>'
.../enclave-0.2.0/lib/enclave.rb:31:in `eval'
.../enclave-0.2.0/lib/enclave.rb:31:in `_eval'

-- Machine register context ------------------------------------------------
  x0: 0x0000000000000020  x1: 0x0000000000000000  x2: 0x0000000000000000
 x19: 0x0000000000000020 x20: 0x0000000000000020 x21: 0x0000000000000001
 x28: 0x0000000000000002

Environment

  • enclave 0.2.0
  • ruby 3.1.7 [arm64-darwin]

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