bugGNUstep - Bugs: bug #29226, GSFFCallInvocation and structs

Group
 
 

bug #29226: GSFFCallInvocation and structs

Submitter:  Manuel Guesdon <mguesdon>
Submitted:  Sun 14 Mar 2010 02:45:49 PM UTC
   
 
Category:  Base/Foundation Severity:  2 - Minor
Item Group:  Bug Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 16 Jun 2010 07:13:12 AM UTC, comment #2: 

I'm closing this due to lack of interest.  I'm still willing to apply a patch in case anyone still wants to use ffcall instead of ffi.

Richard Frith-Macdonald <CaS>
Group Member
Sun 14 Mar 2010 03:47:03 PM UTC, comment #1: 

I reclassified this is 'minor', since we are trying to move away from using ffcall at all.
However, if you can supply a patch for this and I'll certainly apply it so that ffcall can work better until the point when it is removed (which won't be until we are pretty confident that all significant platforms have a version of libffi which works at least as well as the version of ffcall available for the same platform).

Richard Frith-Macdonald <CaS>
Group Member
Sun 14 Mar 2010 02:45:49 PM UTC, original submission:  

GSFFCallInvocation has a bug handling structs as parameters.

The following code:
typedef struct _PassingStructStruct
{
  long long int _value;
} PassingStructStruct;
@interface PassingStructObject: NSObject
-(PassingStructStruct)testPassingStruct:(PassingStructStruct)aStruct;
-(PassingStructStruct)testPassingStructReal:(PassingStructStruct)aStruct;
@end
@implementation PassingStructObject
-(PassingStructStruct)testPassingStructReal:(PassingStructStruct)aStruct
{
  NSLog(@"aStruct value=%lld",aStruct._value);
  aStruct._value+=456;
  return aStruct;
}

- (NSMethodSignature *)methodSignatureForSelector: (SEL)selector
{
  NSLog(@"methodSignatureForSelector: %@",NSStringFromSelector(selector));
  if (sel_eq(selector,@selector(testPassingStruct:)))
    return [super methodSignatureForSelector:@selector(testPassingStructReal:)];
  else
    return [super methodSignatureForSelector:selector];
}

- (void)forwardInvocation: (NSInvocation *)invocation
{
  NSLog(@"forward: %@",NSStringFromSelector([invocation selector]));
  if (sel_eq([invocation selector],@selector(testPassingStruct:)))
    [invocation setSelector:@selector(testPassingStructReal:)];
  [invocation invoke];
}

@end

void TestPassingStruct()
{
  PassingStructObject* o=AUTORELEASE([[PassingStructObject alloc]init]);
  PassingStructStruct inStruct;
  inStruct._value=123456789;
  NSLog(@"inStruct value=%lld",inStruct._value);
  PassingStructStruct retStruct=[o testPassingStruct:inStruct];
  NSLog(@"retStruct value=%lld",retStruct._value);
}

produce:
inStruct value=123456789
aStruct value=0
retStruct value=456

instead of
inStruct value=123456789
aStruct value=123456789
retStruct value=123457245

The problem seems to come from GSFFCallInvocation GSInvocationCallback dunction which handle struct as struct pointer but
handle struct as struct in GSFFCallInvokeWithTargetAndImp so the parameter of the called method is wrong

Manuel Guesdon <mguesdon>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by mguesdon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-06-16 CaS Open/ClosedOpen Closed
    2010-03-14 CaS Severity4 - Important 2 - Minor

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code