Project

General

Profile

Actions

Bug #12662

closed

rb_hash_fetch() Segmentation fault on an empty hash table

Added by rocco (Rocco Carbone) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
[ruby-core:76789]

Description

I am writing HTM (Hash Table Machine - a C benchmark program for hash table) and libruby aborts with

ruby: [BUG] Segmentation fault at 0x00000000000018
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

while attempting to get an entry from an empty hash table.

Attached is a simple program that reproduces the bug.

Hope it helps.

ciao

/rocco


Files

ruby-bug.c (652 Bytes) ruby-bug.c I am on a Debian stretch/sid and compile the example program with gcc -g `pkg-config --cflags ruby` ruby-bug.c `pkg-config --libs ruby` -o ruby-bug rocco (Rocco Carbone), 08/09/2016 08:51 AM

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Rejected

It's your bug.
rb_hash_fetch() raises an exception if the key is not found, and you must catch it by rb_protect().

Updated by rocco (Rocco Carbone) over 7 years ago

I am confused. My C (please note C) program core dumps and libruby gives me an indication I found an error in Ruby an please report and I have to protect?

I am writing a pure C application (C not Ruby) using libruby to benchmark the Ruby's hash implementation versus other languages (PHP, Python, Lua, Perl, TCL).

All plain C. Are you sure I have to protect or I have to patch my own Ruby in order to return NULL in the event the key is not found in the hash table?

No Ruby yet, only C. SIGSEGV is inside Ruby lib not in my code yet.

/rocco

Actions

Also available in: Atom PDF

Like0
Like0Like0