Coder Social home page Coder Social logo

dtls2's People

Contributors

jkrhb avatar lukaslihotzki avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

dtls2's Issues

Network is unreachable treated as DTLSException ?

Back again :-)

Having trouble to catch Network is unreachable exception.

As I can see _abortHandshake(DtlsException("Network is unreachable")); it is treated as DtlsException and I am not managing to catch it.

Would it not be preferable to throw it as a SocketException like thrown by the underlying system?

Fatal exception with no trace

Digging is always good :-)

Was trying to understand the handshake and manipulated using `openssl s_client. Crashed my usecase server and the minimal server used yesterday too. Unfortunately no trace is available. Note that that if the server runs on my linux machine, there is no crash. But on my cloud server one can see the following trace. So I suspect different libssl version.
ret = is a print inside _maintainOutgoing() in dtls_server.dart

If you have an idea will let you go for it otherwise will try to narrow it down ...

Oh yes her the crash trigger: openssl s_client -dtls -psk_identity "" -psk "" -connect XX.XX.XX.XX:PPPP

Server listening on port 8888

ret = 60
ret = -1
New connection

===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=0x110

DtlsException("Sending failed: Not connected!"). Is this exception correctly labeled ?

I was thinking if this exception is correctly labeled.

Actually the connection is closed so we are no more in a dtls context so asking my self if it belongs there.

The openssl s_client behaves returning read:errno=111. Same error is thrown when trying to connect on a server that is down.
https://github.com/openssl/openssl/blob/1e398bec538978b9957e69bf9e12b3c626290bea/apps/s_client.c#L3207-L3213

what is a socket error.

@override
int send(List<int> data) {
if (!connected) {
throw DtlsException("Sending failed: Not connected!");
}
return _dtlsClient._send(this, data);
}

Typo at lib.dart line 68 ?

should be:
return _loadLibrary(libNames, 'libcrypto');
and not
return _loadLibrary(libNames, 'libssl');

Loading of libssl.so and libcrypto.so fails

Hello there,

First of all thank you for your nice contribution !!!

Was struggling with importing the libraries for and android project in Android Studio but managed to get it work after modifying your code. Strangely your code works for a dart Linux application without modification. Maybe you have an idea why.

For android I had to swap lines in dtls_client.dart this way.
DtlsClient(
this._socket, {
DynamicLibrary? libCrypto, <--- swapped with next
DynamicLibrary? libSsl, <--- swapped
}) : _libCrypto = _loadOpenSsl(libCrypto) ?? lib.libCrypto, <--- swapped with next
_libSsl = _loadOpenSsl(libSsl) ?? lib.libSsl { <--- swapped
_startListening();
}

Catch the unhandled Exception Network is unreachable

This exception occurs when during an open connection the adapter is turned off. Not really annoying on Desktops but on mobiles where we often turn WIFI on and off a must. I realized that this exception cannot be catch for what ever isolates reasons but a check of number of returned written bytes from _socket.send can help.

Unhandled exception:
SocketException: Send failed (OS Error: Network is unreachable, errno = 101), address = ::, port = 8888
#0 _NativeSocket.send (dart:io-patch/socket_patch.dart:1224:34)
#1 _RawDatagramSocket.send (dart:io-patch/socket_patch.dart:2491:15)
#2 _DtlsServerConnection._maintainOutgoing (package:dtls2/src/dtls_server.dart:315:27)
#3 _DtlsServerConnection._maintainState (package:dtls2/src/dtls_server.dart:282:9)
#4 _DtlsServerConnection.close (package:dtls2/src/dtls_server.dart:350:7)
#5 Server.connect.. (package:ptt_server/server_socket.dart:333:24)
#6 ConnectionTimer.start. (package:ptt_server/server_socket.dart:268:16)
#7 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
#8 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#9 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#10 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

cant open ffi

on this, late final _SSL_connectPtr =
_lookup<ffi.NativeFunction<ffi.Int Function(ffi.Pointer)>>(
'SSL_connect');

      I lost connection to device

DTLS EXCEPTION "Handshake timed out" vs "DTLS Handshake has failed"

Back again :-)

Facing 2 situations where the exception should be the same for both, but is not:

  • Situation 1 Identity is wrong, PSK is correct results is DtlsHandshakeException: DTLS Handshake has failed what is fine
  • Situation 2 Identity is correct, PSK is wrong results is DtlsTimeoutException after 0:00:10.000000: Handshake timed out what is not OK. Should be exception as in 1

Actually the exception should be DtlsHandshakeException: Wrong identity and PSK

Easy to fix ?

Unable to catch DtlsException: DTLS Handshake has failed.

Hello,
here an other point where I am struggling. Unable to catch DTLS Handshake has failed in this situation.

Client have a working dtls connection with the server.
Server wants to ban the client. Client's presharedkey is then removed from the server.
Client's tries to connect.

Result:

E/flutter (17787): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DtlsException: DTLS Handshake has failed. E/flutter (17787): #0 _DtlsClientConnection._performShutdown (package:dtls2/src/dtls_client.dart:496:7) E/flutter (17787): #1 _DtlsClientConnection._connectToPeer.<anonymous closure> (package:dtls2/src/dtls_client.dart:518:15) E/flutter (17787): #2 _DtlsClientConnection._handleError (package:dtls2/src/dtls_client.dart:482:21) E/flutter (17787): #3 _DtlsClientConnection._connectToPeer (package:dtls2/src/dtls_client.dart:516:7) E/flutter (17787): #4 _DtlsClientConnection._maintainState (package:dtls2/src/dtls_client.dart:602:7) E/flutter (17787): #5 _DtlsClientConnection._incoming (package:dtls2/src/dtls_client.dart:563:5) E/flutter (17787): #6 DtlsClient._startListening.<anonymous closure> (package:dtls2/src/dtls_client.dart:87:26)

Would like to be able to catch this exeption to redirect the client to the signing page.

Thank you for your support.

Crash when calling _maintainOutgoing --> _libSsl.SSL_ctrl

Hello Jan,

here a crash trace. Could you check that ?

Thanks.

Tarik

===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=0x1f0
version=2.19.3 (stable) (Unknown timestamp) on "linux_x64"
pid=3214466, thread=3214944, isolate_group=main(0x5626b38ac000), isolate=main(0x5626b394d000)
os=linux, arch=x64, comp=no, sim=no
isolate_instructions=5626b1d74c80, vm_instructions=5626b1d74c80
  pc 0x00007fe557d815b6 fp 0x00007fe5a1ffce18 /lib/x86_64-linux-gnu/libssl.so+0x255b6
  pc 0x00007fe557e2fe0c fp 0x00007fe5a1ffce60 Unknown symbol
  pc 0x00007fe557e2f989 fp 0x00007fe5a1ffcee0 Unknown symbol
  pc 0x00007fe557e2e1c0 fp 0x00007fe5a1ffcf50 Unknown symbol
  pc 0x00007fe557e2bcae fp 0x00007fe5a1ffcfa0 Unknown symbol
  pc 0x00007fe557e2b237 fp 0x00007fe5a1ffcfd8 Unknown symbol
  pc 0x00007fe557e23eaf fp 0x00007fe5a1ffd050 Unknown symbol
  pc 0x00007fe557e22e63 fp 0x00007fe5a1ffd0a8 Unknown symbol
  pc 0x00007fe557e22c51 fp 0x00007fe5a1ffd128 Unknown symbol
  pc 0x00007fe557e22714 fp 0x00007fe5a1ffd180 Unknown symbol
  pc 0x00007fe557e2204d fp 0x00007fe5a1ffd1c0 Unknown symbol
  pc 0x00007fe557e21d5c fp 0x00007fe5a1ffd200 Unknown symbol
  pc 0x00007fe557e21ab2 fp 0x00007fe5a1ffd240 Unknown symbol
  pc 0x00007fe557e21763 fp 0x00007fe5a1ffd280 Unknown symbol
  pc 0x00007fe557e23a5d fp 0x00007fe5a1ffd2c0 Unknown symbol
  pc 0x00007fe557e1ef52 fp 0x00007fe5a1ffd318 Unknown symbol
  pc 0x00007fe59ec651df fp 0x00007fe5a1ffd360 Unknown symbol
  pc 0x00007fe59ec64e2e fp 0x00007fe5a1ffd3a0 Unknown symbol
  pc 0x00007fe59ec64d59 fp 0x00007fe5a1ffd3c8 Unknown symbol
  pc 0x00007fe59ec64c7e fp 0x00007fe5a1ffd408 Unknown symbol
  pc 0x00007fe59ec24208 fp 0x00007fe5a1ffd448 Unknown symbol
  pc 0x00007fe5a608300c fp 0x00007fe5a1ffd4c0 Unknown symbol
  pc 0x00005626b1eedf79 fp 0x00007fe5a1ffd560 dart::DartEntry::InvokeCode(dart::Code const&, unsigned long, dart::Array const&, dart::Array const&, dart::Thread*)+0x139
  pc 0x00005626b1eeddf5 fp 0x00007fe5a1ffd5c0 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)+0x145
  pc 0x00005626b1ef0154 fp 0x00007fe5a1ffd600 dart::DartLibraryCalls::HandleMessage(long, dart::Instance const&)+0x144
  pc 0x00005626b1f13738 fp 0x00007fe5a1ffdb90 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message>>)+0x348
  pc 0x00005626b1f3bfca fp 0x00007fe5a1ffdc10 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x15a
  pc 0x00005626b1f3c6eb fp 0x00007fe5a1ffdc60 dart::MessageHandler::TaskCallback()+0x1db
  pc 0x00005626b206791b fp 0x00007fe5a1ffdce0 dart::ThreadPool::WorkerLoop(dart::ThreadPool::Worker*)+0x13b
  pc 0x00005626b2067d68 fp 0x00007fe5a1ffdd10 dart::ThreadPool::Worker::Main(unsigned long)+0x78
  pc 0x00005626b1fd91d6 fp 0x00007fe5a1ffddd0 /usr/lib/dart/bin/dart+0x22281d6
-- End of DumpStackTrace
  pc 0x0000000000000000 fp 0x00007fe5a1ffce18 sp 0x0000000000000000 Cannot find code object
  pc 0x00007fe557e2fe0c fp 0x00007fe5a1ffce60 sp 0x00007fe5a1ffce28 [Optimized] FfiTrampoline__SSL_ctrl
  pc 0x00007fe557e2f989 fp 0x00007fe5a1ffcee0 sp 0x00007fe5a1ffce70 [Unoptimized] OpenSsl.SSL_ctrl
  pc 0x00007fe557e2e1c0 fp 0x00007fe5a1ffcf50 sp 0x00007fe5a1ffcef0 [Unoptimized] _DtlsServerConnection@106018504._maintainOutgoing@106018504
  pc 0x00007fe557e2bcae fp 0x00007fe5a1ffcfa0 sp 0x00007fe5a1ffcf60 [Unoptimized] _DtlsServerConnection@106018504._maintainState@106018504
  pc 0x00007fe557e2b237 fp 0x00007fe5a1ffcfd8 sp 0x00007fe5a1ffcfb0 [Unoptimized] _DtlsServerConnection@106018504._incoming@106018504
  pc 0x00007fe557e23eaf fp 0x00007fe5a1ffd050 sp 0x00007fe5a1ffcfe8 [Unoptimized] DtlsServer._handleSocketRead@106018504
  pc 0x00007fe557e22e63 fp 0x00007fe5a1ffd0a8 sp 0x00007fe5a1ffd060 [Unoptimized] DtlsServer._startListening@106018504.<anonymous closure>
  pc 0x00007fe557e22c51 fp 0x00007fe5a1ffd128 sp 0x00007fe5a1ffd0b8 [Unoptimized] [email protected]
  pc 0x00007fe557e22714 fp 0x00007fe5a1ffd180 sp 0x00007fe5a1ffd138 [Unoptimized] _BufferingStreamSubscription@4048458._sendData@4048458
  pc 0x00007fe557e2204d fp 0x00007fe5a1ffd1c0 sp 0x00007fe5a1ffd190 [Unoptimized] _BufferingStreamSubscription@4048458._add@4048458
  pc 0x00007fe557e21d5c fp 0x00007fe5a1ffd200 sp 0x00007fe5a1ffd1d0 [Unoptimized] _SyncStreamController@4048458._sendData@4048458
  pc 0x00007fe557e21ab2 fp 0x00007fe5a1ffd240 sp 0x00007fe5a1ffd210 [Unoptimized] _StreamController@4048458._add@4048458
  pc 0x00007fe557e21763 fp 0x00007fe5a1ffd280 sp 0x00007fe5a1ffd250 [Unoptimized] [email protected]
  pc 0x00007fe557e23a5d fp 0x00007fe5a1ffd2c0 sp 0x00007fe5a1ffd290 [Unoptimized] new _RawDatagramSocket@14069316..<anonymous closure>
  pc 0x00007fe557e1ef52 fp 0x00007fe5a1ffd318 sp 0x00007fe5a1ffd2d0 [Unoptimized] [email protected]
  pc 0x00007fe59ec651df fp 0x00007fe5a1ffd360 sp 0x00007fe5a1ffd328 [Unoptimized] _microtaskLoop@4048458
  pc 0x00007fe59ec64e2e fp 0x00007fe5a1ffd3a0 sp 0x00007fe5a1ffd370 [Unoptimized] _startMicrotaskLoop@4048458
  pc 0x00007fe59ec64d59 fp 0x00007fe5a1ffd3c8 sp 0x00007fe5a1ffd3b0 [Unoptimized] _startMicrotaskLoop@4048458
  pc 0x00007fe59ec64c7e fp 0x00007fe5a1ffd408 sp 0x00007fe5a1ffd3d8 [Unoptimized] _runPendingImmediateCallback@1026248
  pc 0x00007fe59ec24208 fp 0x00007fe5a1ffd448 sp 0x00007fe5a1ffd418 [Unoptimized] _RawReceivePort@1026248._handleMessage@1026248
  pc 0x00007fe5a608300c fp 0x00007fe5a1ffd4c0 sp 0x00007fe5a1ffd458 [Stub] InvokeDartCode

Crash on server side and then client side when psk is null

Hello there,

I am back with one more bug :-)

Experiencing a crash on the server side when the PSK is null for the connecting client.
Unhandled exception: DtlsException: error:1419E044:SSL routines:tls_process_cke_psk_preamble:internal error

At the same time the client crashes with:

Cause: null pointer dereference
    r0  00000000  r1  00000049  r2  00000000  r3  7d0eb340
    r4  7d0eb340  r5  7e806c00  r6  7d608041  r7  75830180
    r8  5a5bbc9c  r9  00000005  r10 7582fe00  r11 682fba80
    ip  5a5a90c0  sp  682fba68  lr  7d5852e4  pc  5a5a9110
backtrace:
      #00 pc 00017110  /data/app/~~JnsSwGDasSwrdFQa0sEWUw==/com.ptt.ptt_client-l6OQ4oTeid1oEwTl35MROg==/base.apk!libssl.so (dtls1_ctrl+80)

Will try to narrow it down if you don't have a clue.

Exception - Failed to lookup symbol 'DTLS_client_method': dlsym(RTLD_DEFAULT, DTLS_client_method): symbol not found

Exception generate when attempting to connect:

    final bindAdress = InternetAddress.anyIPv4;
    final peerAddress = InternetAddress(meterIpAddress);
    const peerPort = 8081;
    const _ciphers = 'ECDHE-ECDSA-AES128-CCM8';
    const _identity = "MEC";

    const _preSharedKey = "secretPSK";

    ByteData data = await rootBundle.load('assets/certs/certificate.pem');
    List<Uint8List> cert = [data.buffer.asUint8List()];
  
    final context = DtlsClientContext(
      withTrustedRoots: true,
      rootCertificates: cert,
      ciphers: _ciphers,
      pskCredentialsCallback: (identityHint) {
        XeDebugPrint.success(msg: 'identityHint: $identityHint');
        return PskCredentials(
          identity: Uint8List.fromList(utf8.encode(_identity)),
          preSharedKey: Uint8List.fromList(utf8.encode(_preSharedKey)),
        );
      },
    );

    final dtlsClient = await DtlsClient.bind(bindAdress, 0);
    final DtlsConnection connection;

    try {
      connection = await dtlsClient.connect(peerAddress, peerPort, context);
    } on Exception {
      await dtlsClient.close();
      rethrow;
    }

Add new library name to library discovery

Hello there !!!

Here a new input for your fantastic plugin.

For the cases "else" please add:

  • in _loadLibSsl: libNames = const ["libssl.so", "libssl.so.3"];
  • in _loadLibCrypto: libNames = const ["libcrypto.so", "libcrypto.so.3"];

Tank you!

Crash at client after successful handshake

Hello Jan

Here a new issue.

After a successful handshake and regular exchange of data between client and server, the client crashes with this message in the console:

`F/libc ( 4545): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd3e7ef20 in tid 27907 (2.ui), pid 4545 (.ptt.ptt_client)


Build fingerprint: 'samsung/jfltexx/jflte:5.0.1/LRX22C/I9505XXUHQK1:user/release-keys'
Revision: '0'
ABI: 'arm'
Timestamp: 2023-03-14 21:49:29.752080152+0000
Process uptime: 101s
Cmdline: com.ptt.ptt_client
pid: 4545, tid: 27907, name: 2.ui >>> com.ptt.ptt_client <<<
uid: 10128
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd3e7ef20
r0 b3e7ef00 r1 aef54220 r2 d3e7eefc r3 07ffffff
r4 80000000 r5 ffffffff r6 b3e00540 r7 b3e01e50
r8 b3e00380 r9 00000002 r10 b4224308 r11 b3e01e90
ip aef5422c sp 7c8fb760 lr 0000001f pc aef670a8
backtrace:
#00 pc 000370a8 /apex/com.android.runtime/lib/bionic/libc.so (arena_slab_reg_alloc+104) (BuildId: 44204e0c53d8b940de9ce87036b16471)
#1 pc 00037665 /apex/com.android.runtime/lib/bionic/libc.so (je_arena_malloc_hard+376) (BuildId: 44204e0c53d8b940de9ce87036b16471)
#2 pc 000309c1 /apex/com.android.runtime/lib/bionic/libc.so (je_malloc+1040) (BuildId: 44204e0c53d8b940de9ce87036b16471)
#3 pc 0002c9a7 /apex/com.android.runtime/lib/bionic/libc.so (malloc+18) (BuildId: 44204e0c53d8b940de9ce87036b16471)
#4 pc 0017b290 /data/app/~~h34K_ao9DgsUqVurL_NozQ==/com.ptt.ptt_client-YGK0p71IU5wqaxxrSpQMwA==/base.apk!libcrypto.so (CRYPTO_zalloc+96)`

This one happened after 1 minute and 30 seconds. But could get sometimes 4 hours without problem.

Will try to give you more input for this crash later ...

Unhandled Exception: DtlsException: DTLS Handshake has failed.

Bom dia again :-)

Not able to catch DtlsException: DTLS Handshake exception. Here the piece of code in dtls_client.dart

void _performShutdown(Exception exception) {
   final wasInHandshake = inHandshake;
   close();

   if (wasInHandshake) {
     _connectCompleter.completeError(exception);
   } else {
     throw exception;
   }
 }

In fact wasInHandshake in false but event in this situation it should completeError the exception to be able to catch it upwards

Make it possible to set the OpenSSL security level

In the context of #97, I noticed that the cipher suite PSK-AES128-CCM8 which is the minimum requirement for CoAPS according to RFC 7252, is not usable with OpenSSL 3.2 by default anymore. That is because the cipher suite only provides 128 bits of security, which now requires a security level of 0 (i.e., "Everything is permitted").

To deal with this, there should be a way to let users configure the security level. A helpful resource can be found here: https://www.openssl.org/docs/man3.2/man3/SSL_CTX_set_security_level.html

Fatal error when trying to connect without nework adapter connected

Experiencing this when try to connect having my network adapter disconnected. I don't know if it was present in the past or if it due to your last commit. I f you need more details, let me know ...

Cause: null pointer dereference
    x0  0000007b8c2b6410  x1  0000000000000049  x2  0000000000000000  x3  0000007c0c6073f0
    x4  0000007968f0b648  x5  00000078063479f9  x6  0000007b8c2b6410  x7  0000000000000049
    x8  0000000000000000  x9  0000007968f62080  x10 0000007968f1b6f8  x11 0000000000000005
    x12 0000000000000001  x13 00000b20c984e9f9  x14 001e769974747fa0  x15 00000079f0364490
    x16 0000000000000000  x17 0000007b5c276c78  x18 00000079ee708000  x19 0000007c0c6073f0
    x20 0000007b8c2b6410  x21 00000079f0364490  x22 0000007800008081  x23 0000000000000000
    x24 0000007800008081  x25 00000079f028b000  x26 0000007b5c276520  x27 000000780d938fb0
    x28 0000000800000078  x29 00000079f0364480
    lr  0000007976286f28  sp  00000079f0364460  pc  0000007968f0b69c  pst 0000000060000000
backtrace:
      #00 pc 000000000002469c  /data/app/~~6QWUhZlMjHtotE41QoK9oQ==/com.ptt.ptt_client-UlPTR7RuWFiZAodLD5KrJg==/base.apk!libssl.so (dtls1_ctrl+84)

After successfull connection, connection.connected state is still false

Hello there,

Hope the summer was not toooo hot :-)

Here an other situation where I think is not normal behavior.

In the minimalist server we used, after connection established:

  • checking connection.connected gives false. Expected would be true
  • trying to send a message to the client fails with DtlsException: Sending failed: Not connected!

I realized that connection.connected passes to true only after connection.listen has been called once, so when a message from the client has been received.

So the server cannot send a message before receiving a first message from the client.

Is this a desired behavior ?

Thank you in advance for your answer.

Since 0.13.3 client cannot connect to server with returned code 2 (SSL3_AL_FATAL)

This is related to the code 2 SS3_AL_FAILURE.

I/flutter (15946): void _connectToPeer() { --> before --> _handleError(ret, _connectCompleter.completeError);
I/flutter (15946): start --> void _handleError(int ret, void Function(Exception) errorHandler) {
I/flutter (15946): _handleError(int ret, void Function(Exception) errorHandler) { --> after --> final code = _libSsl.SSL_get_error(_ssl, ret); code=2

I realized that downgrading the server to 0.13.2 works.
So there is a bug on the server side in 0.13.3.

In both cases client was on 0.13.3. So client is fine (with my fix proposal)

Unhandled exception Message too long in _maintainOutgoing() dtls_server.dart

I don't know why, suddenly started getting this exception that is ending with a Fatal one. Never had that before. Still checking around what could be the reason. Just managed to get the ret values and obviously the message is too long at a certain point.
60
156
315
65536

void _maintainOutgoing() {
final ret = _libCrypto.BIO_read(_wbio, buffer.cast(), bufferSize);
if (ret > 0) {
final bytesSent =
_dtlsServer._socket.send(buffer.asTypedList(ret), _address, _port);
if (bytesSent <= 0) {
_performShutdown(const SocketException("Network unreachable."));
}
}
_timer?.cancel();
if (_libSsl.SSL_ctrl(_ssl, DTLS_CTRL_GET_TIMEOUT, 0, buffer.cast()) > 0) {
_timer = Timer(buffer.cast<timeval>().ref.duration, _maintainState);
}
}

Unhandled exception:
SocketException: Send failed (OS Error: Message too long, errno = 90), address = ::, port = 8888
#0      _NativeSocket.send (dart:io-patch/socket_patch.dart:1246:34)
#1      _RawDatagramSocket.send (dart:io-patch/socket_patch.dart:2516:15)
#2      _DtlsServerConnection._maintainOutgoing (package:dtls2/src/dtls_server.dart:343:31)
#3      _DtlsServerConnection._maintainState (package:dtls2/src/dtls_server.dart:320:7)
#4      _DtlsServerConnection._incoming (package:dtls2/src/dtls_server.dart:358:5)
#5      DtlsServer._handleSocketRead (package:dtls2/src/dtls_server.dart:100:17)
#6      DtlsServer._startListening.<anonymous closure> (package:dtls2/src/dtls_server.dart:123:11)
#7      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
#11     _StreamController._add (dart:async/stream_controller.dart:650:7)
#12     _StreamController.add (dart:async/stream_controller.dart:598:5)
#13     new _RawDatagramSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:2469:33)
#14     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1356:14)
#15     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#16     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#17     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#18     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:190:5)

===== CRASH =====
si_signo=Segmentation fault(11), si_code=128, si_addr=(nil)
version=3.0.3 (stable) (Wed May 31 15:35:05 2023 +0000) on "linux_x64"
pid=1230056, thread=1230069, isolate_group=(nil)((nil)), isolate=(nil)((nil))
os=linux, arch=x64, comp=no, sim=no
isolate_instructions=0, vm_instructions=563043ed5920
fp=7f1cf46fede0, sp=7f1cf46fed80, pc=563043ef4b40
  pc 0x0000563043ef4b40 fp 0x00007f1cf46fede0 tcmalloc::ThreadCache::ReleaseToCentralCache(tcmalloc::ThreadCache::FreeList*, unsigned int, int)+0x1b0
  pc 0x0000563043ef5664 fp 0x00007f1cf46fee10 tcmalloc::ThreadCache::DeleteCache(tcmalloc::ThreadCache*)+0x44
-- End of DumpStackTrace

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Crash client side in void _incoming(Uint8List input) when calling _libCrypto.BIO_write(_rbio, buffer.cast(), input.length)

Hello there!

Back again with a new crash report. By the way, the client server long tests are stable for some hours since the last fixes.

Here the new situation:

I/flutter (22358): void _startListening() {
I/flutter (22358): start -> void _connectToPeer() {
I/flutter (22358): before -> final ret = _libSsl.SSL_connect(_ssl);
I/flutter (22358): after -> final ret = _libSsl.SSL_connect(_ssl);
I/flutter (22358): start --> int _maintainOutgoing() {
I/RawSoundPlayer(22358): Create audio track w/ bufferSize: 2048, sampleRate: 24000, encoding: 2, nChannels: 1
I/flutter (22358): int _maintainOutgoing() { ---> after --> final ret = _libCrypto.BIO_read(_wbio, buffer.cast(), bufferSize); ret=129
I/flutter (22358): void _connectToPeer() { --> before --> _handleError(ret, _connectCompleter.completeError);
I/flutter (22358): start --> void _handleError(int ret, void Function(Exception) errorHandler) {
I/flutter (22358): _handleError(int ret, void Function(Exception) errorHandler) { --> after --> final code = _libSsl.SSL_get_error(_ssl, ret); code=2
I/RawSoundPlayer(22358): sessionId: 206505, bufferCapacityInFrames: 1928, bufferSizeInFrames: 1928
I/flutter (22358): end --> void _handleError(int ret, void Function(Exception) errorHandler) {
I/flutter (22358): void _connectToPeer() { --> after --> _handleError(ret, _connectCompleter.completeError);
I/flutter (22358): start --> Future<void> close() async { _closed=false
I/flutter (22358): Future<void> close() async { --> before --> _libSsl.SSL_shutdown(_ssl);
I/flutter (22358): Future<void> close() async { --> after --> _libSsl.SSL_shutdown(_ssl);
I/flutter (22358): start --> void _maintainState() {
I/flutter (22358): _maintainState _connectToPeer()
I/flutter (22358): start -> void _connectToPeer() {
I/flutter (22358): before -> final ret = _libSsl.SSL_connect(_ssl);
I/flutter (22358): after -> final ret = _libSsl.SSL_connect(_ssl);
I/flutter (22358): start --> int _maintainOutgoing() {
I/flutter (22358): int _maintainOutgoing() { ---> after --> final ret = _libCrypto.BIO_read(_wbio, buffer.cast(), bufferSize); ret=-1
I/flutter (22358): void _connectToPeer() { --> before --> _handleError(ret, _connectCompleter.completeError);
I/flutter (22358): start --> void _handleError(int ret, void Function(Exception) errorHandler) {
I/flutter (22358): _handleError(int ret, void Function(Exception) errorHandler) { --> after --> final code = _libSsl.SSL_get_error(_ssl, ret); code=2
I/flutter (22358): end --> void _handleError(int ret, void Function(Exception) errorHandler) {
I/flutter (22358): void _connectToPeer() { --> after --> _handleError(ret, _connectCompleter.completeError);
I/flutter (22358): start --> Future<void> close() async { _closed=true
I/flutter (22358): end --> _maintainState _connectToPeer()
I/flutter (22358): start -> void _freeResources() {
I/flutter (22358): before -> _libSsl.SSL_free(_ssl);
I/flutter (22358): after -> _libSsl.SSL_free(_ssl);
I/flutter (22358): start --> void _incoming(Uint8List input) {
I/flutter (22358): void _incoming(Uint8List input) { ---> before --> _libCrypto.BIO_write(_rbio, buffer.cast(), input.length);
F/libc    (22358): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3005911e in tid 30232 (1.ui), pid 22358

The exception occurs when calling _libCrypto.BIO_write(_rbio, buffer.cast(), input.length); in void _incoming(Uint8List input)

Obviously _ssl has been freed before. I don't know at the moment why the handshake is not successful. Just seeing that the returned code from _libSsl.SSL_get_error(_ssl, ret) returned code is 2 (SSL3_AL_FATAL). But event with this handshake error the crash should not happen.

Any clue ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.