Results 1 to 8 of 8

Thread: perhaps a bug in pather.cs

  1. #1
    OrNot is offline Registered User
    Name: Bin.Li
    Organization: GE Healthcare
    Project: Enterprise solution
    Join Date
    Jun 2005
    Location
    Shanghai
    Posts
    181

    perhaps a bug in pather.cs

    In current 3.0.0 version, it seems that null object can not be returned from peer endpoints. If not intentionally, this seems a bug.

    public override void patch(Ice.Object v)
    {
    Debug.Assert(type_ != null);

    if (v!=null) // necessary?
    {
    if(!type_.IsInstanceOfType(v))
    {
    throw new System.InvalidCastException("expected element of type " + type()
    + " but received " + v.GetType().FullName);
    }
    }

    value = v;

    }


    Best regards
    OrNot
    ------------------------------------------
    ornot2008@yahoo.com
    --------------------------------------------

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    I'm not sure I understand why this might cause a problem. Do you have test case to show where this would cause incorrect behavior?

    Cheers,

    Michi.

  3. #3
    OrNot is offline Registered User
    Name: Bin.Li
    Organization: GE Healthcare
    Project: Enterprise solution
    Join Date
    Jun 2005
    Location
    Shanghai
    Posts
    181
    hi, Michi,
    It is easy to reproduce this error if you add ,say, HelloI ,in server ,

    public class HelloI: Demo.helloDisp_
    {
    public override Demo.TestClass get(Ice.Current current__)

    {
    return null;
    }


    };

    That is, return a null reference to a object.



    Here are the original codes:

    public override void patch(Ice.Object v)
    {
    Debug.Assert(type_ != null);
    if(!type_.IsInstanceOfType(v))
    {
    throw new System.InvalidCastException("expected element of type " + type()
    + " but received " + v.GetType().FullName);
    }

    value = v;

    }

    When v is undefined, an exception is thrown.
    Last edited by OrNot; 12-24-2005 at 08:40 AM.
    ------------------------------------------
    ornot2008@yahoo.com
    --------------------------------------------

  4. #4
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Thanks for that, I'll have a look at this next week.

    Cheers,

    Michi.

  5. #5
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Thanks muchly for the bug report! I've posted a patch here.

    Cheers,

    Michi.

  6. #6
    OrNot is offline Registered User
    Name: Bin.Li
    Organization: GE Healthcare
    Project: Enterprise solution
    Join Date
    Jun 2005
    Location
    Shanghai
    Posts
    181

    Perhaps another bug in Patcher.cs

    Considering the fellowing slice definition:

    // ************************************************** ********************
    //
    // Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
    //
    // This copy of Ice is licensed to you under the terms described in the
    // ICE_LICENSE file included in this distribution.
    //
    // ************************************************** ********************

    #ifndef HELLO_ICE
    #define HELLO_ICE
    module Demo
    {
    class Node;
    ["clr:collection"]sequence<Node> NodeList;

    class Node
    {
    NodeList subNode;
    };
    interface Hello
    {
    nonmutating void sayHello();
    Node getNode();
    };

    };
    #endif


    In the HelloI (say,Java sample codes):

    public class HelloI extends _HelloDisp
    {
    public void
    sayHello(Ice.Current current)
    {
    System.out.println("Hello World!");
    }

    public Node getNode(Current __current)
    {
    Node fatherNode = new Node();
    Node[] subNodes = new Node[2];
    fatherNode.subNode = subNodes;
    return fatherNode;
    }
    }


    That's, return some objects with null in a sequence.;


    This can result in an exception from Patcher.cs in client when the v==null,


    public override void patch(Ice.Object v)
    {
    try
    {
    if(_seq is IList)
    {
    if(_index >= _seq.Count)
    {
    for(int i = _seq.Count; i <= _index; i++)
    {
    ((IList)_seq).Add(dummyObject); // IList implementation does not permit adding null :-(
    }
    }

    ////////////////////////Exception from here////////////////////////////////
    /// ((IList)_seq)[_index] = v;
    ////////////////////////////////////////////////////////


    }
    else
    {
    ((System.Array)_seq).SetValue(v, _index);
    }
    }
    catch(System.Exception)
    {
    throw new System.InvalidCastException("expected element of type " + type()
    + " but received " + v.GetType().FullName);
    }
    }


    I am not very sure about this bug and maybe it is my useage mistake.


    OS: win2000;
    Vistual Studio 2003;
    Ice: 3.0.0;




    Cheers
    OrNot
    ------------------------------------------
    ornot2008@yahoo.com
    --------------------------------------------

  7. #7
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Thanks for the bug report.

    The problem is caused by the IList methods of CollectionBase. Unfortunately, it does not permit null to be inserted into a list (God only knows why... ) and, to make things worse, the Add method and the indexer of the implementation of CollectionBase appear to be non-virtual, so the call isn't dispatched into the NodeList implementation

    I'm still investigating possible workarounds.

    Michi.
    Last edited by michi; 03-14-2006 at 12:31 AM.

  8. #8
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    I've posted a patch for this problem. Thanks for reporting this!

    Cheers,

    Michi.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IceSL 0.3.2: ArgumentException in IceConnection.cs
    By kwaclaw in forum Bug Reports
    Replies: 0
    Last Post: 10-20-2008, 05:41 PM
  2. perhaps a mistake in IncomingAsync.cs
    By xiehua in forum Bug Reports
    Replies: 1
    Last Post: 02-04-2006, 10:32 AM
  3. C#: loadPlugin() in PluginManagerI.cs
    By kwaclaw in forum Bug Reports
    Replies: 3
    Last Post: 09-26-2005, 04:54 PM
  4. CS: compiler warning
    By DeepDiver in forum Bug Reports
    Replies: 2
    Last Post: 01-10-2005, 07:31 PM
  5. Replies: 3
    Last Post: 08-12-2004, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •