PHP.Core.OrderedDictionary+Enumerator not Serializable

Discussion about the open-source Phalanger [?] project.

PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby kripper » February 19th, 2012, 11:06 am

This happens when using an asp_state server for storing sessions.
I believe it's a trivial bug, since it seems similar to one posted and resolved recently.

BTW, sessions get lost after refreshing the same script about 10 times (randomly). Any hint? I will try to check this in more detail.

Code: Select all
System.Runtime.Serialization.SerializationException: Type PHP.Core.OrderedDictionary+Enumerator is not marked as Serializable.
  at System.Runtime.Serialization.Formatters.Binary.BinaryCommon.CheckSerializable (System.Type type, ISurrogateSelector selector, StreamingContext context) [0x0002c] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs:119
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteValue (System.IO.BinaryWriter writer, System.Type valueType, System.Object val) [0x00006] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:762
  at PhpArray__TypeMetadata.WriteObjectData (System.Runtime.Serialization.Formatters.Binary.ObjectWriter , System.IO.BinaryWriter , System.Object ) [0x00000] in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject (System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x0011e] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:370
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance (System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject) [0x00062] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:303
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects (System.IO.BinaryWriter writer) [0x00005] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:281
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph (System.IO.BinaryWriter writer, System.Object obj, System.Runtime.Remoting.Messaging.Header[] headers) [0x0001f] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:268
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) [0x0005f] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:218
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in /opt/imatronix/src/mono/mono-2.10.9/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:197
  at PHP.Core.AspNetSessionHandler.Persist (PHP.Core.PhpArray variables, PHP.Core.ScriptContext context, System.Web.HttpContext httpContext) [0x00000] in <filename unknown>:0
  at PHP.Core.RequestContext.EndSession (Boolean abandon) [0x00000] in <filename unknown>:0
  at PHP.Core.RequestContext.<TryDisposeBeforeFinalization>b__0 (System.Object _) [0x00000] in <filename unknown>:0
  at PHP.Core.ScriptContext.GuardedCall[Object,Object] (System.Converter`2 routine, System.Object data, Boolean allowUserExceptions) [0x00000] in <filename unknown>:0
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby Jakub Misek » February 19th, 2012, 11:23 am

PHP.Core.OrderedDictionary+Enumerator will be fixed. Thanks.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby Jakub Misek » February 19th, 2012, 11:32 am

Sessions are handled by ASP.NET if not configured differently. Phalanger just loads them into PHP global variable, and at the end of request it saves them back.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby kripper » February 25th, 2012, 10:48 pm

Tested latest SVN implementation and got this:

Code: Select all
System.ArgumentException: Value does not fall within the expected range.
  at PHP.Core.OrderedDictionary.CopyTo (System.Collections.Generic.KeyValuePair`2[] array, Int32 arrayIndex) [0x00000] in <filename unknown>:0
  at PHP.Core.OrderedDictionary.GetObjectData (System.Runtime.Serialization.SerializationInfo info, 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 PHP.Core.AspNetSessionHandler.Persist (PHP.Core.PhpArray variables, PHP.Core.ScriptContext context, System.Web.HttpContext httpContext) [0x00000] in <filename unknown>:0
  at PHP.Core.RequestContext.EndSession (Boolean abandon) [0x00000] in <filename unknown>:0
  at PHP.Core.RequestContext.<TryDisposeBeforeFinalization>b__0 (System.Object _) [0x00000] in <filename unknown>:0
  at PHP.Core.ScriptContext.GuardedCall[Object,Object] (System.Converter`2 routine, System.Object data, Boolean allowUserExceptions) [0x00000] in <filename unknown>:0
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby Jakub Misek » February 25th, 2012, 11:11 pm

Thanks! Fixed. (CopyTo(KeyValuePair<IntStringKey, object>[],int) had invalid argument check, has to be '>' instead of '>=')
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby kripper » February 26th, 2012, 8:40 pm

I changed code to:

Code: Select all
        public void CopyTo(KeyValuePair<IntStringKey, object>[] array, int arrayIndex)
        {
            if (array == null || arrayIndex < 0 || (arrayIndex + this.Count) > array.Length)
                throw new ArgumentException();

            using (var enumerator = GetFastEnumerator())
                while (enumerator.MoveNext())
                    array[arrayIndex++] = enumerator.Current;
        }


Now I'm getting this:

Code: Select all
EndSession Exception: System.NullReferenceException: Object reference not set to
 an instance of an object
  at PHP.Core.OrderedDictionary+FastEnumerator.MoveNext () [0x00000] in <filenam
e unknown>:0
  at PHP.Core.OrderedDictionary.CopyTo (System.Collections.Generic.KeyValuePair`
2[] array, Int32 arrayIndex) [0x00000] in <filename unknown>:0
  at PHP.Core.OrderedDictionary.GetObjectData (System.Runtime.Serialization.Seri
alizationInfo info, 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 (Sy
stem.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


The exception is generated here:

Code: Select all
this.current = table.entries[next].KeyValuePair;
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby Jakub Misek » February 26th, 2012, 8:54 pm

Thanks! This will be fixed as it will go to official release. Meantime it is in development and it is recommended to use release changeset.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby kripper » February 26th, 2012, 8:55 pm

Ok. One more hint:
In MoveNext() 'next' is 0 and 'table.entries' is null.
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am

Re: PHP.Core.OrderedDictionary+Enumerator not Serializable

Postby Jakub Misek » February 26th, 2012, 9:10 pm

Thanks :) We will take a look on this ASAP.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 1 guest

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 787 on May 12th, 2024, 11:50 am

Users browsing this forum: No registered users and 1 guest