App Crash instantly without exception or log (seems like xamarin/mono bug)

EminKokalariEminKokalari USMember ✭✭

It's a weird situation here :) , i have implemented this code in my fragment to scan TCP Ports in multithread enviroment , everything is working fine when the phone is connected in visual studio debbuger , but when i test the app outside debugger in release or debug configuration it crash without throwing any exception or any log in logcat except this line(that i dont know if it has any meaning for this problem) :

[art] art/runtime/fault_handler.cc:117] Check failed: !initialized_

OR

art Nested Signal Detected - original signal being reported

I tried to set Target Android to 23 that didn’t work.

I tried running adb shell setprop debug.mono.env MONO_DEBUG=soft-breakpoints that didn’t work.

_ANY IDEA WHY IS THIS HAPPENING ??
_

HERE IS MY CODE :

            public void start(int threadCounter)
                {
                    Task.Run(() =>
                    {
                        for (int i = 0; i < threadCounter; i++)
                        {
                            Task.Factory.StartNew(RunScanTcpAsync);
                            //Thread.Sleep(150);
                            //Thread thread1 = new Thread(new ThreadStart(RunScanTcpAsync));
                            //thread1.Start();
                        }
                    });
                }
                public async Task RunScanTcpAsync()
                {
                    int port = new int();
                    while ((port = portList.NextPort()) != -1 && nderprit != true)
                    {
                        count = tcp_count = port;
                        TcpClient tcpClient = new TcpClient();
                        var mre = new ManualResetEvent(false);
                        try
                        {
                            Task<TcpClient> connectionTask = tcpClient.ConnectAsync(host, port).ContinueWith(task =>
                            {
                                if (task.IsFaulted)
                                {
                                    return null;
                                }
                                else
                                {
                                    return tcpClient;
                                }
                            }, TaskContinuationOptions.ExecuteSynchronously);
                            var timeoutTask = Task.Delay(tcpTimeout).ContinueWith<TcpClient>(task => null, TaskContinuationOptions.ExecuteSynchronously);
                            var resultTask = Task.WhenAny(connectionTask, timeoutTask).Unwrap();
                            //resultTask.Wait();
                            //var resultTcpClient = resultTask.Result;
                            // Or shorter by using `await`:
                            var resultTcpClient = await resultTask;

                            if (resultTcpClient != null)
                            {
                                Activity.RunOnUiThread(() =>
                                {
                                    received_tcp++;
                                    mdata.Add(new data() { titulli = "Port : " + port, sekuenca = "Sequence : ", ttl = "Connection Sucessfull !", madhesia = "", koha = "Time : " });
                                    mAdapter.NotifyItemInserted(mdata.Count() - 1);
                                    if (ndaluar == false)
                                    {
                                        mRecyclerView.ScrollToPosition(mdata.Count() - 1);
                                    }
                                    mre.Set();
                                });
                                mre.WaitOne();
                                tcpClient.Dispose();
                                tcpClient.Close();
                                tcpClient = null;
                            }
                            else
                            {
                                tcpClient.Dispose();
                                tcpClient.Close();
                                tcpClient = null;
                            }

                        }
                        catch (Exception)
                        {
                            tcpClient.Dispose();
                            tcpClient.Close();
                            tcpClient = null;
                        }

                        mre.Dispose();
                    }
            }

Im compiling using :

Android Version (Android 7.1 Nougat)

Minimum Android Version :

Android 4.1 (API Level 16 - Jelly Bean)

Target Android Version :

Compile Using SDK Version

NOTE :

The code is working very fine without any error or crash when the phone that im testing the app is debugging , it happen when i open the app in release configuration or when it is not connected in debugger

Posts

Sign In or Register to comment.