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 7090759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:46+00:00 2026-05-28T08:05:46+00:00

My code gives me a segmentation fault when I run it with the rdebug

  • 0

My code gives me a segmentation fault when I run it with the rdebug option on command line:

font_size = {"ft0"=>26, "ft1"=>10, "ft2"=>8, "ft3"=>9, "ft4"=>9, "ft5"=>7, "ft6"=>8, "ft7"=>9, "ft8"=>7, "ft9"=>8, "ft10"=>9, "ft11"=>8}
classes = ["ft3", "ft10", "ft6", "ft9", "ft11", "ft4", "ft2", "ft12"]
large_class = classes.max{|a,b| font_size[a] <=> font_size[b] }
puts large_class.to_s

The error is:

test_segfault.rb:3: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.3.0]

-- control frame ----------
c:0006 p:---- s:0016 b:0016 l:000011 d:000015 IFUNC 
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC  :each
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC  :max
c:0003 p:0089 s:0009 b:0009 l:001588 d:000bc0 EVAL   test_segfault.rb:3
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001588 d:001588 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
test_segfault.rb:3:in `<main>'
test_segfault.rb:3:in `max'
test_segfault.rb:3:in `each'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap

When I run it without the -rdebug option, I get an error:

ruby test_segfault.rb 
test_segfault.rb:3:in `each': comparison of String with String failed (ArgumentError)
from test_segfault.rb:3:in `max'
from test_segfault.rb:3:in `<main>'

If I modify the sample data the code works fine.

  • 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-28T08:05:46+00:00Added an answer on May 28, 2026 at 8:05 am

    Looks like you are missing ft12 in font_size.

    classes.map{|e| font_size[e]}
    [9, 9, 8, 8, 8, 9, 8, nil]
    

    My ruby-1.9.2-p290 doesn’t segfault but gives out this error. The segfault bug should have already been fixed.

    /rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/debug.rb:130:in `eval':comparison of String with String failed
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code gives a segmentation fault on the last line require 'rubygems' gem
In this code, for vector size, n >=32767, it gives segmentation fault, but upto
The following piece of code gives a segmentation fault when allocating memory for the
Given the code below, I get a segmentation fault if I run it with
The following C Code gives a segmentation fault: #include <stdio.h> #include <stdint.h> int main(){
This portion of my code (for this project ) gives me a segmentation fault.
Why this below code gives segmentation fault? int main() { char *t = Working
Why does the following code give me a segmentation fault? #define MAXROWS 10 #define
Executing the below code gives me the following exception on the last line: InvalidOperationException:
My c++ program gives me a seg fault when I run as root from

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.