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
[Bug] Failed to lookup symbol 'store_dart_post_cobject' #754
Comments
I had to shorten the logs output because it was exceeding Github limit. |
what is the full output log about that "failed to lookup symbol", i.e. output of execution |
This output @fzyzcjy : flutter_rust_bridge example program start (dylibPath=../../../rust/target/debug/libflutter_rust_bridge_example.dylib)
construct api
Unhandled exception:
Invalid argument(s): Failed to lookup symbol 'store_dart_post_cobject': dlsym(RTLD_DEFAULT, store_dart_post_cobject): symbol not found
#0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:34:70)
#1 FlutterRustBridgeExampleSingleBlockTestWire._store_dart_post_cobjectPtr (package:flutter_rust_bridge_example/bridge_generated.io.dart:1573:76)
#2 FlutterRustBridgeExampleSingleBlockTestWire._store_dart_post_cobjectPtr (package:flutter_rust_bridge_example/bridge_generated.io.dart)
#3 FlutterRustBridgeExampleSingleBlockTestWire._store_dart_post_cobject (package:flutter_rust_bridge_example/bridge_generated.io.dart:1574:41)
#4 FlutterRustBridgeExampleSingleBlockTestWire._store_dart_post_cobject (package:flutter_rust_bridge_example/bridge_generated.io.dart)
#5 FlutterRustBridgeExampleSingleBlockTestWire.store_dart_post_cobject (package:flutter_rust_bridge_example/bridge_generated.io.dart:1567:12)
#6 StoreDartPostCObjectExt.storeDartPostCObject (package:flutter_rust_bridge/src/ffi/io.dart:16:5)
#7 FlutterRustBridgeBase._setUpRustToDartComm (package:flutter_rust_bridge/src/basic.dart:39:11)
#8 new FlutterRustBridgeBase (package:flutter_rust_bridge/src/basic.dart:22:5)
#9 new FlutterRustBridgeExampleSingleBlockTestPlatform (package:flutter_rust_bridge_example/bridge_generated.io.dart:19:9)
#10 new FlutterRustBridgeExampleSingleBlockTestImpl (package:flutter_rust_bridge_example/bridge_generated.dart:16:55)
#11 initializeExternalLibrary (package:flutter_rust_bridge_example/ffi.io.dart:8:10)
#12 main (package:flutter_rust_bridge_example/main.dart:17:15)
#13 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12) |
I got the path messed up in my previous output, so I fixed it So I added a safety net to make sure in if (!File(dylibPath).existsSync()) {
throw Exception('$dylibPath does not exist');
} But the error persists ! 😅 |
Use some tools to see what is inside that dylib file. For a linux .so file, we have Then, we can know whether the symbol is really in the dylib, and if yes, what is the signature of that symbol. |
I noticed that the dummy codegen doesn't appear in the pub const DUMMY_WIRE_CODE_FOR_BINDGEN: &str = r#"
// ----------- DUMMY CODE FOR BINDGEN ----------
// copied from: allo-isolate
pub type DartPort = i64;
pub type DartPostCObjectFnType = unsafe extern "C" fn(port_id: DartPort, message: *mut std::ffi::c_void) -> bool;
#[no_mangle] pub unsafe extern "C" fn store_dart_post_cobject(ptr: DartPostCObjectFnType) { panic!("dummy code") }
// copied from: frb_rust::support.rs
#[repr(C)]
pub struct WireSyncReturnStruct {
pub ptr: *mut u8,
pub len: i32,
pub success: bool,
}
// ---------------------------------------------
"#; |
IIRC that is created and then removed later? forget the details |
I'm sorry I actually don't know what is IIRC (answers on Google seemed unrelated, even with keywords). People recommended |
Ah wait, here you go I guess click to display
00000000000688b0 T _free_WireSyncReturnStruct
0000000000129bf0 T _free_zero_copy_buffer_f32
0000000000129c68 T _free_zero_copy_buffer_f64
0000000000129920 T _free_zero_copy_buffer_i16
0000000000129a10 T _free_zero_copy_buffer_i32
0000000000129b00 T _free_zero_copy_buffer_i64
0000000000129830 T _free_zero_copy_buffer_i8
0000000000129998 T _free_zero_copy_buffer_u16
0000000000129a88 T _free_zero_copy_buffer_u32
0000000000129b78 T _free_zero_copy_buffer_u64
00000000001298a8 T _free_zero_copy_buffer_u8
0000000000067ef4 T _inflate_Distance_Map
00000000000683d4 T _inflate_KitchenSink_Buffer
0000000000068438 T _inflate_KitchenSink_Enums
00000000000682d0 T _inflate_KitchenSink_Nested
000000000006834c T _inflate_KitchenSink_Optional
000000000006824c T _inflate_KitchenSink_Primitives
000000000006853c T _inflate_Measure_Distance
00000000000684d8 T _inflate_Measure_Speed
00000000000687f8 T _inflate_Speed_GPS
0000000000064420 T _new_StringList_0
0000000000064488 T _new_box_application_env_0
00000000000644c8 T _new_box_autoadd_application_settings_0
0000000000064500 T _new_box_autoadd_attribute_0
0000000000064540 T _new_box_autoadd_bool_0
0000000000064578 T _new_box_autoadd_concatenate_with_0
00000000000645b8 T _new_box_autoadd_customized_0
00000000000645f8 T _new_box_autoadd_exotic_optionals_0
0000000000064630 T _new_box_autoadd_f64_0
000000000006465c T _new_box_autoadd_feature_chrono_0
0000000000064694 T _new_box_autoadd_feature_uuid_0
00000000000646d4 T _new_box_autoadd_i32_0
0000000000064700 T _new_box_autoadd_i64_0
000000000006472c T _new_box_autoadd_kitchen_sink_0
000000000006476c T _new_box_autoadd_measure_0
00000000000647ac T _new_box_autoadd_my_size_0
00000000000647ec T _new_box_autoadd_my_struct_0
000000000006482c T _new_box_autoadd_my_tree_node_0
0000000000064864 T _new_box_autoadd_new_type_int_0
00000000000648a4 T _new_box_autoadd_note_0
00000000000648e4 T _new_box_autoadd_numbers_0
0000000000064924 T _new_box_autoadd_sequences_0
0000000000064964 T _new_box_autoadd_sum_with_0
00000000000649a4 T _new_box_autoadd_user_id_0
00000000000649e4 T _new_box_bool_0
0000000000064a1c T _new_box_distance_0
0000000000064a5c T _new_box_exotic_optionals_0
0000000000064a94 T _new_box_f64_0
0000000000064ac0 T _new_box_i32_0
0000000000064aec T _new_box_i64_0
0000000000064b18 T _new_box_i8_0
0000000000064b44 T _new_box_kitchen_sink_0
0000000000064b84 T _new_box_my_size_0
0000000000064bc4 T _new_box_speed_0
0000000000064c04 T _new_box_u8_0
0000000000064c30 T _new_box_weekdays_0
0000000000064c5c T _new_float_32_list_0
0000000000064cc4 T _new_float_64_list_0
0000000000064d2c T _new_int_32_list_0
0000000000064d94 T _new_int_8_list_0
0000000000064dfc T _new_list_application_env_var_0
0000000000064e70 T _new_list_attribute_0
0000000000064ee0 T _new_list_my_size_0
0000000000064f50 T _new_list_my_tree_node_0
0000000000064fb8 T _new_list_opt_box_autoadd_attribute_0
0000000000065020 T _new_uint_8_list_0
0000000000128b5c T _store_dart_post_cobject
00000000000640e8 T _wire_call_new_module_system
00000000000640c4 T _wire_call_old_module_system
0000000000063f98 T _wire_close_event_listener
0000000000064308 T _wire_concatenate__method__ConcatenateWith
000000000006433c T _wire_concatenate_static__static_method__ConcatenateWith
0000000000063fbc T _wire_create_event
0000000000064158 T _wire_datetime_local
0000000000064130 T _wire_datetime_utc
00000000000641a8 T _wire_duration
0000000000063e80 T _wire_first_number
0000000000063eac T _wire_first_sequence
0000000000063db4 T _wire_get_app_settings
0000000000063ed8 T _wire_get_array
0000000000063efc T _wire_get_complex_array
0000000000063e04 T _wire_get_message
0000000000064074 T _wire_get_sum_struct
0000000000063f20 T _wire_get_usize
000000000006410c T _wire_handle_big_buffers
0000000000063834 T _wire_handle_complex_struct
0000000000063d08 T _wire_handle_customized_struct
0000000000063ce0 T _wire_handle_enum_parameter
0000000000063d34 T _wire_handle_enum_struct
0000000000063c00 T _wire_handle_increment_boxed_optional
00000000000637dc T _wire_handle_list_of_struct
0000000000064254 T _wire_handle_nested_uuids
00000000000637b0 T _wire_handle_newtype
0000000000063c2c T _wire_handle_option_box_arguments
0000000000063bd4 T _wire_handle_optional_increment
0000000000063b7c T _wire_handle_optional_return
0000000000063ba8 T _wire_handle_optional_struct
0000000000063cb4 T _wire_handle_return_enum
00000000000636dc T _wire_handle_return_unit
00000000000643d0 T _wire_handle_some_static_stream_sink__static_method__ConcatenateWith
00000000000643fc T _wire_handle_some_static_stream_sink_single_arg__static_method__ConcatenateWith
0000000000064370 T _wire_handle_some_stream_sink__method__ConcatenateWith
00000000000643a4 T _wire_handle_some_stream_sink_at_1__method__ConcatenateWith
0000000000063ae4 T _wire_handle_stream
0000000000063b10 T _wire_handle_stream_of_struct
0000000000063ff0 T _wire_handle_stream_sink_at_1
000000000006401c T _wire_handle_stream_sink_at_2
0000000000064048 T _wire_handle_stream_sink_at_3
00000000000636b0 T _wire_handle_string
0000000000063808 T _wire_handle_string_list
000000000006377c T _wire_handle_struct
0000000000063894 T _wire_handle_sync_bool
0000000000063a50 T _wire_handle_sync_f32
0000000000063a80 T _wire_handle_sync_f64
00000000000639c0 T _wire_handle_sync_i16
00000000000639f0 T _wire_handle_sync_i32
0000000000063a20 T _wire_handle_sync_i64
0000000000063990 T _wire_handle_sync_i8
0000000000063860 T _wire_handle_sync_return
0000000000063ab0 T _wire_handle_sync_string
0000000000063900 T _wire_handle_sync_u16
0000000000063930 T _wire_handle_sync_u32
0000000000063960 T _wire_handle_sync_u64
00000000000638d0 T _wire_handle_sync_u8
00000000000641fc T _wire_handle_uuid
0000000000064228 T _wire_handle_uuids
000000000006372c T _wire_handle_vec_of_primitive
0000000000063700 T _wire_handle_vec_u8
0000000000063754 T _wire_handle_zero_copy_vec_of_primitive
00000000000641d0 T _wire_how_long_does_it_take
0000000000063dd8 T _wire_is_app_embedded
0000000000064098 T _wire_multiply_by_ten
0000000000064180 T _wire_naivedatetime
00000000000642dc T _wire_new__static_method__ConcatenateWith
0000000000063f48 T _wire_next_user_id
0000000000063648 T _wire_primitive_types
0000000000063688 T _wire_primitive_u32
0000000000063c88 T _wire_print_note
0000000000063f74 T _wire_register_event_listener
0000000000063e28 T _wire_repeat_number
0000000000063e54 T _wire_repeat_sequence
0000000000063b34 T _wire_return_err
0000000000063b58 T _wire_return_panic
0000000000064280 T _wire_send_i64
000000000006361c T _wire_simple_adder
00000000000642a8 T _wire_sum__method__SumWith
0000000000063d8c T _wire_use_imported_enum
0000000000063d60 T _wire_use_imported_struct Apparently the symbol is present : |
the weird thing is:
that type looks correct to me |
so maybe do some reduction? for example, write some dart code:
|
Found it : If I replace :
FlutterRustBridgeExampleSingleBlockTestImpl initializeExternalLibrary(String path) {
return FlutterRustBridgeExampleSingleBlockTestImpl(
Platform.isMacOS || Platform.isIOS ? DynamicLibrary.executable() : DynamicLibrary.open(path),
);
} I have no idea why though. |
Is this MacOS ARM specific ? or is |
weird... the lib works well for me, in macos intel |
Should we add another check based on Platform.operatingSystemVersion to differentiate between MacOS Intel and MacOS ARM ? I checked already there's no mention of M1 in e.g. |
really not sure what is happening here. maybe not a problem between m1 and intel, but problem elsewhere in the toolchain config? maybe add this to doc, telling people to try changing what you have changed. and also add a link from doc to here. if many people see same problem we will know whether it is M1 or sth else causes it |
I might be a bit slow, but I'll try to do it asap 👌 |
I'm gonna include a quick fix in the coming PR #755 to remediate : e.g. // ...
FlutterRustBridgeExampleSingleBlockTestImpl initializeExternalLibrary(String path) {
return FlutterRustBridgeExampleSingleBlockTestImpl(
Platform.isMacOS || Platform.isIOS ? DynamicLibrary.executable() : DynamicLibrary.open(path),
);
} To: // ...
FlutterRustBridgeExampleSingleBlockTestImpl initializeExternalLibrary(String path) {
return FlutterRustBridgeExampleSingleBlockTestImpl(
(Platform.isMacOS || Platform.isIOS) &&
!const bool.fromEnvironment('SILICON', defaultValue: false)
? DynamicLibrary.executable()
: DynamicLibrary.open(path),
);
} And updating related |
@Roms1383 LGTM, just a few small points
|
That's a bit tedious, but can if you want.
Hmmm why DYNAMIC_LIBRARY_SOURCE ? SILICON seems more explicit, doesn't it ? |
According to
Usage: |
@fzyzcjy am I allowed to upgrade Dart SDK minimum requirement from enum DylibSourceKind {
process,
executable,
open;
static DylibSourceKind? fromEnvironment(String arg) {
// ...
}
} |
I think so, especially we have made min rust be 1.64.0. |
Don't have an Intel Mac to test this, but I suspect |
Interestingly, as reported in #772 (comment), seems another M1 person sees this problem |
I had the same issue on a Flutter project. It's solved by this:
|
I ran into this problem trying to write a dart test of my rust code on an m1 mac. Here I forked the template and added one tiny unittest. When I run The
|
Could you please check whether it is in master branch. If not, you need to modify code as suggested. |
@fzyzcjy @justinmoon the |
@Roms1383 Btw for your SILICON pr - given all these reports, I now totally agree it is named "silicon" and just do it the simple way. |
If I just do the following in the template, it still doesn't work with the
|
I am using an M1 pro machine. I am trying to run a simple rust program on my android emulator. I am getting the following runtime error:
My
|
@SAGARSURI please create a new issue with full info. there can be many reasons of this |
Sure I will. Thanks. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Describe the bug
Ok, this is the well-known bug that has been reported many times already. I got it in the past and got rid of it by following people's recommendations in
Discussions
orIssues
. This time I'm stuck with this bug for over a couple of weeks and until now it was fine because I'll just runjust test-pure-web
instead or peek at the CI worklows execution (which just works fine, contrary to my machine lol). But this time I'm testing something and I would really like to be able to runjust test-pure
locally and track my progress here.I've already tried a bunch of stuff before opening this
Issue
, also fixed paths around (now that we switched tocargo workspace
, thetarget
folder is systematically in root folder, not in each crate's folder).Codegen logs with
RUST_LOG=debug
environment variableclick to display
To Reproduce
Just build
pure_dart
example and run withoutweb
.Expected behavior
No response
Generated binding code
click to display
OS
MacOS M1 Pro Monterey 12.4
Version of
flutter_rust_bridge_codegen
latest 1.48.0
Flutter info
Version of
clang++
Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: arm64-apple-darwin21.5.0
Version of
ffigen
^6.0.1
Additional context
No response
The text was updated successfully, but these errors were encountered: