Revert "[VM / IO] - Reland : Assert when an OSError exception is reported with no error"

This reverts commit dc8002cc42.

Reason for revert: crashes internally (b/227727791) and externally (dartbug.com/48721)

Original change's description:
> [VM / IO] - Reland : Assert when an OSError exception is reported with no error
>
> 1. Add a Fatal assert when an OSError is reported with no error code (0).
> This is to ensure we get a coredum pwhen this happens so we can analyze
> it. (Please see https://github.com/flutter/flutter/issues/90921 for more
> details)
>
> TEST=ci
>
> Change-Id: I7146ac69ef8b1833f28bed8a23f0c27a2ece4bbf
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239726
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=aam@google.com,asiva@google.com

Change-Id: Ic9302e7922b0ce2ea5ab81357804c3cd822a8052
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239664
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This commit is contained in:
Slava Egorov 2022-04-01 10:14:37 +00:00 committed by Commit Bot
parent 60857f8bc7
commit 4c0387461c
3 changed files with 6 additions and 26 deletions

View file

@ -680,9 +680,6 @@ Dart_Handle DartUtils::NewDartOSError(OSError* os_error) {
Dart_Handle type = GetDartType(kIOLibURL, "OSError");
ASSERT(!Dart_IsError(type));
Dart_Handle args[2];
if (os_error->code() == 0) {
FATAL("Fatal error OSError (code : 0) DartUtils::NewDartOSError");
}
args[0] = NewString(os_error->message());
args[1] = Dart_NewInteger(os_error->code());
return Dart_New(type, Dart_Null(), 2, args);

View file

@ -914,18 +914,7 @@ void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) {
Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
OSError os_error;
SocketBase::GetError(socket->fd(), &os_error);
if (os_error.code() != 0) {
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
} else {
Dart_SetReturnValue(args, Dart_Null());
}
}
void FUNCTION_NAME(Socket_Fatal)(Dart_NativeArguments args) {
Dart_Handle msg = Dart_GetNativeArgument(args, 0);
const char* msgStr =
(!Dart_IsNull(msg)) ? DartUtils::GetStringValue(msg) : nullptr;
FATAL("Fatal error in dart:io (socket): %s", msgStr);
Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
}
void FUNCTION_NAME(Socket_GetFD)(Dart_NativeArguments args) {

View file

@ -877,8 +877,8 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
// the SO_ERROR option at level SOL_SOCKET to determine whether
// connect() completed successfully (SO_ERROR is zero) or
// unsuccessfully.
final osError = socket.nativeGetError();
if (osError != null) {
final OSError osError = socket.nativeGetError();
if (osError.errorCode != 0) {
socket.close();
error ??= osError;
connectNext();
@ -1404,12 +1404,8 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
if (i == errorEvent) {
if (!isClosing) {
final osError = nativeGetError();
if (osError == null) {
_nativeFatal("Reporting error with OSError code of 0");
} else {
reportError(osError, null, osError.message);
}
final err = nativeGetError();
reportError(err, null, err.message);
}
} else if (!isClosed) {
// If the connection is closed right after it's accepted, there's a
@ -1692,7 +1688,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
@pragma("vm:external-name", "Socket_GetFD")
external int get fd;
@pragma("vm:external-name", "Socket_GetError")
external OSError? nativeGetError();
external OSError nativeGetError();
@pragma("vm:external-name", "Socket_GetOption")
external nativeGetOption(int option, int protocol);
@pragma("vm:external-name", "Socket_GetRawOption")
@ -1707,8 +1703,6 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
@pragma("vm:external-name", "Socket_LeaveMulticast")
external void nativeLeaveMulticast(
Uint8List addr, Uint8List? interfaceAddr, int interfaceIndex);
@pragma("vm:external-name", "Socket_Fatal")
external static void _nativeFatal(msg);
}
class _RawServerSocket extends Stream<RawSocket> implements RawServerSocket {