fix: resolve argv[0] misparse and SIGSEGV hang in JNI bridge
Two root causes prevented iperf3 tests from running: 1. argv[0] bug: iperf_parse_arguments() expects argv[0] to be the program name. We passed Dart args directly, so argv[0] was '-c', which iperf3 misinterpreted as the program name → 'Argument parse error: must either be a client (-c) or server (-s)'. Fixed by prepending "iperf3" as argv[0] and shifting user args to argv[1+]. 2. Signal handling: iperf_catch_sigend() installs handlers that use longjmp() to a jmp_buf, but we never initialized the buffer with setjmp(). Any signal during iperf_run_client() caused SIGSEGV or hang. Added setjmp/longjmp wrapper matching main.c's pattern, SIGPIPE=SIG_IGN, and a 30s connect_timeout to avoid DNS hangs. Also extracted iperf_cleanup_and_signal() to deduplicate the normal-return and longjmp paths. Added diagnostic logging to IperfRunner.kt's library loading for faster future debugging.
This commit is contained in:
@@ -19,7 +19,14 @@ object IperfRunner : FlutterPlugin {
|
||||
|
||||
init {
|
||||
// Load native library at class initialization
|
||||
System.loadLibrary("iperf3jni")
|
||||
try {
|
||||
android.util.Log.i("IperfRunner", "Loading native library...")
|
||||
System.loadLibrary("iperf3jni")
|
||||
android.util.Log.i("IperfRunner", "Native library loaded successfully")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
android.util.Log.e("IperfRunner", "Failed to load native library: ${e.message}")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
|
||||
Reference in New Issue
Block a user