Summary: | Typecodes for UNIONs with multiple labels per individual case are generated incorrectly. | ||
---|---|---|---|
Product: | TAO | Reporter: | Simon Massey <sma> |
Component: | IDL Compiler | Assignee: | Simon McQueen <simon.mcqueen> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.1.7 | ||
Hardware: | All | ||
OS: | Windows XP | ||
Attachments: |
A test case for this problem.
Fix for a resource leak under error condition that the test hilights Fix for problem: TAO_IDL/be/be_visitor_typecode/union_typecode.cpp Enhanced Fix for problem: TAO_IDL/be/be_visitor_typecode/union_typecode.cpp |
Description
Simon Massey
2013-02-08 04:18:15 CST
Prismtech reference Jira TAO-69. With the original "normal" union IDL defintion: CORBA::ORB_var orb (CORBA::ORB_init (argc, argv)); CORBA::Object_var codecFactory_obj (orb->resolve_initial_references ("CodecFactory")); IOP::CodecFactory_var codecFactory (IOP::CodecFactory::_narrow (codecFactory_obj)); IOP::Encoding cdr_encoding; cdr_encoding.format = IOP::ENCODING_CDR_ENCAPS; cdr_encoding.major_version = 1; cdr_encoding.minor_version = 2; IOP::Codec_var codec (codecFactory->create_codec (cdr_encoding)); MultiLabelUnion mlu; mlu.mlu_char ('4'); mlu._d (1); CORBA::Any any; any <<= mlu; CORBA::OctetSeq_var messageInCDR = codec->encode (any); CORBA::Any_ptr result = codec->decode (messageInCDR); The above "result" is unusable as the any is corrupt as if the union had used an unknown case label and the data for the '4' is not copied into it. This is due to the $TAO_ROOT/tao/AnyTypeCode/skip.cpp in the TAO_Marshal_Union::skip (tc, InputCDR) function (lines 316-545) doesn't have the correct information from the typecode to decode the correct case. (It would also effect the append.cpp in the same way). I think this is generated from: // TAO_IDL - Generated from // be/be_visitor_typecode/union_typecode.cpp:66 Sorry obviosuly the idl unions above should be: union MultiLabelUnion switch (long) { case 0: case 1: char mlu_char; case 2: double mlu_double; }; and union MultiLabelUnion switch (long) { case 0: char mlu_char; case 1: char mlu_char; case 2: double mlu_double; }; Looks like JacOrb is actually generating the typecode correctly with duplicate members for each label as per Henning and Vinoski's statement. It's just TAO and eORB which isn't. Created attachment 1453 [details]
A test case for this problem.
Added a test case for this problem untar with tar -xzf Bug_4097_Regression.gztar
Created attachment 1454 [details]
Fix for a resource leak under error condition that the test hilights
Line 160 "empty_value" is not actually deleted by the destructor of the "replacement" so the "replacement_safety" auto_ptr is not enough to protect against memory leak of the "empty_value" under error conditions. This diff adds another auto_ptr for the "empty_value".
Problem seems to be from: be/be_visitor_typecode/union_typecode.cpp:174 TAO::be_visitor_union_typecode::visit_cases (be_union * node) see comment at line 214-216. The typecode is not getting generated with all the correct information. Created attachment 1455 [details]
Fix for problem: TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
Test now passes. Typecode for multi-case labels for union type now created correctly by tao_idl compiler.
Created attachment 1456 [details]
Enhanced Fix for problem: TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
Replacing the original as it had a flaw for one of the existing IDL_Tests, this enhanced version corrects that and reduces the amount of static memory required if the default type is aliased.
Reassign because Simon Massey left PT. Simon, what is the status of this? |