Project

General

Profile

Actions

Bug #17860

closed

Segmentation fault when trying to grab blocks of memory using Fiddle

Added by edipofederle (Édipo Féderle) almost 3 years ago. Updated almost 3 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0dev (2021-04-09T04:59:46Z master 582f4bc188) [x86_64-darwin20]
[ruby-core:103810]

Description

Reproduce process

ruby version: ruby 3.1.0dev (2021-04-09T04:59:46Z master 582f4bc188) [x86_64-darwin20]

Install ruby with:

$ git clone git@github.com:ruby/ruby.git
$ cd ruby
$ autoconf
$ ./configure --prefix=$PWD/local
$ make
$ make install 

create a test.rb file with:

require 'fiddle'
str = "Hello world!"
str_ptr_int = str.object_id << 1

str_ptr = Fiddle::Pointer.new str_ptr_int
str_ptr.to_i == str_ptr_int

r_basic = str_ptr[0, Fiddle::SIZEOF_LONG*2]

Inside compiled ruby directly run:

$ ./local/bin/ruby test.rb


Files

ruby_2021-05-12-210059_edipos-MacBook-Pro.txt (21.8 KB) ruby_2021-05-12-210059_edipos-MacBook-Pro.txt edipofederle (Édipo Féderle), 05/13/2021 12:16 AM

Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago

  • Status changed from Open to Rejected

Object#object_id now returns an incrementing integer, it no longer is related to a place in memory. So you are referencing probably uninitialized memory, which should result in a segmentation fault.

Actions

Also available in: Atom PDF

Like0
Like0Like0