-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics
Description
Description
This is a regression in main toolchain snapshots not reproducible with previously released version of the compiler.
Reproduction
Check out this commit of WasmKit: swiftwasm/WasmKit@c4f9b3f
and build it using swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a with the following command:
swift test --traits WasmDebuggingSupport
Stack dump
SIL memory lifetime failure in @$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC: memory is not initialized, but should be
memory location: %9 = struct_element_addr %4 : $*Debugger, #Debugger.breakpoints // user: %13
at instruction: destroy_addr %71 : $*Dictionary<Int, UInt64> // id: %72
Abort: function reportError at MemoryLifetimeVerifier.cpp:268
in function:
// Debugger.init(module:store:imports:)
// Isolation: unspecified
sil [ossa] @$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC : $@convention(method) (@owned Module, @owned Store, @owned Imports, @thin Debugger.Type) -> (@owned Debugger, @error any Error) {
// %0 "module" // users: %30, %70, %54, %5
// %1 "store" // users: %39, %69, %53, %21, %18, %15, %6
// %2 "imports" // users: %30, %68, %52, %7
// %3 "$metatype"
bb0(%0 : @owned $Module, %1 : @owned $Store, %2 : @owned $Imports, %3 : $@thin Debugger.Type):
%4 = alloc_stack [lexical] [var_decl] $Debugger, var, name "self", type $Debugger // users: %50, %9, %45, %58, %71, %55, %73
debug_value %0, let, name "module", argno 1 // id: %5
debug_value %1, let, name "store", argno 2 // id: %6
debug_value %2, let, name "imports", argno 3 // id: %7
debug_value undef : $any Error, var, name "$error", argno 4 // id: %8
%9 = struct_element_addr %4, #Debugger.breakpoints // user: %13
%10 = metatype $@thin Dictionary<Int, UInt64>.Type // user: %12
// function_ref Dictionary.init()
%11 = function_ref @$sS2Dyxq_GycfC : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@thin Dictionary<τ_0_0, τ_0_1>.Type) -> @owned Dictionary<τ_0_0, τ_0_1> // user: %12
%12 = apply %11<Int, UInt64>(%10) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@thin Dictionary<τ_0_0, τ_0_1>.Type) -> @owned Dictionary<τ_0_0, τ_0_1> // user: %13
store %12 to [init] %9 // id: %13
%14 = metatype $@thin Instance.Type // user: %41
%15 = begin_borrow %1 // users: %38, %67, %16
%16 = ref_element_addr [immutable] %15, #Store.allocator // user: %17
%17 = load [copy] %16 // users: %37, %30, %66
%18 = begin_borrow %1 // users: %36, %65, %19
%19 = ref_element_addr [immutable] %18, #Store.engine // user: %20
%20 = load [copy] %19 // users: %35, %30, %64
%21 = begin_borrow %1 // users: %34, %63, %22
%22 = ref_element_addr %21, #Store.resourceLimiter // user: %23
%23 = begin_access [read] [dynamic] %22 // users: %26, %25
%24 = alloc_stack $any ResourceLimiter // users: %33, %32, %30, %62, %61, %25
copy_addr %23 to [init] %24 // id: %25
end_access %23 // id: %26
%27 = integer_literal $Builtin.Int1, -1 // user: %28
%28 = struct $Bool (%27) // user: %30
// function_ref StoreAllocator.allocate(module:engine:resourceLimiter:imports:isDebuggable:)
%29 = function_ref @$s7WasmKit14StoreAllocatorC8allocate6module6engine15resourceLimiter7imports12isDebuggableAA12EntityHandleVyAA08InstanceM0VGAA6ModuleV_AA6EngineCAA08ResourceI0_pAA7ImportsVSbtKF : $@convention(method) (@guaranteed Module, @guaranteed Engine, @in_guaranteed any ResourceLimiter, @guaranteed Imports, Bool,
@guaranteed StoreAllocator) -> (EntityHandle<InstanceEntity>, @error any Error) // user: %30
try_apply %29(%0, %20, %24, %2, %28, %17) : $@convention(method) (@guaranteed Module, @guaranteed Engine, @in_guaranteed any ResourceLimiter, @guaranteed Imports, Bool, @guaranteed StoreAllocator) -> (EntityHandle<InstanceEntity>, @error any Error), normal bb1, error bb2 // id: %30
// %31 // user: %41
bb1(%31 : $EntityHandle<InstanceEntity>): // Preds: bb0
destroy_addr %24 // id: %32
dealloc_stack %24 // id: %33
end_borrow %21 // id: %34
destroy_value %20 // id: %35
end_borrow %18 // id: %36
destroy_value %17 // id: %37
end_borrow %15 // id: %38
%39 = copy_value %1 // user: %41
// function_ref Instance.init(handle:store:)
%40 = function_ref @$s7WasmKit8InstanceV6handle5storeAcA12EntityHandleVyAA0cF0VG_AA5StoreCtcfC : $@convention(method) (EntityHandle<InstanceEntity>, @owned Store, @thin Instance.Type) -> @owned Instance // user: %41
%41 = apply %40(%31, %39, %14) : $@convention(method) (EntityHandle<InstanceEntity>, @owned Store, @thin Instance.Type) -> @owned Instance // user: %42
%42 = move_value [lexical] [var_decl] %41 // users: %44, %49, %43
debug_value %42, let, name "instance" // id: %43
%44 = copy_value %42 // user: %47
%45 = begin_access [modify] [static] %4 // users: %46, %48
%46 = struct_element_addr %45, #Debugger.instance // user: %47
store %44 to [init] %46 // id: %47
end_access %45 // id: %48
destroy_value %42 // id: %49
%50 = load [take] %4 // user: %56
debug_value undef : $*Debugger, var, name "self" // id: %51
destroy_value %2 // id: %52
destroy_value %1 // id: %53
destroy_value %0 // id: %54
dealloc_stack %4 // id: %55
return %50 // id: %56
// %57 // user: %74
bb2(%57 : @owned $any Error): // Preds: bb0
%58 = struct_element_addr %4, #Debugger.breakpoints // user: %59
destroy_addr %58 // id: %59
debug_value undef : $*Debugger, var, name "self" // id: %60
destroy_addr %24 // id: %61
dealloc_stack %24 // id: %62
end_borrow %21 // id: %63
destroy_value %20 // id: %64
end_borrow %18 // id: %65
destroy_value %17 // id: %66
end_borrow %15 // id: %67
destroy_value %2 // id: %68
destroy_value %1 // id: %69
destroy_value %0 // id: %70
%71 = struct_element_addr %4, #Debugger.breakpoints // user: %72
destroy_addr %71 // id: %72
dealloc_stack %4 // id: %73
throw %57 // id: %74
} // end sil function '$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC'
[...]
1. Apple Swift version 6.3-dev (LLVM 3a427639f2a06cf, Swift 5417f00a58578de)
2. Compiling with the current language version
3. While verifying SIL function "@$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC".
for 'init(module:store:imports:)' (at /Users/mdesiatov/Documents/externalOSS/swiftwasm/WasmKit/Sources/WasmKit/Execution/Debugger.swift:27:17)
4. Abort: function reportError at MemoryLifetimeVerifier.cpp:268
| in function:
| // Debugger.init(module:store:imports:)
| // Isolation: unspecified
| sil [ossa] @$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC : $@convention(method) (@owned Module, @owned Store, @owned Imports, @thin Debugger.Type) -> (@owned Debugger, @error any Error) {
| // %0 "module" // users: %30, %70, %54, %5
| // %1 "store" // users: %39, %69, %53, %21, %18, %15, %6
| // %2 "imports" // users: %30, %68, %52, %7
| // %3 "$metatype"
| bb0(%0 : @owned $Module, %1 : @owned $Store, %2 : @owned $Imports, %3 : $@thin Debugger.Type):
| %4 = alloc_stack [lexical] [var_decl] $Debugger, var, name "self", type $Debugger // users: %50, %9, %45, %58, %71, %55, %73
| debug_value %0, let, name "module", argno 1 // id: %5
| debug_value %1, let, name "store", argno 2 // id: %6
| debug_value %2, let, name "imports", argno 3 // id: %7
| debug_value undef : $any Error, var, name "$error", argno 4 // id: %8
| %9 = struct_element_addr %4, #Debugger.breakpoints // user: %13
| %10 = metatype $@thin Dictionary<Int, UInt64>.Type // user: %12
| // function_ref Dictionary.init()
| %11 = function_ref @$sS2Dyxq_GycfC : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@thin Dictionary<τ_0_0, τ_0_1>.Type) -> @owned Dictionary<τ_0_0, τ_0_1> // user: %12
| %12 = apply %11<Int, UInt64>(%10) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@thin Dictionary<τ_0_0, τ_0_1>.Type) -> @owned Dictionary<τ_0_0, τ_0_1> // user: %13
| store %12 to [init] %9 // id: %13
| %14 = metatype $@thin Instance.Type // user: %41
| %15 = begin_borrow %1 // users: %38, %67, %16
| %16 = ref_element_addr [immutable] %15, #Store.allocator // user: %17
| %17 = load [copy] %16 // users: %37, %30, %66
| %18 = begin_borrow %1 // users: %36, %65, %19
| %19 = ref_element_addr [immutable] %18, #Store.engine // user: %20
| %20 = load [copy] %19 // users: %35, %30, %64
| %21 = begin_borrow %1 // users: %34, %63, %22
| %22 = ref_element_addr %21, #Store.resourceLimiter // user: %23
| %23 = begin_access [read] [dynamic] %22 // users: %26, %25
| %24 = alloc_stack $any ResourceLimiter // users: %33, %32, %30, %62, %61, %25
| copy_addr %23 to [init] %24 // id: %25
| end_access %23 // id: %26
| %27 = integer_literal $Builtin.Int1, -1 // user: %28
| %28 = struct $Bool (%27) // user: %30
| // function_ref StoreAllocator.allocate(module:engine:resourceLimiter:imports:isDebuggable:)
| %29 = function_ref @$s7WasmKit14StoreAllocatorC8allocate6module6engine15resourceLimiter7imports12isDebuggableAA12EntityHandleVyAA08InstanceM0VGAA6ModuleV_AA6EngineCAA08ResourceI0_pAA7ImportsVSbtKF : $@convention(method) (@guaranteed Module, @guaranteed Engine, @in_guaranteed any ResourceLimiter, @guaranteed Imports
, Bool, @guaranteed StoreAllocator) -> (EntityHandle<InstanceEntity>, @error any Error) // user: %30
| try_apply %29(%0, %20, %24, %2, %28, %17) : $@convention(method) (@guaranteed Module, @guaranteed Engine, @in_guaranteed any ResourceLimiter, @guaranteed Imports, Bool, @guaranteed StoreAllocator) -> (EntityHandle<InstanceEntity>, @error any Error), normal bb1, error bb2 // id: %30
|
| // %31 // user: %41
| bb1(%31 : $EntityHandle<InstanceEntity>): // Preds: bb0
| destroy_addr %24 // id: %32
| dealloc_stack %24 // id: %33
| end_borrow %21 // id: %34
| destroy_value %20 // id: %35
| end_borrow %18 // id: %36
| destroy_value %17 // id: %37
| end_borrow %15 // id: %38
| %39 = copy_value %1 // user: %41
| // function_ref Instance.init(handle:store:)
| %40 = function_ref @$s7WasmKit8InstanceV6handle5storeAcA12EntityHandleVyAA0cF0VG_AA5StoreCtcfC : $@convention(method) (EntityHandle<InstanceEntity>, @owned Store, @thin Instance.Type) -> @owned Instance // user: %41
| %41 = apply %40(%31, %39, %14) : $@convention(method) (EntityHandle<InstanceEntity>, @owned Store, @thin Instance.Type) -> @owned Instance // user: %42
| %42 = move_value [lexical] [var_decl] %41 // users: %44, %49, %43
| debug_value %42, let, name "instance" // id: %43
| %44 = copy_value %42 // user: %47
| %45 = begin_access [modify] [static] %4 // users: %46, %48
| %46 = struct_element_addr %45, #Debugger.instance // user: %47
| store %44 to [init] %46 // id: %47
| end_access %45 // id: %48
| destroy_value %42 // id: %49
| %50 = load [take] %4 // user: %56
| debug_value undef : $*Debugger, var, name "self" // id: %51
| destroy_value %2 // id: %52
| destroy_value %1 // id: %53
| destroy_value %0 // id: %54
| dealloc_stack %4 // id: %55
| return %50 // id: %56
|
| // %57 // user: %74
| bb2(%57 : @owned $any Error): // Preds: bb0
| %58 = struct_element_addr %4, #Debugger.breakpoints // user: %59
| destroy_addr %58 // id: %59
| debug_value undef : $*Debugger, var, name "self" // id: %60
| destroy_addr %24 // id: %61
| dealloc_stack %24 // id: %62
| end_borrow %21 // id: %63
| destroy_value %20 // id: %64
| end_borrow %18 // id: %65
| destroy_value %17 // id: %66
| end_borrow %15 // id: %67
| destroy_value %2 // id: %68
| destroy_value %1 // id: %69
| destroy_value %0 // id: %70
| %71 = struct_element_addr %4, #Debugger.breakpoints // user: %72
| destroy_addr %71 // id: %72
| dealloc_stack %4 // id: %73
| throw %57 // id: %74
| } // end sil function '$s7WasmKit8DebuggerV6module5store7importsAcA6ModuleV_AA5StoreCAA7ImportsVtKcfC'
Expected behavior
Code compiles as with previous versions of Swift (builds fine in 6.2.0 release)
Environment
Reproducible on both macOS and Linux.
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareownershipFeature: Ownership modifiers and semanticsFeature: Ownership modifiers and semantics