本文地址:https://www.cnblogs.com/LynnVon/p/13953888.html
版本:4.25.3 之前的版本是没有错误的,4.25.3修改了这部分代码
1.CreateSession节点,当电脑没有网络连接时,使用该节点,会Assertfail导致crash,主要是源码Engine/Runtime/Sockets/private/SocketSubsystem.cpp Line:404的方法
TSharedRef<FInternetAddr> ISocketSubsystem::GetLocalHostAddr(FOutputDevice& Out, bool& bCanBindAll) { TSharedRef<FInternetAddr> HostAddr = CreateInternetAddr(); bCanBindAll = false; if (!GetMultihomeAddress(HostAddr)) { bCanBindAll = true; TArray<TSharedPtr<FInternetAddr>> AdapterAddresses; if (!GetLocalAdapterAddresses(AdapterAddresses)) { Out.Logf(TEXT("Could not fetch the local adapter addresses")); HostAddr->SetAnyAddress(); } else {
HostAddr = AdapterAddresses[0]->Clone(); //有bug 会导致数组越界访问崩溃
}
} } return HostAddr; }
更具体的错误应该是355行的方法bool ISocketSubsystem::GetLocalAdapterAddresses(TArray<TSharedPtr<FInternetAddr>>& OutAddresses),不过我没有更具体的去看,我直接在上边assertfail的地方加了个判断
if (AdapterAddresses.Num()>0) { HostAddr = AdapterAddresses[0]->Clone(); }
Over!