Bug 1667

Summary: Locate Forward with out sequences causes server to segv
Product: TAO Reporter: Heather Drury <drury_h>
Component: IDL CompilerAssignee: Dale Wilson <wilson_d>
Status: RESOLVED FIXED    
Severity: normal CC: cleeland, drury_h, wilson_d
Priority: P3    
Version: 1.3.5   
Hardware: All   
OS: All   
Bug Depends on: 1676    
Bug Blocks: 1638    
Attachments: idl code that illustrates the problem

Description Heather Drury 2003-12-08 09:59:35 CST
TAO VERSION: 1.3.4
ACE VERSION: 5.3.4

HOST MACHINE and OPERATING SYSTEM:
Linux 8.0

TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
COMPILER NAME AND VERSION (AND PATCHLEVEL):
gcc version 3.2.3

AREA/CLASS/EXAMPLE AFFECTED:
N/A
DOES THE PROBLEM AFFECT:
 COMPILATION?
 No


LINKING?
No

EXECUTION?
Yes

OTHER (please specify)?

SYNOPSIS:
Locate Forward thrown by interceptor causes server to segv.

DESCRIPTION:
When the idl file contains a sequence of outs, and a Locate Forward is 
thrown from an interceptor, the server dumps core. It appears that the 
skeleton  code doesn't check to see if a location forward is thrown 
before trying to marshal the response, including the sequence of strings 
(which is nil).

For example, the following idl:

    module Test
    {
     interface Hello
     {
       typedef sequence<string> stringSeq;
       void get_string (out stringSeq test_string);
       oneway void shutdown ();
     };
    };


has a corresponding skeleton method of get_string_skel() that has code 
[attached] that trys to marshal the string into the out object even 
though that sequence of strings has not been initialized in the servant:

 if (!(
     (_tao_out << test_string.in ())
     ))
     {
              TAO_InputCDR::throw_skel_exception (errno 
ACE_ENV_ARG_PARAMETER);
       ACE_CHECK;
     }
Comment 1 Heather Drury 2003-12-08 10:00:11 CST
Created attachment 245 [details]
idl code that illustrates the problem
Comment 2 Nanbor Wang 2003-12-08 11:23:46 CST
Is OCI having a fix for this?
Comment 3 Jeff Parsons 2003-12-16 12:12:53 CST
Pending OCI's reply to Bala's last comment, we will address this issue when we 
tackle the generated code refactoring for the skeleton side.
Comment 4 Dale Wilson 2003-12-16 12:40:36 CST
I have a fix for this one, but I haven't finished testing it yet.
If it passes, I'll check it in when the repo is open for checkins.

The fix is in TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp.  It needs 
to generate an if to skip the marshalling code if TAO_HAS_INTERCEPTORS and 
this is a location forward.

Dale
Comment 5 Nanbor Wang 2003-12-16 14:33:54 CST
Dale, please add your patches to the bugzilla. We can integrate it as soon as the beta is out of the 
door. I think you are on the right track. Adda test case for this. Anyway, during the next stage of 
refactoring we will have to clean this up. 

Talking of this, Jeff we have a problem here irrespective of LF. Marshalling a sequence of strings 
which are not initialized seems to be a problem. We need that fixed. Let me double check that and 
probably add a bugzilla entry if required. 
Comment 6 Nanbor Wang 2003-12-16 14:47:20 CST
Dale, I just registered a new bugzilla entry. I think 1676 is "the" bug to fix, and this would get 
resolved automatically. Nevertheless your patches shuld be useful too
Comment 7 Dale Wilson 2003-12-16 15:47:28 CST
The patch:
Index: operation_ss.cpp
===================================================================
RCS file: /project/cvs-repository/ACE_wrappers-
repository/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp,v
retrieving revision 1.77
diff -r1.77 operation_ss.cpp
680a681,686
>   // Skip marshalling on location forward
>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl
>       << "if (!_tao_vfr.location_forwarded ())" << be_idt_nl
>       << "{" << be_idt;
>   *os << "\n#endif /* TAO_HAS_INTERCEPTORS */"<< be_nl;
>
684a691
>   // begin: marshal code
737a745,755
>
>   // end of indent: marshal code
>   *os << be_uidt << be_uidt;
>
>   // End of scope: Skip marshalling on location forward
>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)
>       << be_uidt_nl << "}" << be_uidt;
>   *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl;

I also have a test program that I'll check in eventually.

------------------------------

Bala,

I disagree that fixing 1676 fixes this bug.  1676 addresses the issue of an 
uninitialized out parameter or return value.  While I agree that SEGV is not a 
very good error message for this case, the correct action is to throw a 
MARSHAL exception.  The application program has provided un-marshable data.  
(I'll add a note to that effect to that bugzilla entry)

If 1676 were fixed correctly, but this fix not applied, then a location 
forward from a portable interceptor would trigger a MARSHAL exception which is 
not the desired behavior.

Dale
Comment 8 Dale Wilson 2003-12-16 16:18:15 CST
oops, I did a little last minute code-polishing before generating the diff.

Add a closing quote at the end of the line:

>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)
to make it
>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)"

Dale

Comment 9 Nanbor Wang 2003-12-16 17:42:44 CST
Dale, coudl you please generate a new diff again? It woudl make my life easier. 

Please see bug 1676 for my replies to your osbervation
Comment 10 Dale Wilson 2003-12-17 09:37:50 CST
Revised diff:

Index: operation_ss.cpp
===================================================================
RCS file: /project/cvs-repository/ACE_wrappers-
repository/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp,v
retrieving revision 1.77
diff -r1.77 operation_ss.cpp
680a681,686
>   // Skip marshalling on location forward
>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl
>       << "if (!_tao_vfr.location_forwarded ())" << be_idt_nl
>       << "{" << be_idt;
>   *os << "\n#endif /* TAO_HAS_INTERCEPTORS */"<< be_nl;
>
684a691
>   // begin: marshal code
737a745,755
>
>   // end of indent: marshal code
>   *os << be_uidt << be_uidt;
>
>   // End of scope: Skip marshalling on location forward
>   *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)"
>       << be_uidt_nl << "}" << be_uidt;
>   *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl;
>
>
>
Comment 11 Dale Wilson 2003-12-26 09:41:01 CST
I'll go ahead and check in this change.  It's been working at OCI for a week.
Comment 12 Dale Wilson 2003-12-29 09:05:38 CST
Fix is checked in.
I still need to clean up and check in the regression test.
Comment 13 Nanbor Wang 2003-12-29 11:08:48 CST
Fixed already

Sun Dec 28 09:55:44 2003  Dale Wilson  <wilson_d@ociweb.com>