-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/ffi] Disallow
Pointer
s and structs in finalizers and expandos
`Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in `dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s as values passed in to the `object` parameter. Expandos no longer accept `Pointer`s and subtypes of `Struct`s as values passed in to the `object` parameter. Cleans up unused object_store->ffi_struct_class. Closes: #45071 Breaking change: #45072 TEST=vm/cc/DartAPI_FinalizableHandleErrors TEST=vm/cc/DartAPI_WeakPersistentHandleErrors TEST=tests/ffi(_2)/expando_test.dart Change-Id: I1f11adfa073c7d2c979f3c2bb15c7444c7c767a0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186280 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
- Loading branch information
Showing
11 changed files
with
213 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// Dart test program for testing dart:ffi primitive data pointers. | ||
// | ||
// SharedObjects=ffi_test_functions | ||
|
||
import 'dart:ffi'; | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
void main() { | ||
testPointer(); | ||
testStruct(); | ||
} | ||
|
||
Expando<int> expando = Expando('myExpando'); | ||
|
||
void testPointer() { | ||
final pointer = Pointer<Int8>.fromAddress(0xdeadbeef); | ||
Expect.throws(() { | ||
expando[pointer]; | ||
}); | ||
Expect.throws(() { | ||
expando[pointer] = 1234; | ||
}); | ||
} | ||
|
||
class MyStruct extends Struct { | ||
external Pointer notEmpty; | ||
} | ||
|
||
void testStruct() { | ||
final pointer = Pointer<MyStruct>.fromAddress(0xdeadbeef); | ||
final struct = pointer.ref; | ||
Expect.throws(() { | ||
expando[struct]; | ||
}); | ||
Expect.throws(() { | ||
expando[struct] = 1234; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// Dart test program for testing dart:ffi primitive data pointers. | ||
// | ||
// SharedObjects=ffi_test_functions | ||
|
||
import 'dart:ffi'; | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
void main() { | ||
testPointer(); | ||
testStruct(); | ||
} | ||
|
||
Expando<int> expando = Expando('myExpando'); | ||
|
||
void testPointer() { | ||
final pointer = Pointer<Int8>.fromAddress(0xdeadbeef); | ||
Expect.throws(() { | ||
expando[pointer]; | ||
}); | ||
Expect.throws(() { | ||
expando[pointer] = 1234; | ||
}); | ||
} | ||
|
||
class MyStruct extends Struct { | ||
Pointer notEmpty; | ||
} | ||
|
||
void testStruct() { | ||
final pointer = Pointer<MyStruct>.fromAddress(0xdeadbeef); | ||
final struct = pointer.ref; | ||
Expect.throws(() { | ||
expando[struct]; | ||
}); | ||
Expect.throws(() { | ||
expando[struct] = 1234; | ||
}); | ||
} |