-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Labels
Description
Describe the bug, including details regarding any error messages, version, and platform.
#48880 is marked as fixed, but I'm still getting corrupted values.
It is very difficult to create a test case that reliably demonstrates the problem. This defines a finaliser on the string literal, but we need to go through some hoops to make sure it is not in scope of any block.
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
require 'objspace'
class TestExecutePlan < Test::Unit::TestCase
class LiveChecker
def initialize
@live = true
end
def check(object)
ObjectSpace.define_finalizer(object, self.class.create_finalizer(self))
object
end
def live?
GC.start
@live
end
def finalize
@live = false
end
def self.create_finalizer(checker)
proc { checker.finalize }
end
end
def test_filter_expressions_live
checker = LiveChecker.new
table = Arrow::Table.new(
'foo' => [1, 2],
'bar' => %w[a b],
)
plan = Arrow::ExecutePlan.new
node = plan.build_source_node(table)
node = plan.build_filter_node(
node,
Arrow::FilterNodeOptions.new(
Arrow::CallExpression.new('equal', [:bar, checker.check('a')]),
),
)
assert do
checker.live?
end
end
def test_project_expressions_live
checker = LiveChecker.new
table = Arrow::Table.new(
'foo' => [1, 2],
'bar' => [%w[a b], %w[c d]],
)
plan = Arrow::ExecutePlan.new
node = plan.build_source_node(table)
node = plan.build_project_node(
node,
Arrow::ProjectNodeOptions.new(
[
:foo,
Arrow::CallExpression.new('binary_join', [:bar, checker.check(',')]),
],
%w[foo bar],
),
)
assert do
checker.live?
end
end
endThese tests pass if I add CallExpression, FilterNodeOptions, and ProjectNodeOptions to the gc_guard in loader.rb, but I'm not sure if it is the correct solution.
Component(s)
Ruby