Bug 12611 - System.Runtime.Serialization.SerializationException when logging from a child AppDomain
Summary: System.Runtime.Serialization.SerializationException when logging from a child...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: PC Linux
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-06-09 20:19 UTC by Narinder
Modified: 2017-10-12 13:08 UTC (History)
4 users (show)

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


Attachments
NUnit tests to reproduce 2 potential issues in Mono (4.82 KB, application/x-zip-compressed)
2013-06-09 20:19 UTC, Narinder
Details
A further simplified project to reproduce the code. NO use of NUnit (6.42 KB, application/zip)
2013-06-11 17:34 UTC, Narinder
Details

Description Narinder 2013-06-09 20:19:34 UTC
Created attachment 4090 [details]
NUnit tests to reproduce 2 potential issues in Mono

Hello,
Using: Mono 3.0.10, log4net, Ubuntu 12.10.

I marshal a logging appender to a child Appdomain. In the appender I overload the DoAppend to do the following:

 loggingEvent.Fix = log4net.Core.FixFlags.Domain | log4net.Core.FixFlags.Exception |
                               log4net.Core.FixFlags.Identity |
                               //********************************************************************
                                log4net.Core.FixFlags.LocationInfo |  // Blows up in Mono
                               //********************************************************************
                               log4net.Core.FixFlags.Message | log4net.Core.FixFlags.ThreadName | log4net.Core.FixFlags.Properties;

This works fine in .NET4 on windows but I have an exception on Mono under Linux. Specifically it's the line

log4net.Core.FixFlags.LocationInfo |  // Blows up in Mono

When this is commented out everything works fine. The source code to reproduce the issue as a NUnit test is attached.


The exception details are :
 
.log4net:ERROR Failed to append to appender []
System.Runtime.Serialization.SerializationException: Type System.Reflection.MonoCMethod is not marked as Serializable.
  at System.Runtime.Serialization.Formatters.Binary.BinaryCommon.CheckSerializable (System.Type type, ISurrogateSelector selector, StreamingContext context) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData (System.Object obj, System.Runtime.Serialization.Formatters.Binary.TypeMetadata& metadata, System.Object& data) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject (System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance (System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects (System.IO.BinaryWriter writer) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph (System.IO.BinaryWriter writer, System.Object obj, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in <filename unknown>:0 
  at System.Runtime.Remoting.RemotingServices.SerializeCallData (System.Object obj) [0x00000] in <filename unknown>:0 
  at (wrapper xdomain-invoke) mono_vs_net.AppenderWrapper:DoAppend (log4net.Core.LoggingEvent)
  at mono_vs_net.AppenderWrapper.DoAppend (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0 
  at mono_vs_net.AppenderFixingWrapper.DoAppend (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0 
  at log4net.Util.AppenderAttachedImpl.AppendLoopOnAppenders (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0
Comment 1 Narinder 2013-06-11 17:34:51 UTC
Created attachment 4102 [details]
A further simplified project to reproduce the code. NO use of NUnit

I have removed the dependency on NUnit and attached a new zip file of the project. There is one executable and one library.
Comment 2 Rodrigo Kumpera 2013-06-14 19:07:26 UTC
The above is fixed in the next mono 3.0. Thanks for the test case.

Logging probably remain broken from generic methods as they still don't serialize correctly.

Please file another bug if you bump into the issue.
Comment 3 Narinder 2013-06-20 19:00:24 UTC
Hello,
I have just downloaded and compiled the tarball for 3.0.12.  

My output for mono -V is :
Usage is: mono [options] program [program-options]

Development:
    --aot[=<options>]      Compiles the assembly to native code
    --debug[=<options>]    Enable debugging support, use --help-debug for details
    --debugger-agent=options Enable the debugger agent
    --profile[=profiler]   Runs in profiling mode with the specified profiler module
    --trace[=EXPR]         Enable tracing, use --help-trace for details
    --jitmap               Output a jit method map to /tmp/perf-PID.map
    --help-devel           Shows more options available to developers

Runtime:
    --config FILE          Loads FILE as the Mono config
    --verbose, -v          Increases the verbosity level
    --help, -h             Show usage information
    --version, -V          Show version information
    --runtime=VERSION      Use the VERSION runtime, instead of autodetecting
    --optimize=OPT         Turns on or off a specific optimization
                           Use --list-opt to get a list of optimizations
    --security[=mode]      Turns on the unsupported security manager (off by default)
                           mode is one of cas, core-clr, verifiable or validil
    --attach=OPTIONS       Pass OPTIONS to the attach agent in the runtime.
                           Currently the only supported option is 'disable'.
    --llvm, --nollvm       Controls whenever the runtime uses LLVM to compile code.
    --gc=[sgen,boehm]      Select SGen or Boehm GC (runs mono or mono-sgen)
nclaire@Beast:~/workspace/csharp/learning/mono_vs_net/mono_vs_net/bin/Debug$ mono -V
Mono JIT compiler version 3.0.12 (tarball Thu Jun 20 23:12:59 BST 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          bigarrays softdebug 
	LLVM:          supported, not enabled.
	GC:            Included Boehm (with typed GC and Parallel Mark)



I execute the code previously attached "mono_vs_net". I still get the following error :


log4net:ERROR Failed to append to appender []
System.Runtime.Serialization.SerializationException: Could not find method 'System.Object InternalInvoke(System.Reflection.MonoCMethod, System.Object, System.Object[], System.Exception ByRef)' in type 'System.Reflection.MonoCMethod'

Server stack trace: 
  at System.Reflection.MemberInfoSerializationHolder.GetRealObject (StreamingContext context) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.ObjectRecord.LoadData (System.Runtime.Serialization.ObjectManager manager, ISurrogateSelector selector, StreamingContext context) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in <filename unknown>:0 
  at System.Runtime.Remoting.RemotingServices.DeserializeCallData (System.Byte[] array) [0x00000] in <filename unknown>:0 
  at (wrapper xdomain-dispatch) mono_vs_net.AppenderWrapper:DoAppend (object,byte[]&,byte[]&)

Exception rethrown at [0]: 

  at (wrapper xdomain-invoke) mono_vs_net.AppenderWrapper:DoAppend (log4net.Core.LoggingEvent)
  at mono_vs_net.AppenderWrapper.DoAppend (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0 
  at mono_vs_net.AppenderFixingWrapper.DoAppend (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0 
  at log4net.Util.AppenderAttachedImpl.AppendLoopOnAppenders (log4net.Core.LoggingEvent loggingEvent) [0x00000] in <filename unknown>:0 



I am not logging from a generic method.


Rgds
N
Comment 4 Marek Safar 2017-10-12 13:08:56 UTC
Could you please try to update to any recent version and try to reproduce the issue again.

If the issue still persists please include the version information and change the bug status to NEW.

Note You need to log in before you can comment on or make changes to this bug.