UEFN 42.20: Python cleanup crashes and confirmed native callable size mismatch

Summary

UEFN crashed twice during editor automation with Python Editor Scripting and UEFN MCP Toolsets enabled. Both crash traces point to Python’s weak-reference cleanup.

A separate read-only check found a concrete defect in Unreal’s native Python callable type: it declares 40 bytes of storage, although its inherited base requires 56 bytes. Its weak-reference pointer is positioned outside the declared storage.

The layout defect is confirmed. Its connection to the crashes is strongly supported, but the exact object responsible for either crash has not been identified.

Epic Launcher Verify completed successfully without changing the affected build or sampled components. Please identify a supported UEFN correction; a patch for a separately compiled Unreal Engine build cannot be applied directly to this installation.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Stability

Steps to Reproduce

This is a diagnostic for the measured layout defect, not a guaranteed crash reproducer.

  1. Use Win64 UEFN 42.20, CL58011042, with Python Editor Scripting enabled. The affected workflows also had UEFN MCP Toolsets enabled.
  2. In the editor Python environment, run this descriptor-only check:
import unreal

for name, fn in (
    ("SystemLibrary.get_engine_version", unreal.SystemLibrary.get_engine_version),
    ("EditorAssetLibrary.does_asset_exist", unreal.EditorAssetLibrary.does_asset_exist),
):
    print(name)
    for cls in type(fn).__mro__:
        print(
            cls.__name__,
            cls.__basicsize__,
            cls.__itemsize__,
            cls.__weakrefoffset__,
        )
  1. Compare each closure type’s declared size and weak-reference offset with its builtin base. The observed values are listed below.

The check completed successfully. It calls neither sampled Unreal function, loads no assets, scans no world, creates no weak references, and neither forces collection nor changes GC settings. Ordinary Python allocations can still trigger automatic collection.

The two actual crashes occurred in separate editor automation workflows: a collision-metadata inspection and a read-only actor preflight. The second failed during script compilation, before the actor queries. A deterministic minimal crash reproducer has not been established.

Expected Result

The native callable should reserve enough memory for its inherited fields, including weak-reference storage. Editor Python/MCP operations should complete without invalid memory reads during Python cleanup.

Observed Result

Both unreal.SystemLibrary.get_engine_version and unreal.EditorAssetLibrary.does_asset_exist exposed the following layout:

Type Basic size Item size Weak-reference offset
builtin_function_or_method_with_closure 40 bytes 0 40 bytes
Its builtin_function_or_method base 56 bytes 0 40 bytes

On Win64, a pointer at offset 40 occupies bytes 40–47. Those bytes lie outside the closure type’s declared 40-byte basic allocation. The closure type flags were 20736.

For comparison, ordinary len, unreal.load_asset, and unreal.find_asset reported the normal builtin type: basic size 56 and weak-reference offset 40.

Both recorded crashes resolve to weak-reference garbage collection. The second occurred during AST conversion/script compilation, so the last requested scene property is not established as the cause. The exact offending heap object and first corrupting operation remain unknown.

Platform(s)

Windows / Win64
UEFN: 42.20, CL58011042
Engine: 6.0.0-58011042+++Fortnite+Release-42.20
Embedded Python: CPython 3.11.8

Additional Notes

Crash evidence

Both crashes occurred during editor automation, before editor shutdown.

Crash A — invalid read at 0x000000000000000a:

python311+0xD8FE1  clear_weakref+0x1D
python311+0xD8B16  handle_weakrefs+0x12E
python311+0x0CB2A  gc_collect_main+0x13A
python311+0x0C795  gc_collect_with_callback+0x45
python311+0x0C725  gc_collect_generations+0x49

Crash B — invalid read at 0x00007465736c6f18:

python311+0xD8B06  handle_weakrefs+0x11E
python311+0x0CB2A  gc_collect_main+0x13A
python311+0x0C795  gc_collect_with_callback+0x45
python311+0x0C725  gc_collect_generations+0x49
python311+0x6798A  _PyObject_GC_Link
python311+0x675A4  PyType_GenericAlloc

Lower frames in Crash B include ast2obj_expr, ast2obj_stmt, ast2obj_list, and Py_CompileStringObject.

Symbol verification: the traces were resolved offline using the official Python 3.11.8 AMD64 PDB. Its GUID exactly matches the dump module: 0a53b3b3-c6f6-4f54-b771-ad15efda80d8, age 1.

  • Both handle_weakrefs fault sites map to Modules/gcmodule.c:813.
  • clear_weakref maps to Objects/weakrefobject.c:60.

Related report

A September 15 UE 5.8.3 source-build report describes the same FPyCFunctionWithClosureObject / PyMethodWithClosure size mismatch and an author-tested source correction. This does not establish that a supported UEFN fix exists.

UE-168225 concerns an older exit-time issue; it is not being claimed as this defect’s resolution.

Installation verification

Epic Games Launcher’s UEFN Verify operation completed successfully:

  • Result: AlertCode=[ok]; IncompleteInstall=0.
  • Installed build remained 42.20 / CL58011042.
  • All five sampled binaries were byte-for-byte unchanged, including the Engine DLL containing PythonScriptPlugin and both installed Python DLL copies.
  • No fresh native layout probe was run after verification.

The integrity operation therefore did not apply a changed compiled binding. No binary patch, runtime type-memory modification, GC suppression, or custom engine-source patch was applied.

Requested resolution

Please confirm whether this native callable allocation/lifetime defect affects this UEFN build and identify an applicable supported UEFN update or repair. A generic Unreal Engine source patch cannot be deployed directly to the installed UEFN application.

Raw dumps and unsanitized logs are not attached. Reviewed, sanitized diagnostic excerpts can be provided through an authorized support channel if needed.

Hi, thanks for reporting this to us.

Please could you provide us with your logs

How to get logs:

Feel free to privately message me the logs

Thanks for the report. This size/layout mismatch has been corrected for 43.00.

FORT-1161329’s status has changed to ‘Ready for QA’. A member of the QA department is investigating the issue.

Thanks Jamie and Rhyan! I sent the sanitized logs from all three crash sessions to Rhyan by private message earlier today, in case they’re still useful for QA. Great news that the layout fix is in 43.00. We’ll re-test our editor automation when it ships.