Project

General

Profile

Actions

Bug #19524

closed

Garbage Collector is not working as expected.

Added by hjimenez89rb (Hugo Alberto Jiménez Santos) over 2 years ago. Updated over 2 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
[ruby-core:112794]

Description

We are currently developing a Ruby based web application which connects to a DB2 Database . WE have been using ibm_db-5.4.0 to establish a connection. We are currently following the IBM and Ruby documentation but the application crashes by garbage collector Ruby error.

We have checked the issue with IBM_team to make sure that It was not a IBM_GEM problem but as a result of their tests, IBM_GEM is working in different cases but for us we face up with those errors even with those versions (2.7.6, 3.1.2, 3.2.1):

*/usr/local/rvm/gems/ruby-3.2.1/gems/ibm_db-5.4.0/lib/active_record/connection_adapters/ibm_db_adapter.rb:3104: warning: undefining the allocator of T_DATA class IBM_DB::Statement
/usr/local/rvm/rubies/ruby-3.2.1/lib/ruby/3.2.0/rubygems/specification.rb:1048: [BUG] object allocation during garbage collection phase

*0x0/usr/local/rvm/gems/ruby-3.1.2/gems/ibm_db-5.4.0/lib/active_record/connection_adapters/ibm_db_adapter.rb:760: [BUG] object allocation during garbage collection phase
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

*Exception occurred on Step thread ID #SID:34117;RSEQ:911723; wrong instance allocation; backtrace: /usr/local/rvm/gems/ruby-3.1.2/gems/ibm_db-5.4.0/lib/active_record/connection_adapters/ibm_db_adapter.rb:760:in server_info' (RuntimeError) /usr/local/rvm/gems/ruby-3.1.2/gems/ibm_db-5.4.0/lib/active_record/connection_adapters/ibm_db_adapter.rb:760:in initialize'.

(all trace is attached in this ticket)

OS
name: "CentOS"
version: "8"
architecture: "x86_64"

rvm:
version: "1.29.12 (latest)"

As an extra error, we're not sure if
Warning! PATH is not properly set up, /usr/local/rvm/gems/ruby-3.2.1/bin is not at first place.
Usually this is caused by shell initialization files. Search for PATH=... entries.
You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
To fix it temporarily in this shell session run: rvm use ruby-3.2.1
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.

Garbage collector leack test this code we have been running manually garbage collector, if you can see in this example:T_STRING. is not deceasing the stings in live memory, Even executig GC manualy. (log is attached)

GC.disable # Only run GC when manually called

an_array = []

loop do
1000.times { an_array << "A" + "B" + "C" }
puts "Array is #{an_array.size} items long"

GC.start # Run a major GC - use full_mark: false for minor GC
pp ObjectSpace.count_objects

sleep 1
end


Files

LOGS3.txt (12.5 KB) LOGS3.txt hjimenez89rb (Hugo Alberto Jiménez Santos), 03/09/2023 05:03 PM
LOGS4.txt (127 KB) LOGS4.txt hjimenez89rb (Hugo Alberto Jiménez Santos), 03/09/2023 05:03 PM
LOGS2.txt (9.62 KB) LOGS2.txt hjimenez89rb (Hugo Alberto Jiménez Santos), 03/09/2023 05:03 PM
LOGS1.txt (123 KB) LOGS1.txt hjimenez89rb (Hugo Alberto Jiménez Santos), 03/09/2023 05:03 PM
leacky.txt (3.64 KB) leacky.txt Garbage collector leack test hjimenez89rb (Hugo Alberto Jiménez Santos), 03/09/2023 05:38 PM

Updated by ufuk (Ufuk Kayserilioglu) over 2 years ago

In your code example you keep adding strings to an array named an_array which has to hold a reference to all those strings. Of course they will not be garbage collected, since they are not garbage, they are live. Imagine if after your loop ... end you were to write the code puts an_array[50], what would you expect to happen? If all the array elements were garbage collected, Ruby would not be able to find any entry at offset 50, but I don't think that's anyones expectation.

Updated by byroot (Jean Boussier) over 2 years ago

  • Status changed from Open to Third Party's Issue

As Ufuk said. You example script is behaving as expected.

As for [BUG] object allocation during garbage collection phase, that indicate a bug in a C-extension.

So It's very unclear what problem you are trying to describe, but at this stage it seems very unlikely to be a Ruby bug. If you can actually demonstrate a Ruby bug I can reopen.

Actions

Also available in: Atom PDF

Like0
Like0Like0