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

safety consideration for operations with incompletely initialized types #54543

Closed
aviatesk opened this issue May 22, 2024 · 2 comments
Closed

Comments

@aviatesk
Copy link
Member

For example, when declaring a type with a field whose type has not yet been defined, an error occurs when trying to construct the type, but the type itself is defined and may be referenced in the subsequent session.
In such cases, performing basic operations like getfield or fieldtype can cause a segfault, and the tfunc that models these operations can also segfault.

For instance, consider the following situation:

julia> struct A
           b::B
       end
ERROR: UndefVarError: `B` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[14]:1

julia> code_typed((A,)) do a
           a.b
       end
Assertion failed: (n > 0 && "expected empty case to be handled during construction"), function jl_compute_fieldtypes, file jltypes.c, line 2692.

[55309] signal 6: Abort trap: 6
in expression starting at REPL[2]:1
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 5286346 (Pool: 5285851; Big: 495); GC: 6
[1]    55309 abort

Should this behavior be kept, or show we try to keep the session alive at least without segfaulting it? If we choose the latter, we need to change the assertions in functions like jl_compute_fieldtypes to handleable errors.

@KristofferC
Copy link
Member

KristofferC commented May 22, 2024

#53754 is probably related.

@aviatesk
Copy link
Member Author

Yes, exactly, this is the same issue. Let's focus on that. Thanks for your help.

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

No branches or pull requests

2 participants