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

pkg> st fails second time around with ERROR: MethodError: no method matching Int64(::Dates.DateTime) #4017

Closed
PallHaraldsson opened this issue Sep 8, 2024 · 29 comments · Fixed by JuliaLang/julia#55892

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Sep 8, 2024

This is a very strange bug to me, and likely has nothing to do with PythonCall, though seemingly the only thing triggering it, showing verbatim:

$ julia +1.11
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.0-rc3 (2024-08-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [6099a3de] PythonCall v0.9.23 `~/.julia/dev/PythonCall`

julia> @time_imports using PythonCall
     10.9 ms  UnsafePointers
      0.9 ms  Printf
     81.7 ms  Dates
      0.3 ms  UUIDs
      1.4 ms  TOML
     23.2 ms  Preferences
      0.4 ms  PrecompileTools
               ┌ 0.0 ms Parsers.__init__() 
    254.0 ms  Parsers 78.78% compilation time
      0.6 ms  Mmap
      7.3 ms  StructTypes
     53.1 ms  JSON3
      0.4 ms  Pidfile
      1.3 ms  Base64
               ┌ 0.0 ms NetworkOptions.__init__() 
      3.3 ms  NetworkOptions
               ┌ 0.0 ms MbedTLS_jll.__init__() 
      3.4 ms  MbedTLS_jll
               ┌ 0.0 ms LibSSH2_jll.__init__() 
      3.1 ms  LibSSH2_jll
               ┌ 0.0 ms LibGit2_jll.__init__() 
      3.1 ms  LibGit2_jll
     15.3 ms  LibGit2
     15.9 ms  ArgTools
               ┌ 0.0 ms nghttp2_jll.__init__() 
      3.5 ms  nghttp2_jll
               ┌ 0.0 ms LibCURL_jll.__init__() 
      4.2 ms  LibCURL_jll
               ┌ 0.0 ms MozillaCACerts_jll.__init__() 
      3.8 ms  MozillaCACerts_jll
               ┌ 0.0 ms LibCURL.__init__() 
      1.5 ms  LibCURL
               ┌ 0.0 ms Downloads.Curl.__init__() 
     28.4 ms  Downloads
      1.1 ms  Tar
               ┌ 0.1 ms p7zip_jll.__init__() 
      5.4 ms  p7zip_jll
      0.2 ms  Logging
     16.7 ms  Markdown
               ┌ 0.0 ms Pkg.__init__() 
    388.8 ms  Pkg
      0.3 ms  Scratch
      0.2 ms  LazyArtifacts
      0.4 ms  JLLWrappers
               ┌ 5.4 ms micromamba_jll.__init__() 95.66% compilation time
      5.8 ms  micromamba_jll 88.54% compilation time
      0.4 ms  MicroMamba
               ┌ 248.0 ms CondaPkg.PkgREPL.__init__() 99.49% compilation time
    252.4 ms  CondaPkg 97.76% compilation time
               ┌ 0.0 ms Requires.__init__() 
      0.5 ms  Requires
     13.1 ms  MacroTools
      0.2 ms  DataValueInterfaces
      1.0 ms  DataAPI
      0.2 ms  IteratorInterfaceExtensions
      0.2 ms  TableTraits
      4.5 ms  OrderedCollections
     15.9 ms  Tables
      1.3 ms  Serialization
               ┌ 1822.4 ms PythonCall.C.__init__() 90.45% compilation time
               ├ 0.0 ms PythonCall.GC.__init__() 
               ├ 1016.6 ms PythonCall.Core.__init__() 96.71% compilation time
               ├ 160.5 ms PythonCall.Convert.__init__() 99.50% compilation time
               ├ 0.0 ms PythonCall.Wrap.__init__() 
               ├ 0.0 ms PythonCall.JlWrap.Cjl.__init__() 
               ├ 67.3 ms PythonCall.JlWrap.__init__() 81.75% compilation time
               ├ 23.0 ms PythonCall.Compat.__init__() 94.89% compilation time
   3197.9 ms  PythonCall 89.68% compilation time

(@v1.11) pkg> st
ERROR: MethodError: no method matching Int64(::Dates.DateTime)
The type `Int64` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Int64(::Float64)
   @ Base float.jl:990
  Int64(::Float32)
   @ Base float.jl:990
  Int64(::Float16)
   @ Base float.jl:990
  ...

Stacktrace:
  [1] Dates.DateTime(y::Dates.DateTime, m::Int64, d::Int64, h::Int64, mi::Int64, s::Int64, ms::Int64, ampm::Dates.AMPM)
    @ Dates ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Dates/src/types.jl:421
  [2] (::Pkg.Types.var"#53#56"{String, String})(d::Dict{String, Any})
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:556
  [3] iterate
    @ ./generator.jl:48 [inlined]
  [4] _collect(c::Vector{Any}, itr::Base.Generator{Vector{Any}, Pkg.Types.var"#53#56"{String, String}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:800
  [5] collect_similar(cont::Vector{Any}, itr::Base.Generator{Vector{Any}, Pkg.Types.var"#53#56"{String, String}})
    @ Base ./array.jl:709
  [6] map(f::Function, A::Vector{Any})
    @ Base ./abstractarray.jl:3374
  [7] (::Pkg.Types.var"#52#55"{String, String, Dates.DateTime, String})()
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:554
  [8] mkpidlock(f::Pkg.Types.var"#52#55"{String, String, Dates.DateTime, String}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:95
  [9] mkpidlock
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:92 [inlined]
 [10] mkpidlock
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:90 [inlined]
 [11] write_env_usage(source_file::String, usage_filepath::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:537
 [12] Pkg.Types.EnvCache(env::Nothing)
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:375
 [13] EnvCache
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:354 [inlined]
 [14] Context
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:404 [inlined]
 [15] status(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:150
 [16] status(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:148
 [17] do_cmd(command::Pkg.REPLMode.Command, io::Base.TTY)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:407
 [18] do_cmds(commands::Vector{Pkg.REPLMode.Command}, io::Base.TTY)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:393
 [19] do_cmds(repl::REPL.LineEditREPL, commands::String)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:92
 [20] on_done(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool, repl::REPL.LineEditREPL)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:106
 [21] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [22] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [23] (::REPLExt.var"#47#50"{REPL.LineEditREPL})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:128
 [24] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [25] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [26] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2749
 [27] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1456
 [28] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:461

(@v1.11) pkg> st
ERROR: MethodError: no method matching Int64(::Dates.DateTime)

Yes, I'm deving the package (and Markdown its dependency, seemingly successfully, just added precompile statements there), but I didn't really change PythonCall, some very minor changes, besides they shouldn't make this happen?!

@PallHaraldsson
Copy link
Contributor Author

Note segfault when trying similar (why not in my original report?), just opened another tab and Julia, again verbatim:

$ julia +1.11
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.0-rc3 (2024-08-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [6099a3de] PythonCall v0.9.23 `~/.julia/dev/PythonCall`

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [6099a3de] PythonCall v0.9.23 `~/.julia/dev/PythonCall`

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [6099a3de] PythonCall v0.9.23 `~/.julia/dev/PythonCall`

julia> @time_imports using PythonCall
      9.5 ms  UnsafePointers
      1.0 ms  Printf
     79.7 ms  Dates
      0.3 ms  UUIDs
      1.2 ms  TOML
     20.9 ms  Preferences
      0.4 ms  PrecompileTools
               ┌ 0.1 ms Parsers.__init__() 
    270.0 ms  Parsers 81.91% compilation time
      0.9 ms  Mmap
      9.4 ms  StructTypes
     77.7 ms  JSON3
      0.5 ms  Pidfile
      1.5 ms  Base64
               ┌ 0.0 ms NetworkOptions.__init__() 
      5.0 ms  NetworkOptions
               ┌ 0.1 ms MbedTLS_jll.__init__() 
      6.4 ms  MbedTLS_jll
               ┌ 0.1 ms LibSSH2_jll.__init__() 
      4.5 ms  LibSSH2_jll
               ┌ 0.1 ms LibGit2_jll.__init__() 
      5.3 ms  LibGit2_jll
     20.9 ms  LibGit2
     21.0 ms  ArgTools
               ┌ 0.1 ms nghttp2_jll.__init__() 
      4.3 ms  nghttp2_jll
               ┌ 0.1 ms LibCURL_jll.__init__() 
      6.3 ms  LibCURL_jll
               ┌ 0.0 ms MozillaCACerts_jll.__init__() 
      5.4 ms  MozillaCACerts_jll
               ┌ 0.0 ms LibCURL.__init__() 
      1.9 ms  LibCURL
               ┌ 0.0 ms Downloads.Curl.__init__() 
     39.6 ms  Downloads
      1.9 ms  Tar
               ┌ 0.1 ms p7zip_jll.__init__() 
      7.7 ms  p7zip_jll
      0.3 ms  Logging
     21.8 ms  Markdown
               ┌ 0.0 ms Pkg.__init__() 
    525.0 ms  Pkg
      0.4 ms  Scratch
      0.2 ms  LazyArtifacts
      0.4 ms  JLLWrappers
               ┌ 5.9 ms micromamba_jll.__init__() 94.27% compilation time
      6.4 ms  micromamba_jll 87.16% compilation time
      0.6 ms  MicroMamba
               ┌ 297.6 ms CondaPkg.PkgREPL.__init__() 99.64% compilation time
    302.4 ms  CondaPkg 98.05% compilation time
               ┌ 0.0 ms Requires.__init__() 
      0.7 ms  Requires
     16.9 ms  MacroTools
      0.4 ms  DataValueInterfaces
      1.4 ms  DataAPI
      0.3 ms  IteratorInterfaceExtensions
      0.3 ms  TableTraits
      5.3 ms  OrderedCollections
     21.7 ms  Tables
      1.5 ms  Serialization
               ┌ 1900.8 ms PythonCall.C.__init__() 90.32% compilation time
               ├ 0.0 ms PythonCall.GC.__init__() 
               ├ 
[2001444] signal 11 (1): Segmentation fault
in expression starting at REPL[1]:1
pymalloc_alloc at /usr/local/src/conda/python-3.12.5/Objects/obmalloc.c:1544 [inlined]
_PyObject_Malloc at /usr/local/src/conda/python-3.12.5/Objects/obmalloc.c:1564 [inlined]
PyObject_Malloc at /usr/local/src/conda/python-3.12.5/Objects/obmalloc.c:801 [inlined]
gc_alloc at /usr/local/src/conda/python-3.12.5/Modules/gcmodule.c:2307 [inlined]
_PyObject_GC_New at /usr/local/src/conda/python-3.12.5/Modules/gcmodule.c:2322 [inlined]
PyMethod_New at /usr/local/src/conda/python-3.12.5/Objects/classobject.c:113 [inlined]
func_descr_get at /usr/local/src/conda/python-3.12.5/Objects/funcobject.c:895
_PyEval_EvalFrameDefault at /home/conda/feedstock_root/build_artifacts/python-split_1723141048588/work/build-shared/Python/bytecodes.c:2501
_PyObject_VectorcallTstate at /usr/local/src/conda/python-3.12.5/Include/internal/pycore_call.h:92 [inlined]
object_vacall at /usr/local/src/conda/python-3.12.5/Objects/call.c:850
PyObject_CallMethodObjArgs at /usr/local/src/conda/python-3.12.5/Objects/call.c:911
import_find_and_load at /usr/local/src/conda/python-3.12.5/Python/import.c:2779 [inlined]
PyImport_ImportModuleLevelObject at /usr/local/src/conda/python-3.12.5/Python/import.c:2862
builtin___import___impl at /usr/local/src/conda/python-3.12.5/Python/bltinmodule.c:275 [inlined]
builtin___import__ at /usr/local/src/conda/python-3.12.5/Python/clinic/bltinmodule.c.h:107
cfunction_vectorcall_FASTCALL_KEYWORDS at /usr/local/src/conda/python-3.12.5/Objects/methodobject.c:438
_PyObject_VectorcallTstate at /usr/local/src/conda/python-3.12.5/Include/internal/pycore_call.h:92 [inlined]
_PyObject_CallFunctionVa at /usr/local/src/conda/python-3.12.5/Objects/call.c:562 [inlined]
PyObject_CallFunction at /usr/local/src/conda/python-3.12.5/Objects/call.c:584
PyImport_Import at /usr/local/src/conda/python-3.12.5/Python/import.c:3048
PyImport_Import at /home/pharaldsson/.julia/dev/PythonCall/src/C/pointers.jl:303
unknown function (ip: 0x7f545273a904)
macro expansion at /home/pharaldsson/.julia/dev/PythonCall/src/Core/Py.jl:132 [inlined]
pyimport at /home/pharaldsson/.julia/dev/PythonCall/src/Core/builtins.jl:1561
pyimport at /home/pharaldsson/.julia/dev/PythonCall/src/Core/builtins.jl:1562
init_consts at /home/pharaldsson/.julia/dev/PythonCall/src/Core/consts.jl:205
__init__ at /home/pharaldsson/.julia/dev/PythonCall/src/Core/Core.jl:48
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_module_run_initializer at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:76
run_module_init at ./loading.jl:1277
register_restored_modules at ./loading.jl:1255
_include_from_serialized at ./loading.jl:1199
_include_from_serialized at ./loading.jl:1156 [inlined]
#_require_search_from_serialized#1075 at ./loading.jl:1921
_require_search_from_serialized at ./loading.jl:1843
jfptr__require_search_from_serialized_44488.1 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
_require at ./loading.jl:2382
__require_prelocked at ./loading.jl:2247
jfptr___require_prelocked_69631.1 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_in_world at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:894
#invoke_in_world#3 at ./essentials.jl:1088 [inlined]
invoke_in_world at ./essentials.jl:1085 [inlined]
_require_prelocked at ./loading.jl:2234
macro expansion at ./loading.jl:2173 [inlined]
macro expansion at ./lock.jl:273 [inlined]
__require at ./loading.jl:2130
jfptr___require_69567.1 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_in_world at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:894
#invoke_in_world#3 at ./essentials.jl:1088 [inlined]
invoke_in_world at ./essentials.jl:1085 [inlined]
require at ./loading.jl:2123
jfptr_require_69564.1 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
call_require at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:486 [inlined]
eval_import_path at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:523
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:759
eval_body at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:629
eval_body at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:539
jl_interpret_toplevel_thunk at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:821
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:943
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:886
ijl_toplevel_eval_in at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:994
eval at ./boot.jl:430 [inlined]
eval_user_input at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:226
repl_backend_loop at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:323
#start_repl_backend#59 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:308
start_repl_backend at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:305
#run_repl#72 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:464
run_repl at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:450
jfptr_run_repl_11642 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_5pcrL.so (unknown line)
#1137 at ./client.jl:441
jfptr_YY.1137_16382 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_5pcrL.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_latest at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:875
#invokelatest#2 at ./essentials.jl:1054 [inlined]
invokelatest at ./essentials.jl:1051 [inlined]
run_main_repl at ./client.jl:425
repl_main at ./client.jl:562 [inlined]
_start at ./client.jl:536
jfptr__start_71892.1 at /home/pharaldsson/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
true_main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:900
jl_repl_entrypoint at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:1059
main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/cli/loader_exe.c:58
unknown function (ip: 0x7f5469db5d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
Allocations: 5894276 (Pool: 5892724; Big: 1552); GC: 7
Segmentation fault (core dumped)
pharaldsson@ryksugan:~$ The type `Int64` exists, but no method is defined for this combination of arg

@PallHaraldsson

This comment was marked as duplicate.

@PallHaraldsson
Copy link
Contributor Author

This doesn't happen in rc2, so I likely messed up rc3 with my Markdown change. Even if I undo that change of rc3, or try...,, it doesn't seem to take, i.e. I still get the error. I guess the Markdown precompile statements can't be undone? Precompilation is triggered when I added them, and I think should happen each time there's a change, but I'm using a stale pkgimage? Why isn't it updated if I change the source?

@PallHaraldsson
Copy link
Contributor Author

@cdoris, are you doing something unusual in CondaPkg, with Julia's internals? You change Pkg, or the REPL mode, not sure if it's disallowed, or not guaranteed to work in later Julia versions.

Note this works in my rc2 (where I've not changed Markdown). Also in rc3 works with Markdown alone (that I changed and may not have undone the right way, so can someone reproduce this error with an unchanged rc3), but not with otherwise unchanged CondaPkg:

$ julia +1.11
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.0-rc3 (2024-08-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [992eb4ea] CondaPkg v0.2.23
  [6099a3de] PythonCall v0.9.23

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [992eb4ea] CondaPkg v0.2.23
  [6099a3de] PythonCall v0.9.23

julia> using Markdown

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [992eb4ea] CondaPkg v0.2.23
  [6099a3de] PythonCall v0.9.23

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [992eb4ea] CondaPkg v0.2.23
  [6099a3de] PythonCall v0.9.23

julia> using CondaPkg

(@v1.11) pkg> st
ERROR: MethodError: no method matching Int64(::Dates.DateTime)
The type `Int64` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Int64(::Float64)
   @ Base float.jl:990
  Int64(::Float32)
   @ Base float.jl:990
  Int64(::Float16)
   @ Base float.jl:990
  ...

Stacktrace:
  [1] Dates.DateTime(y::Dates.DateTime, m::Int64, d::Int64, h::Int64, mi::Int64, s::Int64, ms::Int64, ampm::Dates.AMPM)
    @ Dates ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Dates/src/types.jl:421
  [2] (::Pkg.Types.var"#53#56"{String, String})(d::Dict{String, Any})
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:556
  [3] iterate
    @ ./generator.jl:48 [inlined]
  [4] _collect(c::Vector{Any}, itr::Base.Generator{Vector{Any}, Pkg.Types.var"#53#56"{String, String}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:800
  [5] collect_similar(cont::Vector{Any}, itr::Base.Generator{Vector{Any}, Pkg.Types.var"#53#56"{String, String}})
    @ Base ./array.jl:709
  [6] map(f::Function, A::Vector{Any})
    @ Base ./abstractarray.jl:3374
  [7] (::Pkg.Types.var"#52#55"{String, String, Dates.DateTime, String})()
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:554
  [8] mkpidlock(f::Pkg.Types.var"#52#55"{String, String, Dates.DateTime, String}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:95
  [9] mkpidlock
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:92 [inlined]
 [10] mkpidlock
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:90 [inlined]
 [11] write_env_usage(source_file::String, usage_filepath::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:537
 [12] Pkg.Types.EnvCache(env::Nothing)
    @ Pkg.Types ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:375
 [13] EnvCache
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:354 [inlined]
 [14] Context
    @ ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/Types.jl:404 [inlined]
 [15] status(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:150
 [16] status(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/API.jl:148
 [17] do_cmd(command::Pkg.REPLMode.Command, io::Base.TTY)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:407
 [18] do_cmds(commands::Vector{Pkg.REPLMode.Command}, io::Base.TTY)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:393
 [19] do_cmds(repl::REPL.LineEditREPL, commands::String)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:92
 [20] on_done(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool, repl::REPL.LineEditREPL)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:106
 [21] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [22] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [23] (::REPLExt.var"#47#50"{REPL.LineEditREPL})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ REPLExt ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Pkg/ext/REPLExt/REPLExt.jl:128
 [24] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [25] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [26] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2749
 [27] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1456
 [28] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:461

@IanButterworth
Copy link
Sponsor Member

I think this is a TOML issue.
I suspect for some reason we stop hitting this method
https://github.com/JuliaLang/julia/blob/1463c9991c4a75730e4d6822313180ca323241c0/stdlib/Dates/src/types.jl#L499
and fall back to the generic Dates.DateTime(y::Any, m::Int64, ...) method.

Could Pkg being loaded via require_stdlib mean that when PythonCall is loaded a different TOML gets loaded?

(@v1.12) pkg> st
Status `~/.julia/environments/v1.12/Project.toml`
  [6099a3de] PythonCall v0.9.23

(@v1.12) pkg> why TOML
  PythonCall → CondaPkg → JSON3 → Parsers → PrecompileTools → Preferences → TOML
  PythonCall → CondaPkg → JSON3 → PrecompileTools → Preferences → TOML
  PythonCall → CondaPkg → MicroMamba → Pkg → TOML
  PythonCall → CondaPkg → MicroMamba → micromamba_jll → JLLWrappers → Preferences → TOML
  PythonCall → CondaPkg → MicroMamba → micromamba_jll → LazyArtifacts → Pkg → TOML
  PythonCall → CondaPkg → Pkg → TOML
  PythonCall → CondaPkg → Preferences → TOML
  PythonCall → CondaPkg → TOML
  PythonCall → Pkg → TOML

@topolarity given you worked on some of the TOML stuff here.
@vtjnash for the require_stdlib behavior.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 9, 2024

yes, you can have any number of different TOML packages loaded, and unless you depend specifically upon a TOML package, you should not assume anything about it being present

@IanButterworth
Copy link
Sponsor Member

Ok. I've not followed the recent TOML changes in Pkg so I defer to @topolarity I think?

@topolarity
Copy link
Member

Pkg does depend on both TOML and Dates, and makes sure to load the Dates-enabled TOML parser always. I'm a bit skeptical that we changed anything there - I think it's always been that way.

We read d["time"] in the TOML dict and get a Dates.DateTime and then pass that to Dates.DateTime(d["time"])

As far as I can tell that's actually supposed to be hitting https://github.com/JuliaLang/julia/blob/1463c9991c4a75730e4d6822313180ca323241c0/stdlib/Dates/src/conversions.jl#L20

I'm not sure why it's not hitting that method - that doesn't seem related to TOML to me.

@KristofferC
Copy link
Sponsor Member

My guess is that there must be two Dates packages loaded and in

  [1] Dates.DateTime(y::Dates.DateTime, m::Int64, d::Int64, h::Int64, mi::Int64, s::Int64, ms::Int64, ampm::Dates.AMPM)
    @ Dates ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Dates/src/types.jl:421

the first Dates and the second Dates are actually different modules?

@topolarity
Copy link
Member

Oh my - so TOML.Dates !== Pkg.Dates and then TOML.parsefile and Pkg.parse_toml return incompatible types

@topolarity
Copy link
Member

That seems terribly broken to me.

How is Julia allowed to break the identity of a common dependency like that?

@KristofferC
Copy link
Sponsor Member

KristofferC commented Sep 9, 2024

I haven't confirmed my suspicion but that is the only way I can imagine hitting that dispatch...

@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 9, 2024

It is permitted, but only in certain configurations (e.g. where there is no dependencies between them, but only an assumption it will exist because of some transitive assumption of being in the other's project files)

@topolarity
Copy link
Member

topolarity commented Sep 9, 2024

Is that defined precisely somewhere?

It's not clear to me whether that would include this situation or not...

@topolarity
Copy link
Member

@PallHaraldsson I'm having trouble reproducing this issue on my end.

Can you try to come up with an MWE that works out-of-the-box with a fresh depot (i.e. using JULIA_DEPOT_PATH="some/temporary/path")?

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 10, 2024

[Probably worth noting is I often do CTRL-C while precompiling packages to avoid OOM... so far always ok, or at best a segfualt and ok after a restart. I'm not sure I did CTRL-C in that case (I even think I didn't), but might have and very probably something got inconsistent in compiled code? I think CTRL-C is supported, or at least is should be... and if not I would like to know and how to then fix after such issues.] I haven't seen this again myself... And maybe CTRL-C is worse if you're deving packages? And deving further fixed things?

I'm not sure I can do an MWE, I basically just added some precompiles and/or deleted stuff from PythonCall if I recall. This isn't supposed to happen, obviously, and even if I deved PythonCall to trigger this I've changed it since, but I do have some julias open where this happened, if there's anything helpful with knowing that, I could do there. The problem didn't go away there, I checked in one julia, nor did I expect that... all in RAM.

I don't know about JULIA_DEPOT_PATH really, not something I've used, if you can tell me exactly what to do then maybe I can be helpful.

This was just so strange to me, that I though opening an issue worthy... even if I can't do more. Though willing.

@IanButterworth
Copy link
Sponsor Member

@topolarity I think we want the trailing : i.e. JULIA_DEPOT_PATH=some/temporary/path: otherwise it won't use the shipped stdlib pkgimages?

@topolarity
Copy link
Member

@PallHaraldsson The idea is that if you start Julia like this:

$ export _JULIA_BUILTIN_DEPOT="$(dirname $(julia +1.10 -e "println(Sys.BINDIR)"))/local/share/julia:$(dirname $(julia +1.10 -e "println(Sys.BINDIR)"))/share/julia"
$ JULIA_DEPOT_PATH="./temp_depot:${_JULIA_BUILTIN_DEPOT}" julia +1.10

That will force Julia to run using a "fresh" registry, compile cache, etc. in "./temp_depot"

If you can show a how to create the problem (from start to finish) after starting Julia as above, that means that it isn't affected by any corrupted cache files, etc. and it should be easier for us to reproduce.

After you're done, you can just rm -rf ./temp_depot to clean up the temporary files

@wheeheee
Copy link

wheeheee commented Sep 26, 2024

Hi, if it's needed I think I've got another MWE in JuliaLang/julia#55887? There, with an additional ]add TOML before everything then replacing using BenchmarkTools with using TOML also produces the error on a fresh install of 1.11.

@topolarity
Copy link
Member

Ugh, unfortunately that still doesn't reproduce for me.

Can you try re-producing with JULIA_DEPOT_PATH, as above?

@wheeheee
Copy link

Sorry, I'm not sure what the Windows equivalent of those commands are. I also realized I can't reproduce that on Fedora...

@topolarity
Copy link
Member

topolarity commented Sep 26, 2024

Oh, on Windows? Let me see... The powershell equivalent looks like this:

$_JULIA_BUILTIN_DEPOT = "$(Split-Path -parent $(julia +1.11 -e "println(Sys.BINDIR)"))\local\share\julia;$(Split-Path -parent $(julia +1.11 -e "println(Sys.BINDIR)"))\share\julia"
$env:JULIA_DEPOT_PATH=".\temp_depot;${_JULIA_BUILTIN_DEPOT}"; julia +1.11; $env:JULIA_DEPOT_PATH=$null

which will run using a temporary depot in .\temp_depot

@wheeheee
Copy link

oops, can't reproduce with a temporary depot too...

@topolarity
Copy link
Member

OK, at least we know there's something going on with the cache.

Can you try running with:

$env:JULIA_DEBUG="loading"; julia +1.11; $env:JULIA_DEBUG=$null

and share the full output here?

(this will run with the default depot, so the problem should still reproduce)

@wheeheee
Copy link

wheeheee commented Sep 26, 2024

Ok, I'm not sure if this is what you're asking for, but I can reliably reproduce the error with the below steps, so here goes:

  1. Run the first command ($_JULIA_BUILTIN_DEPOT = "$(Split-Path -parent $(julia +1.11 -e "println(Sys.BINDIR)"))\local\share\julia;$(Split-Path -parent $(julia +1.11 -e "println(Sys.BINDIR)"))\share\julia" ). (i guess this doesn't do anything, but I ran it anyway...)
  2. Run $env:JULIA_DEPOT_PATH=".\temp_depot"; julia +1.11; $env:JULIA_DEPOT_PATH=$null instead
  3. ]up, making sure a logs/manifest_usage.toml file gets created.
  4. Exit, then manually edit manifest_usage.toml, so there is a second entry, maybe an entry for 1.10 in addition to 1.11
  5. Repeat step 2, then continue with the MWE

@topolarity
Copy link
Member

Woah! Thanks for working so hard to get that MWE, that is extremely helpful.

I can reproduce on my machine with those steps now

@topolarity
Copy link
Member

topolarity commented Sep 26, 2024

Oof, we can even end up loading two copies of Pkg.

One that works and one that doesn't...

(@v1.11) pkg> status
Status `C:\Users\cody\temp_depot\environments\v1.11\Project.toml`
  [fa267f1f] TOML v1.0.3

julia> using TOML

julia> using Pkg # loads a *second* copy of Pkg
[ Info: Precompiling Pkg [44cfe95a-1eb2-52ea-b672-e2afdf69b78f] (cache misses: wrong dep version loaded (2), mismatched flags (2))

julia> Pkg.status() # the new copy works!
Status `C:\Users\cody\temp_depot\environments\v1.11\Project.toml`
  [fa267f1f] TOML v1.0.3

(@v1.11) pkg> status # the old one is still broken
ERROR: MethodError: no method matching Int64(::Dates.DateTime)
The type `Int64` exists, but no method is defined for this combination of argument types when trying to construct it.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 26, 2024

How is the old Pkg getting broken by the loading of later packages? That seems like it should only be possible if one of those packages is doing some invalid hacks around accessing private APIs such as Base.loaded_modules or Base.get_extension

@topolarity
Copy link
Member

Turns out this is a method overload issue - @KristofferC 's spidey senses were tingling for good reason when he pointed out this type piracy

The problem is that using TOML will re-define Base.TOML.Parser(...) to use the last-loaded TOML.Dates. Since the Base.TOML.Parser type is common to Base (rather than specific to each copy of the TOML stdlib) this invalidates the code in Pkg to return DateTimes from the wrong copy of Dates

This specific problem is easy to fix, but it also makes me think more broadly about the correct-ness requirements here. I guess this means that require_stdlib makes type-piracy fatal in stdlibs, if you return any non-Base types?

KristofferC pushed a commit to JuliaLang/julia that referenced this issue Oct 1, 2024
Since stdlibs can be duplicated but Base never is, `Base.require_stdlib`
makes type piracy even more complicated than it normally would be.

To adapt, this changes `TOML.Parser` to be a type defined by the TOML
stdlib, so that we can define methods on it without committing
type-piracy and avoid problems like Pkg.jl#4017

Resolves
JuliaLang/Pkg.jl#4017 (comment)

(cherry picked from commit 2a2878c)
giordano pushed a commit to JuliaLang/julia that referenced this issue Oct 6, 2024
…#56005)

I was a recent offender in
JuliaLang/Pkg.jl#4017 (comment)

This PR tries to lay down some guidelines for the behavior that stdlibs
and the callers of `require_stdlib` must adhere to to avoid "duplicate
stdlib" bugs

These bugs are particularly nasty because they are experienced
semi-rarely and under pretty specific circumstances (they only occur
when `require_stdlib` loads another copy of a stdlib, often in a
particular order and/or with a particular state of your pre-compile /
loading cache) so they may make it a long way through a pre-release
cycle without an actionable bug report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants