discuss-gnustep
[Top][All Lists]
Advanced

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

Undefined methods


From: Stefan Urbanek
Subject: Undefined methods
Date: Fri, 13 Apr 2001 21:11:15 +0200

Hi,

When I executed this code:

#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSObjCRuntime.h>

int main(int argc, const char **argv)
{       
    NSAutoreleasePool *pool;
    NSObject          *obj;

    pool = [NSAutoreleasePool new];
    
    obj = [[NSObject alloc] init];
    
    NSLog(@"Crash here");
    [obj undefinedMessage];
    
    [pool release];
    return 0;
}

I've got segfault and gdb reported this:

(gdb) r
[New Thread 1024 (runnable)]
Apr 13 11:16:19 undefined[13116] Crash here

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (runnable)]
0x4023be49 in objc_skip_type_qualifiers ()
   from
/usr/GNUstep/System/Libraries/ix86/linux-gnu/gnu-gnu-gnu-xgps/libobjc.so.0
(gdb) bt
#0  0x4023be49 in objc_skip_type_qualifiers ()
   from
/usr/GNUstep/System/Libraries/ix86/linux-gnu/gnu-gnu-gnu-xgps/libobjc.so.0
#1  0x401ae204 in GSInvocationCallback (callback_data=0x4023040c, 
    args=0xbffff080) at GSFFCallInvocation.m:363
#2  0x402469ed in __vacall_r ()
   from /usr/GNUstep/System/Libraries/ix86/linux-gnu/libcallback.so.0
#3  0x4016109e in main (argc=1, argv=0xbffff17c, env=0xbffff184)
    at NSProcessInfo.m:518
#4  0x402b3a42 in __libc_start_main () from /lib/libc.so.6


I would like to ask, if this is correct behaviour? I think, that there is
something wrong, because an exception should be raised, when there is no
method. One more question: why there is no gnustep_base_user_main frame? (I've
used --enable-fake-main) When I've set breakpoint on following line, gdb
output was:


15          pool = [NSAutoreleasePool new];
Current language:  auto; currently objective-c
(gdb) bt
#0  gnustep_base_user_main (argc=1, argv=0xbffff17c) at undefined.m:15
#1  0x4016109e in main (argc=1, argv=0xbffff17c, env=0xbffff184)
    at NSProcessInfo.m:518
#2  0x402b3a42 in __libc_start_main () from /lib/libc.so.6
(gdb) 

As you can see, thare is gnustep_base_user_main. This is usual for this crash,
that it breaks the stack and few frames are removed. When this happens in some
method, frame for this method is broken (?) and you can only see frame, that
is 2-3 levels higher. So it is sometimes difficult to find out, where it
really happened, and what caused that (for example, when you make a typo in
source)

When I've added this:

@interface NSObject(UndefinedCategory)
- undefinedMessage;
@end

The behaviour was like expected:

Apr 13 11:21:01 undefined[13160] Crash here
Uncaught exception NSInvalidArgumentException, reason: NSObject does not
recognize undefinedMessage
/usr/GNUstep/System/Tools/opentool: line 191: 13160 Abandon                
$full_toolname "$@"


Is it possible to somehow handle the first situation?

Thank you,

Stefan



reply via email to

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