Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in deepcopy(Base.GenericCondition(ReentrantLock())) from 1.7.3 to 1.8.0 (also present on master) #46405

Closed
DilumAluthge opened this issue Aug 19, 2022 · 0 comments · Fixed by #46406
Labels
bug Indicates an unexpected problem or unintended behavior multithreading Base.Threads and related functionality parallelism Parallel or distributed computation regression Regression in behavior compared to a previous version

Comments

@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 19, 2022

deepcopy(Base.GenericCondition(ReentrantLock())) works on 1.7.3 but errors on 1.8.0 and master.

On 1.7.3:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.3 (2022-05-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> a = Base.GenericCondition(ReentrantLock())
Base.GenericCondition{ReentrantLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, Base.GenericCondition{Base.Threads.SpinLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), 0))

julia> b = deepcopy(a)
Base.GenericCondition{ReentrantLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, Base.GenericCondition{Base.Threads.SpinLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), 0))

On 1.8.0:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0 (2022-08-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> a = Base.GenericCondition(ReentrantLock())
Base.GenericCondition{ReentrantLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.InvasiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (0, 0, 0)))

julia> b = deepcopy(a)
ERROR: MethodError: no method matching deepcopy_internal(::ReentrantLock)
Closest candidates are:
  deepcopy_internal(::Base.AbstractLock, ::IdDict) at deepcopy.jl:130
  deepcopy_internal(::Any, ::IdDict) at deepcopy.jl:53
  deepcopy_internal(::BigInt, ::IdDict) at gmp.jl:794
  ...
Stacktrace:
 [1] deepcopy_internal
   @ ./deepcopy.jl:143 [inlined]
 [2] deepcopy(x::Base.GenericCondition{ReentrantLock})
   @ Base ./deepcopy.jl:26
 [3] top-level scope
   @ REPL[2]:1

On nightly (1.9.0-DEV.1151):

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-DEV.1151 (2022-08-18)
 _/ |\__'_|_|_|\__'_|  |  Commit 6b8e9f97ec9 (0 days old master)
|__/                   |

julia> a = Base.GenericCondition(ReentrantLock())
Base.GenericCondition{ReentrantLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), ReentrantLock(nothing, 0x00000000, 0x00, Base.GenericCondition{Base.Threads.SpinLock}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0)), (0, 0, 0)))

julia> b = deepcopy(a)
ERROR: MethodError: no method matching deepcopy_internal(::ReentrantLock)

Closest candidates are:
  deepcopy_internal(::Base.AbstractLock, ::IdDict)
   @ Base deepcopy.jl:130
  deepcopy_internal(::Any, ::IdDict)
   @ Base deepcopy.jl:53
  deepcopy_internal(::BigInt, ::IdDict)
   @ Base gmp.jl:795
  ...

Stacktrace:
 [1] deepcopy_internal
   @ ./deepcopy.jl:143 [inlined]
 [2] deepcopy(x::Base.GenericCondition{ReentrantLock})
   @ Base ./deepcopy.jl:26
 [3] top-level scope
   @ REPL[2]:1

Motivation

The motivation is that I have a struct of the form:

struct Foo
    bar::Channel{Bool}
end

Foo() = Foo(Channel{Bool}(0))

And then I want to be able to do the following

julia> a = Foo()

julia> b = deepcopy(a)

This code works on 1.7.3 but errors on 1.8.0 and nightly; here's the stacktrace on nightly:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-DEV.1151 (2022-08-18)
 _/ |\__'_|_|_|\__'_|  |  Commit 6b8e9f97ec9 (0 days old master)
|__/                   |

julia> struct Foo
           bar::Channel{Bool}
       end

julia> Foo() = Foo(Channel{Bool}(0))
Foo

julia> a = Foo()
Foo(Channel{Bool}(0))

julia> b = deepcopy(a)
ERROR: MethodError: no method matching deepcopy_internal(::ReentrantLock)

Closest candidates are:
  deepcopy_internal(::Base.AbstractLock, ::IdDict)
   @ Base deepcopy.jl:130
  deepcopy_internal(::Any, ::IdDict)
   @ Base deepcopy.jl:53
  deepcopy_internal(::BigInt, ::IdDict)
   @ Base gmp.jl:795
  ...

Stacktrace:
 [1] deepcopy_internal(x::Base.GenericCondition{ReentrantLock}, stackdict::IdDict{Any, Any})
   @ Base ./deepcopy.jl:143
 [2] deepcopy_internal(x::Any, stackdict::IdDict{Any, Any})
   @ Base ./deepcopy.jl:65
 [3] deepcopy_internal
   @ ./deepcopy.jl:76 [inlined]
 [4] deepcopy(x::Foo)
   @ Base ./deepcopy.jl:26
 [5] top-level scope
   @ REPL[4]:1
@DilumAluthge DilumAluthge added the regression Regression in behavior compared to a previous version label Aug 19, 2022
@DilumAluthge DilumAluthge added bug Indicates an unexpected problem or unintended behavior parallelism Parallel or distributed computation multithreading Base.Threads and related functionality labels Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior multithreading Base.Threads and related functionality parallelism Parallel or distributed computation regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant