Bug 56765 - App Crash instantly without exception or log
Summary: App Crash instantly without exception or log
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Android+BCL Integration ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
: 56770 57131 ()
Depends on:
Blocks: 57131
  Show dependency tree
 
Reported: 2017-05-23 16:44 UTC by Emin Kokalari
Modified: 2017-06-12 13:38 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Emin Kokalari 2017-05-23 16:44:41 UTC
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_

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 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
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2017-06-05 18:32:03 UTC
*** Bug 56770 has been marked as a duplicate of this bug. ***
Comment 2 Marek Habersack 2017-06-07 21:18:02 UTC
@Emin, can you attach a small application that reliably reproduces the issue for you? Also, what is the Xamarin.Android version you're using?
Comment 3 Marek Habersack 2017-06-07 21:23:33 UTC
@Emin, one other question - are you absolutely positive it happens only when NOT debugging? The fault handler mentioned in message used to be triggered when we used "hard" breakpoints (using segmentation faults which sometimes conflicted with Android ART's segfault handler) to implement debugging, we've since moved to "soft" ones which no longer trigger the issue. The repro and information on the Xamarin.Android version will be necessary to attempt to resolve this issue, thanks!
Comment 4 Emin Kokalari 2017-06-10 02:04:22 UTC
After last update 30/5/2017 , of vs2017 and xamarin it crash when debugging too...

I dont have reson to attach any project , it can simply reproduce with the lastest ver. Of xam. And VS . i have tried to compile with diferent apis and changes target api too , disabled/enabled proguard , multidex , native compile... Tried diferent abis and diferent linker settings... Ect ect ... I have tried almost everything , but still not finding solution..., it again and again everytime crash after that code that i have posted above in the first message of the bug
Comment 5 Emin Kokalari 2017-06-10 02:06:59 UTC
And something other ... Juat try with this if you dont have time to try the first example : 


  public void start()
    {
        for (int i = 0; i < 50; i++)
        {
            Task.Run(() => RunScanTcp());
            //ThreadPool.QueueUserWorkItem(RunScanTcp);
            //Thread thread = new Thread(new ThreadStart(RunScanTcp));
            //thread.Start();
        }
    }


    public void RunScanTcp()
    {
        while (abort != true)
        {
                port = port + 1;
                Log.Info("PORT SCANNER", port.ToString());
        }
    }
Comment 6 Emin Kokalari 2017-06-10 02:14:07 UTC
And the last one : 

I will continue to use xamarin bcos c# is the language that i have fall in love , but i decided before 1-2 months to start learning java for better android platform. Xam. Forums and the support need improvements , i think im unprotected as prg. from xamarin
Comment 7 Emin Kokalari 2017-06-10 17:56:11 UTC
IT have been fixed after last update 6/9/2017 Visual Studio 2017 version 15.2 (26430.13) it dont crash anymore ... anyway thanks for your time
Comment 8 Marek Habersack 2017-06-12 13:37:48 UTC
@Emin, it's not about me/us having no time to try the example. The reason we request repros is that people configure their applications, environments and solutions in a myriad different ways and we want to get the exact code that fails on your machine - pasting a fragment of code doesn't meet the criteria. Android (any OS), Xamarin.{Android,Forms,iOS} (any non-trivial framework) are highly complex creations that interact with each other in a multitude of ways. The fastest way to get to the bottom of a problem is being able to reproduce the issue - and that can be ascertained only if you, the reporter, give us, the developers, something that's self-contained and fully reproduces the issue. It certainly isn't about the lack of interest of time.

Anyhow, I'm glad the update fixed the issue for you - I don't know what version of XA you used previously but most likely it was one which still used hardware-assisted breakpoints while the latest update you now have doesn't do that.
Comment 9 Marek Habersack 2017-06-12 13:38:34 UTC
*** Bug 57131 has been marked as a duplicate of this bug. ***