Skip to content

Commit 0c34185

Browse files
dcharkesCommit Queue
authored andcommitted
[vm/ffi] Fix crash in FFI transformer
Private symbols need a library in the `Name(`. Ensure that the names chosen in the transformer are not private. TEST=pkg/vm/testcases/transformations/ffi/regress_61321.dart Closes: #61321 Change-Id: Idf7e67f5c52bea794d93253227bea214ea0d3490 Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445460 Reviewed-by: Jens Johansen <[email protected]> Commit-Queue: Daco Harkes <[email protected]>
1 parent b5c5ad0 commit 0c34185

16 files changed

+159
-55
lines changed

pkg/vm/lib/modular/transformations/ffi/use_sites.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ mixin _FfiUseSiteTransformer on FfiTransformer {
19911991
return node;
19921992
}
19931993

1994-
final newName = '${target.name.text}#$methodPostfix';
1994+
final newName = '#${target.name.text}#$methodPostfix';
19951995
final Procedure newTarget;
19961996
final parent = target.parent;
19971997
final members = switch (parent) {

pkg/vm/testcases/transformations/ffi/address_of_cast_compound_element.dart.aot.expect

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,27 @@ final class MyUnion extends ffi::Union {
7272
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
7373
static method main() → void {
7474
final self::MyStruct myStruct = new self::MyStruct::#fromTypedDataBase([@vm.inferred-type.metadata=dart.typed_data::_Uint8List] typ::Uint8List::•([@vm.inferred-type.metadata=dart.core::_Smi] self::MyStruct::#sizeOf));
75-
self::myNative#CC( block {
75+
self::#myNative#CC( block {
7676
synthesized ffi::_Compound pointer#value = myStruct;
7777
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.inferred-type.metadata=dart.core::_Smi (value: 0)] self::MyStruct::a#offsetOf){(core::num) → core::num}), block {
7878
synthesized ffi::_Compound pointer2#value = myStruct;
7979
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer2#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer2#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] self::MyStruct::b#offsetOf){(core::num) → core::num}));
8080
final self::MyUnion myUnion = new self::MyUnion::#fromTypedDataBase([@vm.inferred-type.metadata=dart.typed_data::_Uint8List] typ::Uint8List::•([@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] self::MyUnion::#sizeOf));
81-
self::myNative#CC(myUnion, myUnion);
82-
self::myNative#CC( block {
81+
self::#myNative#CC(myUnion, myUnion);
82+
self::#myNative#CC( block {
8383
synthesized ffi::_Compound pointer#value = [@vm.direct-call.metadata=#lib::MyStruct.array] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::Int8>] myStruct.{self::MyStruct::array}{ffi::Array<ffi::Int8>};
8484
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] #C19.{core::num::*}(3){(core::num) → core::num}){(core::num) → core::num}), block {
8585
synthesized ffi::_Compound pointer2#value = [@vm.direct-call.metadata=#lib::MyStruct.array] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::Int8>] myStruct.{self::MyStruct::array}{ffi::Array<ffi::Int8>};
8686
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer2#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer2#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] #C19.{core::num::*}(4){(core::num) → core::num}){(core::num) → core::num}));
87-
self::myNative#CC( block {
87+
self::#myNative#CC( block {
8888
synthesized ffi::_Compound pointer#value = [@vm.direct-call.metadata=#lib::MyStruct.array2] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::UnsignedLong>] myStruct.{self::MyStruct::array2}{ffi::Array<ffi::UnsignedLong>};
8989
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] [@vm.inferred-type.metadata=dart.core::_Smi] ffi::UnsignedLong::#sizeOf.{core::num::*}(3){(core::num) → core::num}){(core::num) → core::num}), block {
9090
synthesized ffi::_Compound pointer2#value = [@vm.direct-call.metadata=#lib::MyStruct.array2] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::UnsignedLong>] myStruct.{self::MyStruct::array2}{ffi::Array<ffi::UnsignedLong>};
9191
} =>new ffi::_Compound::_fromTypedDataBase([@vm.direct-call.metadata=dart.ffi::_Compound._typedDataBase] pointer2#value.{ffi::_Compound::_typedDataBase}{core::Object}, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.ffi::_Compound._offsetInBytes] [@vm.inferred-type.metadata=int?] pointer2#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}([@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] [@vm.inferred-type.metadata=dart.core::_Smi] ffi::UnsignedLong::#sizeOf.{core::num::*}(4){(core::num) → core::num}){(core::num) → core::num}));
9292
}
9393
@#C37
9494
@#C39
95-
external static method myNative#CC([@vm.inferred-arg-type.metadata=!] ffi::_Compound pointer, [@vm.inferred-arg-type.metadata=!] ffi::_Compound pointer2) → void;
95+
external static method #myNative#CC([@vm.inferred-arg-type.metadata=!] ffi::_Compound pointer, [@vm.inferred-arg-type.metadata=!] ffi::_Compound pointer2) → void;
9696
constants {
9797
#C1 = "vm:deeply-immutable"
9898
#C2 = null

pkg/vm/testcases/transformations/ffi/address_of_cast_compound_element.dart.expect

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ final class MyUnion extends ffi::Union {
108108
}
109109
static method main() → void {
110110
final self::MyStruct myStruct = new self::MyStruct::#fromTypedDataBase(typ::Uint8List::•(self::MyStruct::#sizeOf), #C23);
111-
self::myNative#CC( block {
111+
self::#myNative#CC( block {
112112
synthesized ffi::_Compound pointer#value = myStruct;
113113
} =>new ffi::_Compound::_fromTypedDataBase(pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}(self::MyStruct::a#offsetOf){(core::num) → core::num}), block {
114114
synthesized ffi::_Compound pointer2#value = myStruct;
115115
} =>new ffi::_Compound::_fromTypedDataBase(pointer2#value.{ffi::_Compound::_typedDataBase}{core::Object}, pointer2#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}(self::MyStruct::b#offsetOf){(core::num) → core::num}));
116116
final self::MyUnion myUnion = new self::MyUnion::#fromTypedDataBase(typ::Uint8List::•(self::MyUnion::#sizeOf), #C23);
117-
self::myNative#CC(myUnion, myUnion);
118-
self::myNative#CC( block {
117+
self::#myNative#CC(myUnion, myUnion);
118+
self::#myNative#CC( block {
119119
synthesized ffi::_Compound pointer#value = myStruct.{self::MyStruct::array}{ffi::Array<ffi::Int8>};
120120
} =>new ffi::_Compound::_fromTypedDataBase(pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}(#C25.{core::num::*}(3){(core::num) → core::num}){(core::num) → core::num}), block {
121121
synthesized ffi::_Compound pointer2#value = myStruct.{self::MyStruct::array}{ffi::Array<ffi::Int8>};
122122
} =>new ffi::_Compound::_fromTypedDataBase(pointer2#value.{ffi::_Compound::_typedDataBase}{core::Object}, pointer2#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}(#C25.{core::num::*}(4){(core::num) → core::num}){(core::num) → core::num}));
123-
self::myNative#CC( block {
123+
self::#myNative#CC( block {
124124
synthesized ffi::_Compound pointer#value = myStruct.{self::MyStruct::array2}{ffi::Array<ffi::UnsignedLong>};
125125
} =>new ffi::_Compound::_fromTypedDataBase(pointer#value.{ffi::_Compound::_typedDataBase}{core::Object}, pointer#value.{ffi::_Compound::_offsetInBytes}{core::int}.{core::num::+}(ffi::UnsignedLong::#sizeOf.{core::num::*}(3){(core::num) → core::num}){(core::num) → core::num}), block {
126126
synthesized ffi::_Compound pointer2#value = myStruct.{self::MyStruct::array2}{ffi::Array<ffi::UnsignedLong>};
@@ -131,7 +131,7 @@ static method main() → void {
131131
external static method myNative(ffi::Pointer<ffi::Void> pointer, ffi::Pointer<ffi::Void> pointer2) → void;
132132
@#C43
133133
@#C45
134-
external static method myNative#CC(ffi::_Compound pointer, ffi::_Compound pointer2) → void;
134+
external static method #myNative#CC(ffi::_Compound pointer, ffi::_Compound pointer2) → void;
135135
constants {
136136
#C1 = "vm:deeply-immutable"
137137
#C2 = null

pkg/vm/testcases/transformations/ffi/address_of_cast_typeddata_element.dart.aot.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ import "dart:typed_data";
1111
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
1212
static method main() → void {
1313
final typ::Int8List typedData = [@vm.inferred-type.metadata=dart.typed_data::_Int8List] typ::Int8List::•(20);
14-
self::myNative#T(typedData);
15-
self::myNative#C(new ffi::_Compound::_fromTypedDataBase(typedData, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] #C1.{core::num::*}(0){(core::num) → core::num}));
14+
self::#myNative#T(typedData);
15+
self::#myNative#C(new ffi::_Compound::_fromTypedDataBase(typedData, [@vm.direct-call.metadata=dart.core::_IntegerImplementation.*] [@vm.inferred-type.metadata=int (skip check)] #C1.{core::num::*}(0){(core::num) → core::num}));
1616
}
1717

1818
[@vm.inferred-return-type.metadata=int]
1919
[@vm.unboxing-info.metadata=(b)->i]
2020
@#C7
2121
@#C9
22-
external static method myNative#T([@vm.inferred-arg-type.metadata=dart.typed_data::_Int8List] typ::TypedData pointer) → core::int;
22+
external static method #myNative#T([@vm.inferred-arg-type.metadata=dart.typed_data::_Int8List] typ::TypedData pointer) → core::int;
2323

2424
[@vm.inferred-return-type.metadata=int]
2525
[@vm.unboxing-info.metadata=(b)->i]
2626
@#C7
2727
@#C9
28-
external static method myNative#C([@vm.inferred-arg-type.metadata=dart.ffi::_Compound] ffi::_Compound pointer) → core::int;
28+
external static method #myNative#C([@vm.inferred-arg-type.metadata=dart.ffi::_Compound] ffi::_Compound pointer) → core::int;
2929
constants {
3030
#C1 = 1
3131
#C2 = "cfe:ffi:native-marker"

pkg/vm/testcases/transformations/ffi/address_of_cast_typeddata_element.dart.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ import "dart:typed_data";
99

1010
static method main() → void {
1111
final typ::Int8List typedData = typ::Int8List::•(20);
12-
self::myNative#T(typedData);
13-
self::myNative#C(new ffi::_Compound::_fromTypedDataBase(typedData, #C1.{core::num::*}(0){(core::num) → core::num}));
12+
self::#myNative#T(typedData);
13+
self::#myNative#C(new ffi::_Compound::_fromTypedDataBase(typedData, #C1.{core::num::*}(0){(core::num) → core::num}));
1414
}
1515
@#C7
1616
@#C9
1717
external static method myNative(ffi::Pointer<ffi::Void> pointer) → core::int;
1818
@#C7
1919
@#C9
20-
external static method myNative#T(typ::TypedData pointer) → core::int;
20+
external static method #myNative#T(typ::TypedData pointer) → core::int;
2121
@#C7
2222
@#C9
23-
external static method myNative#C(ffi::_Compound pointer) → core::int;
23+
external static method #myNative#C(ffi::_Compound pointer) → core::int;
2424
constants {
2525
#C1 = 1
2626
#C2 = "cfe:ffi:native-marker"

pkg/vm/testcases/transformations/ffi/address_of_struct.dart.aot.expect

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ final class MyUnion extends ffi::Union {
4848
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
4949
static method main() → void {
5050
final self::MyStruct myStruct = new self::MyStruct::#fromTypedDataBase([@vm.inferred-type.metadata=dart.typed_data::_Uint8List] typ::Uint8List::•([@vm.inferred-type.metadata=dart.core::_Smi (value: 10)] self::MyStruct::#sizeOf));
51-
self::myNative#C(myStruct);
51+
self::#myNative#C(myStruct);
5252
final self::MyUnion myUnion = new self::MyUnion::#fromTypedDataBase([@vm.inferred-type.metadata=dart.typed_data::_Uint8List] typ::Uint8List::•([@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] self::MyUnion::#sizeOf));
53-
self::myNative2#C(myUnion);
54-
self::myNative3#C([@vm.direct-call.metadata=#lib::MyStruct.a] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::Int8>] myStruct.{self::MyStruct::a}{ffi::Array<ffi::Int8>});
53+
self::#myNative2#C(myUnion);
54+
self::#myNative3#C([@vm.direct-call.metadata=#lib::MyStruct.a] [@vm.inferred-type.metadata=dart.ffi::Array<dart.ffi::Int8>] myStruct.{self::MyStruct::a}{ffi::Array<ffi::Int8>});
5555
}
5656
@#C28
5757
@#C30
58-
external static method myNative#C([@vm.inferred-arg-type.metadata=#lib::MyStruct] ffi::_Compound pointer) → void;
58+
external static method #myNative#C([@vm.inferred-arg-type.metadata=#lib::MyStruct] ffi::_Compound pointer) → void;
5959
@#C33
6060
@#C34
61-
external static method myNative2#C([@vm.inferred-arg-type.metadata=#lib::MyUnion] ffi::_Compound pointer) → void;
61+
external static method #myNative2#C([@vm.inferred-arg-type.metadata=#lib::MyUnion] ffi::_Compound pointer) → void;
6262
@#C37
6363
@#C38
64-
external static method myNative3#C([@vm.inferred-arg-type.metadata=dart.ffi::Array<dart.ffi::Int8>] ffi::_Compound pointer) → void;
64+
external static method #myNative3#C([@vm.inferred-arg-type.metadata=dart.ffi::Array<dart.ffi::Int8>] ffi::_Compound pointer) → void;
6565
constants {
6666
#C1 = "vm:deeply-immutable"
6767
#C2 = null

pkg/vm/testcases/transformations/ffi/address_of_struct.dart.expect

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ final class MyUnion extends ffi::Union {
6464
}
6565
static method main() → void {
6666
final self::MyStruct myStruct = new self::MyStruct::#fromTypedDataBase(typ::Uint8List::•(self::MyStruct::#sizeOf), #C17);
67-
self::myNative#C(myStruct);
67+
self::#myNative#C(myStruct);
6868
final self::MyUnion myUnion = new self::MyUnion::#fromTypedDataBase(typ::Uint8List::•(self::MyUnion::#sizeOf), #C17);
69-
self::myNative2#C(myUnion);
70-
self::myNative3#C(myStruct.{self::MyStruct::a}{ffi::Array<ffi::Int8>});
69+
self::#myNative2#C(myUnion);
70+
self::#myNative3#C(myStruct.{self::MyStruct::a}{ffi::Array<ffi::Int8>});
7171
}
7272
@#C30
7373
@#C32
@@ -80,13 +80,13 @@ external static method myNative2(ffi::Pointer<self::MyUnion> pointer) → void;
8080
external static method myNative3(ffi::Pointer<ffi::Int8> pointer) → void;
8181
@#C30
8282
@#C32
83-
external static method myNative#C(ffi::_Compound pointer) → void;
83+
external static method #myNative#C(ffi::_Compound pointer) → void;
8484
@#C35
8585
@#C36
86-
external static method myNative2#C(ffi::_Compound pointer) → void;
86+
external static method #myNative2#C(ffi::_Compound pointer) → void;
8787
@#C39
8888
@#C40
89-
external static method myNative3#C(ffi::_Compound pointer) → void;
89+
external static method #myNative3#C(ffi::_Compound pointer) → void;
9090
constants {
9191
#C1 = "vm:deeply-immutable"
9292
#C2 = null

0 commit comments

Comments
 (0)