Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart_SendPortGetId and Dart_NewSendPort lose information about origin_id for the port #55605

Closed
aam opened this issue Apr 30, 2024 · 0 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on

Comments

@aam
Copy link
Contributor

aam commented Apr 30, 2024

$ cat send.dart
import 'dart:isolate';
import 'dart:ffi';

import 'package:ffi/ffi.dart';

@Native<Handle Function(Int64 port)>(
  symbol: 'Dart_NewSendPort')
external SendPort newSendPort(int obj);

@Native<Handle Function(Handle, Pointer<Int64>)>(
  symbol: 'Dart_SendPortGetId')
external Object sendPortGetId(Object sendPort, Pointer<Int64> out_id);

class A {}

main() async {
   final rp = ReceivePort();
   rp.close();

   Pointer<Int64> portid = calloc();
   sendPortGetId(rp.sendPort, portid);
   final sendPortThroughAPI = newSendPort(portid.value);
   sendPortThroughAPI.send('A');
   sendPortThroughAPI.send(A());
}
$ out/ReleaseX64/dart send.dart
Unhandled exception:
Invalid argument: is a regular instance reachable via : Instance of 'A'
#0      _SendPort._sendInternal (dart:isolate-patch/isolate_patch.dart:250:43)
#1      _SendPort.send (dart:isolate-patch/isolate_patch.dart:231:5)
#2      main (file:///p/d/d2/sdk/send.dart:24:23)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

it should not throw on second send. Second send should behave similarly to the first one.

from flutter/flutter#147469

@aam aam added area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on labels Apr 30, 2024
@aam aam self-assigned this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

1 participant