Project

General

Profile

Actions

Bug #20250

closed

Crash with "Object ID seen, but not in mapping table: proc" error

Added by zetter (Chris Zetter) 3 months ago. Updated about 2 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
[ruby-core:116643]

Description

Hello, I experienced a crash which I was able to reliably reproduce with the following:


require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'
  gem 'activesupport', '7.1.3'
end

require 'active_support'

logger = ActiveSupport::Logger.new('log/log.log', 1, 100 * 1024 * 1024)

logger.formatter = proc {|_, _, _, message| "#{message}\n" }

logger = ActiveSupport::TaggedLogging.new(logger)

logger.tagged("TAG").info "hello"
logger.tagged("TAG").info "hello" # usually crashes here
GC.start # sometimes need to trigger crash with GC

It looks like this is caused by the interaction with the formatter proc and the tagged logging features of activesupport. Let me know if a more minimal example would be useful.

I can reproduce this with:

  • ruby 3.3.0 on arm64-darwin23
  • ruby 3.3.0 on x86_64-linux
  • latest ruby HEAD (5e12b75716) on arm64-darwin23

I cannot reproduce this on ruby 3.2.2.

Thanks for any help


Files

ruby-2024-02-09-092829.ips (13.2 KB) ruby-2024-02-09-092829.ips zetter (Chris Zetter), 02/09/2024 10:05 AM
output.log (142 KB) output.log zetter (Chris Zetter), 02/09/2024 10:05 AM
crash_test_2.rb (465 Bytes) crash_test_2.rb reproduction zetter (Chris Zetter), 02/09/2024 10:10 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #20253: `Proc.dup` and `Proc#clone` don't preserve finalizersClosedActions

Updated by byroot (Jean Boussier) 3 months ago

I had a quick look and this is very interesting. As far as I can tell cached_object_id for this Proc, so the most likely explanation is that some other part of the codebase is messing with the object flags.

I'll try to dig deeper.

Updated by byroot (Jean Boussier) 3 months ago

Alright, it's a bug in #clone, I managed to reduce it to:

proc = Proc.new { }
proc.object_id
proc.clone
GC.start

Shouldn't be too hard to figure out. IIRC Proc#clone was modified recently, the flag that indicate the instance has an object_id need to be cleared on the cloned object.

Updated by byroot (Jean Boussier) 3 months ago

  • Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.0: WONTFIX, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED

Patch: https://github.com/ruby/ruby/pull/9903

Also this bug affect all Ruby versions since the new object_id implementation back in 2.7, I got all of them to crash on it.

Actions #4

Updated by byroot (Jean Boussier) 3 months ago

  • Status changed from Open to Closed

Applied in changeset git|d19d683a354530a27b4cbb049223f8dc70c75849.


rb_obj_setup: do not copy RUBY_FL_SEEN_OBJ_ID

[Bug #20250]

We're seting up a new instance, so it never had an associated
object_id.

Actions #5

Updated by byroot (Jean Boussier) 3 months ago

  • Related to Bug #20253: `Proc.dup` and `Proc#clone` don't preserve finalizers added

Updated by naruse (Yui NARUSE) about 2 months ago

  • Backport changed from 3.0: WONTFIX, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.0: WONTFIX, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE

ruby_3_3 a63e979853783601a60228b45741f8b3776e5507 merged revision(s) d19d683a354530a27b4cbb049223f8dc70c75849,de1a586ecc2ee7f465f0c0a69291054136a3a819.

Actions

Also available in: Atom PDF

Like0
Like0Like1Like0Like0Like0Like0