discuss-gnustep
[Top][All Lists]
Advanced

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

Re: conformsToProtocol over DO


From: David Ayers
Subject: Re: conformsToProtocol over DO
Date: Tue, 20 Apr 2004 10:23:08 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113

Richard Frith-Macdonald wrote:

On 19 Apr 2004, at 07:45, Philip Mötteli wrote:

Hi


I have a heavy crash, that I do not understand why:
I send from a client program the following message:

    [aUser conformsToProtocol:@protocol(UserProtocol)];


This makes my server crash in

    #2 in +[NSObject conformsToProtocol:aProtocol] at NSObject.m:1286


where the protocol list gives something probably wrong:

    (gdb) print *aProtocol
$3 = {isa = 0x4022c680, protocol_name = 0x0, protocol_list = 0c8165c78, instance_methods = 0x0, class_methods = 0x1}
    (gdb) print *aProtocol->protocol_list
    $2 = {next = 0x40228580, count = 257, list = {0x0}}


Count is surely wrong and the protocol name of the first protocol too.
So the program crashes with somewhere in libc:

    #0 in strcmp () from /lib/i686/libc.so.6
    #1 in -[Protocol conformsTo:] () from /usr/lib/libobjc.so.1
    #2 in +[NSObject conformsToProtocol:] at NSObject.m:1286
    #3 in -[NSObject conformsToProtocol:] at NSObject.m:1309
    #4 in __builtin_avcall () from /usr/lib/libavcall.so.0
    #5 in GSFFCallInvokeWithTargetAndImp at GSFFCallInvocation.m:638
    #6 in callframe_do_call at callframe.m:442
#7 in -[NSConnection(Private) _service:forwardForProxy:] at NSConnection.m:2390 #8 in -[NSConnection(Private) handlePortMessage:] at NSConnection.m:2149
    #9 in -[NSSocketPort handlePortMessage:] at NSSocketPort.m:1712
#10 in -[GSTcpHandle receivedEvent:type:extra:forMode:] at NSSocketPort.m:1021 #11 in -[NSSocketPort receivedEvent:type:extra:forMode:] at NSSocketPort.m:1864
    #12 in -[GSRunLoopCtxt pollUntil:within:] at NSRunLoop.m:835
#13 in -[NSRunLoop acceptInputForMode:beforeDate:] at NSRunLoop.m:1960
    #14 in -[NSRunLoop runMode:beforeDate:] at NSRunLoop.m:2030
    #15 in -[NSRunLoop runUntilDate:] at NSRunLoop.m:2051
    #16 in -[NSRunLoop run] at NSRunLoop.m:2039
    #17 in main (argc=1, argv=0xbffff434) at main.m:62


if I replace the call to -conformsToProtocol: with

    [aUser respondsToSelector:@selector(loginName)]

it works.


Does anybody have an idea, why this crashes? Or why perhaps the protocol is not correctly sent over the wire?


Looking at the source of Protocol in the runtime, it accesses ivars of the other protocol object directly ... so it can't work via a proxy to the remote system ... but the Protocol objects have no coding/decoding to be sent over the wire and no clean interface which could allow you to implement such coding. I've hacked in a solution in NSDistantObject.m which is still rather nasty ... but at least it only
accesses one private ivar.

Doh, now i get what was going on. In fact I don't think the concept of using protocol names is in anyway hacky. Just like class definitions must match so do protocol definitions in my view. Yet I am wondering whether we would want to implement coding/decoding based on the protocol name. (i.e. encode the protocol name and when decoding, lookup the protocol by name and return nil if it doesn't exist in the decoding process.) Does that sound viable?

Cheers,
David




reply via email to

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