Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-01-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
slice2cs: struct/class unmarshalling problem

I have a struct defined in Slice that is mapped to a class in C#, but I get a null-reference exception on unmarshalling. Here is the Slice:

Code:
  ["clr:property"]
  struct Action {
    string Key;
    string Description;
  };
  
  ["clr:property"]
  struct ActionPermission {
    ::IServices2ICE::Action Action;
    bool IsAuthorized;
  };
  
  sequence<ActionPermission> ActionPermissionSeq;

  ["ami", "amd"] interface ClassifiedServices {
    . . .
    idempotent OpStatus GetClientPermissions(
        string clientGroupKey,
        string orderStatus,
        out ActionPermissionSeq permissions
      )
      throws ServiceError;
  };
Now, debugging it, I can see that exception happens in the unmarshalling code for ActionPermission:

Code:
        public void read__(IceInternal.BasicStream is__)
        {
            Action_prop.read__(is__);
            IsAuthorized_prop = is__.readBool();
        }
When it is called, Action_prop is null, leading to the exception.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
  #2 (permalink)  
Old 10-01-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
Quote:
Originally Posted by kwaclaw View Post
I have a struct defined in Slice that is mapped to a class in C#, but I get a null-reference exception on unmarshalling.
It seems the marshalling code has the same problem:

Code:
        public void write__(IceInternal.BasicStream os__)
        {
            Action_prop.write__(os__);
            os__.writeBool(IsAuthorized_prop);
        }
It looks as if the code was generated assuming that Action was mapped to a struct instead of a class.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
  #3 (permalink)  
Old 10-01-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,055
Thanks Karl we'll look into this.
Reply With Quote
  #4 (permalink)  
Old 10-10-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Karl,

I'm looking at your problem. Unfortunately, the fix isn't entirely trivial (and I was away on vacation all last week), which is why this is taking so long. I'll have a patch for you by tomorrow.

Cheers,

Michi.
Reply With Quote
  #5 (permalink)  
Old 10-10-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
Quote:
Originally Posted by michi View Post
Karl,

I'm looking at your problem. Unfortunately, the fix isn't entirely trivial (and I was away on vacation all last week), which is why this is taking so long. I'll have a patch for you by tomorrow.

Cheers,

Michi.
Thanks, that is OK, we are still in development, and there is a simple workaround.

And even you are entitled to some vacation.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
  #6 (permalink)  
Old 10-11-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Hi Karl, I've post a patch for this problem. Please let me know how you go with that.

Cheers,

Michi.
Reply With Quote
  #7 (permalink)  
Old 10-11-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
Quote:
Originally Posted by michi View Post
Hi Karl, I've post a patch for this problem. Please let me know how you go with that.

Cheers,

Michi.
There is now another issue with the generated code (in another part of my Slice) that does not allow it to compile. The problem is when a struct is mapped to a C# struct. The generated code does not initialize the struct when reading it from the stream. Here is the code generated - the function is the one called by IceInternal.DispatchStatus dispatch__(). I hope this is sufficient detail for you:

Code:
        public static IceInternal.DispatchStatus GetPackagePubDates___(CommonServices obj__, IceInternal.Incoming inS__, Ice.Current current__)
        {
            checkMode__(Ice.OperationMode.Idempotent, current__.mode);
            IceInternal.BasicStream is__ = inS__.istr();
            string packageKey;
            packageKey = is__.readString();
            IServices2ICE.Date startDate;  // = new IServices2ICE.Date();
            startDate.read__(is__);
            string classKey;
            classKey = is__.readString();
            AMD_CommonServices_GetPackagePubDates cb__ = new _AMD_CommonServices_GetPackagePubDates(inS__);
            try
            {
                obj__.GetPackagePubDates_async(cb__, packageKey, startDate, classKey, current__);
            }
            catch(_System.Exception ex)
            {
                cb__.ice_exception(ex);
            }
            return IceInternal.DispatchStatus.DispatchAsync;
        }
The type IServices2ICE.Date is a struct, and it should be initialized by calling the default struct constructor, see the comment in the code.

Because of the compile issue I haven't tested your patch yet, although the generated code looks OK for it.

Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
  #8 (permalink)  
Old 10-11-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 909
Hi Karl,

my apologies--I missed two spots in the code generator that were affected by the changes.

I've updated the patch. Could you try again please?

Thanks,

Michi.
Reply With Quote
  #9 (permalink)  
Old 10-12-2007
kwaclaw kwaclaw is offline
Registered User
 
Name: Karl Waclawek
Organization: Toronto Star Newspapers Ltd.
Project: Proof of concept
 
Join Date: Sep 2004
Location: Oshawa, Canada
Posts: 136
Quote:
Originally Posted by michi View Post
Hi Karl,

my apologies--I missed two spots in the code generator that were affected by the changes.

I've updated the patch. Could you try again please?

Thanks,

Michi.
Good news - it works now.

Thanks,


Karl
__________________
Karl Waclawek
The Toronto Star - http://www.thestar.com
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
C#: Nested struct unmarshalling problem kwaclaw Bug Reports 11 09-27-2007 01:01 PM
A problem about struct of multi-items klsmlzm Help Center 4 10-24-2006 03:38 AM
Problem with classes in struct kovacm Help Center 9 10-06-2005 02:49 AM
why struct inherit class code Help Center 6 10-06-2004 02:17 PM
May slice struct contain class? minifat Help Center 1 08-09-2004 10:16 PM


All times are GMT -4. The time now is 08:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.