bugGNUstep - Bugs: bug #29226, GSFFCallInvocation and structs

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #29226: GSFFCallInvocation and structs

Submitted by:  Manuel Guesdon <mguesdon>
Submitted on:  Sun 14 Mar 2010 02:45:49 PM UTC  
 
Category: Base/FoundationSeverity: 2 - Minor
Item Group: BugStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

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>
Project 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>
Project 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>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 16 Jun 2010 07:13:12 AM UTCCaSOpen/ClosedOpen=>Closed
    Sun 14 Mar 2010 03:47:03 PM UTCCaSSeverity4 - Important=>2 - Minor

    Back to the top


    Powered by Savane 3.1-cleanup1