Bug #10485
closedNoMethodError "undefined method `initialize_copy'" when trying to execute Queue#dup
Description
Queue#dup raises NoMethodError (Queue#clone as well)
:001 > q = Queue.new
=> #<Thread::Queue:0x00000001507ca0>
:002 > q.dup
NoMethodError: undefined method `initialize_copy' for #<Thread::Queue:0x00000001504c08>
from (irb):2:in `initialize_dup'
from (irb):2:in `dup'
from (irb):2
from /home/bubo/.rvm/rubies/ruby-head/bin/irb:11:in `<main>'
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Related to Bug #9440: Calling methods on a `Queue.new.dup` or `Queue.new.clone` causes Segfault added
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Category changed from lib to ext
- Status changed from Open to Feedback
Why do you need to copy Queue
s?
Updated by bubo47 (Jakub Jursa) about 10 years ago
why not? :)
actually I bumped into this by accident when implementing Queue#to_a
(which basically clones self and empties it into new array which it then returns). So it's not really some kind of blocker bug. But since #clone
and #dup
are methods of Object
, I expected them to work on Queue
s as well.
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Related to Feature #8639: Add Queue#each added
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
Not all methods in super classes always work on all subclasses.
Queue
s hold waiting Thread
s, and copying it may cause them waken up unexpectedly.
Updated by recursive-madman (Recursive Madman) about 10 years ago
Not all methods in super classes always work on all subclasses.
If a method that works on a superclass doesn't work on a subclass, I would expect the subclass to at least mark it as private
and definitely not segfault.
Updated by bubo47 (Jakub Jursa) about 10 years ago
Recursive Madman wrote:
Not all methods in super classes always work on all subclasses.
If a method that works on a superclass doesn't work on a subclass, I would expect the subclass to at least mark it as
private
and definitely not segfault.
definitely.
Updated by naruse (Yui NARUSE) almost 7 years ago
- Target version deleted (
2.2.0)
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Feedback to Closed