Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6797325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:35:42+00:00 2026-05-26T18:35:42+00:00

In extensions to ruby RARRAY_PTR() which returns a VALUE* for a given ruby array

  • 0

In extensions to ruby RARRAY_PTR() which returns a VALUE* for a given ruby array is dangerous, since it does no type checks. For example this will probably segfault:

VALUE a= rb_hash_new();
RARRAY_PTR(a)[999];

I sometimes find myself storing an array into an instance variable and then later doing RARRAY_PTR() on this instance variable. This can be dangerous since there are ways to tamper with any objects instance variables. If someone does this, I could be ending up doing RARRAY_PTR() one something which is not an array.

Is it bad pratice to rely on otheres not changing my instance variables, or is it there fault if then the ruby interpreter segfaults?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:35:43+00:00Added an answer on May 26, 2026 at 6:35 pm

    I wouldn’t worry about it that much. If someone is messing around with your instance variables then they’re responsible for whatever damage they cause.

    If someone uses instance_varible_set to change an instance variable from an array to a Fixnum in a pure Ruby class, then you’ll probably end up with a NoMethodError; if they do it to your C backed class, they’ll get a segfault.

    Basically, if someone wants to smash themselves in the face with a brick by messing around with an object’s internals, then it isn’t your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rails introduced some core extensions to Ruby like 3.days.from_now which returns, as you'd expect
I have the following error during sqlite3-ruby install: Building native extensions. This could take
Is there a prescribed way to clean up Ruby Gems which have native extensions
The following error comes up: C:\gem>gem install sqlite3-ruby --local Building native extensions. This could
Windows Vista, Ruby v. 3.3.5 C:\>gem install rmagick Building native extensions. This could take
Any suggestions? C:\Users\Steve\barcoden>gem install ruby-debug Building native extensions. This could take a while... ERROR:
When I tried to install: gem install sqlite3-ruby it shows: Building native extensions. This
I am currently trying to install the gem nfoiled , which provides a ruby
What are the trade offs between ffi and mri c extensions in ruby?
Not sure if many people are familiar with Scaffolding Extensions for Ruby, but I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.