Bug 24577

Summary: Fatal Unhandled Exсeption: System.FormatException
Product: [Mono] Runtime Reporter: Dmitry <dzyranov>
Component: GeneralAssignee: Zoltan Varga <vargaz>
Status: RESOLVED FIXED    
Severity: normal CC: kumpera, mono-bugs+mono, mono-bugs+runtime, vargaz
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Source vs2012

Description Dmitry 2014-11-17 08:32:04 UTC
Mono 3.12.1 sgen llvm from git (linux debian 7.6 64bit)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace MonoTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var doc = new XDocument();
                doc.Add(new XElement("Root",
                           new XElement("Field1", "sss@sss.com"),
                           new XElement("Field2", "sss")));
                //*******************************************************************************
                // Fatal Unhandled Exception
                //*******************************************************************************
                var test = GetObjectFromXml<CTest>(doc);
            }
            catch(Exception e)
            {
                Console.WriteLine("Error");
            }

            Console.ReadLine();
        }

        public static T GetObjectFromXml<T>(XDocument doc)
        {
            XmlSerializer s = new XmlSerializer(typeof(T));
            var r = doc.CreateReader();
            var o = s.Deserialize(r);

            return (T)o;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace MonoTest
{
    [XmlRoot("Root")]
    public class CTest
    {
        public long Field1;
        public string Field2;
    }
}
Comment 1 Dmitry 2014-11-17 11:07:46 UTC
Created attachment 8768 [details]
Source vs2012
Comment 2 Zoltan Varga 2014-11-17 17:16:00 UTC
What is the problem here, and what is the expected behaviour ?
Comment 3 Dmitry 2014-11-17 21:03:42 UTC
crash mono, not execute catch block
Comment 4 Dmitry 2014-11-17 21:08:19 UTC
if 'Field1' is 'int' type to not crash
Comment 5 Zoltan Varga 2014-11-18 01:25:12 UTC
What is the output of mono --version ?
Comment 6 Dmitry 2014-11-18 03:23:53 UTC
Mono JIT compiler version 3.12.1 (master/4f237e0 Mon Nov 17 17:08:15 MSK 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.6.0svn-mono-master/5486eb2)
        GC:            sgen
Comment 7 Dmitry 2014-11-18 03:32:22 UTC
run MonoTest


root@1945war:/home/Project1945/MonoTest# mono MonoTest.exe

Unhandled Exception:
System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
root@1945war:/home/Project1945/MonoTest#
Comment 8 Zoltan Varga 2014-11-18 03:38:23 UTC
Could you try with the latest version of our LLVM repo (master branch, 0e362dce134e2234abb28465f05f0564f43b1dfb) ?
Comment 9 Dmitry 2014-11-18 05:18:43 UTC
install mono from https://github.com/mono/llvm.git not effect

Mono JIT compiler version 3.12.1 (master/4f237e0 Tue Nov 18 13:57:54 MSK 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.6.0svn-mono-mono/5486eb2)
        GC:            sgen


mono MonoTest.exe and mono MonoTest.exe --nollvm MonoTest.exe generates exception

Unhandled Exception:
System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
Comment 10 Zoltan Varga 2014-11-18 16:30:51 UTC
Could you try running with -O=-aot ?
Comment 11 Zoltan Varga 2014-11-18 16:53:48 UTC
Fixed in mono master 672a02e1779f2c37edee7bf6f8ecb58f888f3cc5.
Comment 12 Dmitry 2014-11-21 03:17:20 UTC
Again error

Mono JIT compiler version 3.12.1 (master/1230a40 Fri Nov 21 11:46:30 MSK 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.6.0svn-mono-mono/5486eb2)
        GC:            sgen


Unhandled Exception:
System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.FormatException: Input string was not in the correct format
  at System.Int64.Parse (System.String s, NumberStyles style, IFormatProvider provider) [0x00000] in <filename unknown>:0
root@1945war:/home/Project1945/MonoTest#
Comment 13 Zoltan Varga 2014-11-21 03:41:52 UTC
Use -O=-aot as a workaround until this is fixed.
Comment 14 Zoltan Varga 2014-11-21 18:46:54 UTC
Should be fixed now.