bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug] GSFFCallInvocation (was Re: [bugs #8275] gnustep-base-1.9.1: nscon


From: Kazunobu Kuriyama
Subject: [Bug] GSFFCallInvocation (was Re: [bugs #8275] gnustep-base-1.9.1: nsconnection_client fails on win32 using ffcall
Date: Wed, 24 Mar 2004 18:59:39 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1

anonymous wrote:

><snip>
>Summary:  gnustep-base-1.9.1: nsconnection_client fails on win32 using ffcall
>
>Original Submission:  On win32, it's possible to compile gnustep-base with 
>ffcall and libffi using cygwin or MinGW.
>
Even on i686-pc-linux-gnu (32 bit, little endian), -base linked against
ffcall
shows a phenomenon similar to this bug report. As I noticed this phenomenon
about 4 or 5 months ago, I don't think it is specific to -base 1.9.1.

>When using ffcall, the Test nsconnection_client fails on both systems when 
>sending the (large) struct:
>Struct:
>2004-03-23 22:42:11.117 nsconnection_client[3132] File GSFFCallInvocation.m: 
>856
>. In GSInvocationCallback Changed type signature 
>'{_foo=cdi*L}40@0:4{_foo=cdi*L}
>8' to '{_foo=cdi*L}48@4:8{_foo=cdi*L}16' for 'sendStruct:'
>Segmentation fault (core dumped)
>
I noticed a similar one while testing a small server-client program, in
which
the server has a method returning a *small* C structure, and a client
calls it.
As shown in the digits after @, it also added extra 4 bytes to the
structure.
It looks as if -base confused a C structure with an Objective-C object.

A phenomenon similar to the above can be produced without using a
server-client program; the attached small program is for this purpose.

The program has an object called Bar whose delegate is Foo. Bar calls
a Foo's method through -forwardInvocation: when Bar is sent a message
it doesn't know how to deal with.

Interestingly, the phenomenon comes up only when Bar implements
-methodSignatureForSelector. That is, if you commented out
the method, and build and run the program, you will get no
warning.

In my understading, The combination of -forwardInvocation: and
-methodSignatureForSelector: is a standard way of using
-forwardInvocation:. So the resulting warnings are quite annoying.

The program also shows that a similar phenomenon occurs when the return
value is qualified as const. Though the warning itself looks logical,
but I feel it is redundant.

>(This is cygwins output, but except for the last line, MinGWs is similar)
>
Again, this happens with i686-pc-linux-gnu as well.

>nsconnection_client works if the library was compiled with libffi.
>
>nsconnection_server works at least on MinGW.
>
I don't do this comparison on i686-pc-linux-gnu yet.

>
>Thank you, Carl Eugen Hoyos, ce AT hoyos DOT ws
>

Regards,
- Kazunobu Kuriyama
#include <Foundation/Foundation.h>
#include <stdio.h>

// ----------------------------------------------------------------------------
typedef struct _MyPoint {
    int x;
    int y;
} MyPoint;

@interface Foo : NSObject
{
    MyPoint p;
}

- (const char *)fooMethod1;
- (MyPoint)fooMethod2;
@end

@implementation Foo
- (id)init
{
    self = [super init];
    p.x = 12;
    p.y = 34;
    return self;
}

- (const char *)fooMethod1
{
    return "Hello world";
}

- (MyPoint)fooMethod2
{
    return p;
}
@end
// ----------------------------------------------------------------------------
@interface Bar : NSObject
{
    Foo     *delegate;
}
@end

@implementation Bar
- (id)init
{
    self = [super init];
    delegate = [[Foo alloc] init];
    return self;
}

- (void)dealloc
{
    [delegate release];
    [super dealloc];
}

- (void)forwardInvocation: (NSInvocation *)anInvocation
{
    [anInvocation invokeWithTarget: delegate]; 
}

#if 1 // Warnings appear when this method is implemented.
- (NSMethodSignature *)methodSignatureForSelector: (SEL)aSelector
{
    return [delegate methodSignatureForSelector: aSelector];
}
#endif
@end
// ----------------------------------------------------------------------------
int main(int argc, const char *argv[])
{
    NSAutoreleasePool   *pool   = [[NSAutoreleasePool alloc] init];
    id                  bar     = [[Bar alloc] init];

    // File GSFFCallInvocation.m: 856. In GSInvocationCallback Changed type
    // signature 'r*8@0:4' to '*8@0:4' for 'fooMethod1'
    printf("--> %s\n", [bar fooMethod1]);

    // File GSFFCallInvocation.m: 856. In GSInvocationCallback Changed type
    // signature '{_MyPoint=ii}8@0:4' to '{_MyPoint=ii}12@4:8' for
    // 'fooMethod2'
    printf("--> %d %d\n", [bar fooMethod2].x, [bar fooMethod2].y);

    [bar release];
    [pool release];
    return 0;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]