Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ struct SystemError <: Exception
end

lock(::IO) = nothing
typeof(lock).name.max_methods = UInt8(1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if a method of lock gets defined and a method instance gets compiled/inferred before you change max_methods here? Would it cause miscompilation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From grepping the code and looking at the include order in Base.jl I think this is where the function is declared the first time, so that should not happen.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if some other PR switches the code around a bit, sometime in the future? Will we get miscompilation silently?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a separate concern from this PR since this code pattern is already used in other places already. Maybe move the discussion to a separate issue?

Copy link
Copy Markdown
Member

@nsajko nsajko Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a separate issue. The pattern of modifying max_methods for a function is only used for a few examples currently:

So if it becomes common to modify max_methods for various functions all over the code base, I think then we would actually need to start worrying about stuff like this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since it is already in the code base, a dedicated issue makes more sense rather than comments on a PR.

unlock(::IO) = nothing
typeof(unlock).name.max_methods = UInt8(1)

"""
reseteof(io)
Expand Down