discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Problem allocating an NSOperationQueue


From: Lobron, David
Subject: Re: Problem allocating an NSOperationQueue
Date: Tue, 7 Jan 2014 09:52:51 -0500
User-agent: Microsoft-MacOutlook/14.3.8.130913

Hi Fred,

Thank you for your fast reply.

One of my colleagues wrote a simple Hello World program, compiled it in
our gnustep-base environment, and found that it runs as expected.  His
program was:

#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
   NSAutoreleasePool *pool = [NSAutoreleasePool new];

   NSLog(@"Hello world");
   NSOperationQueue *q = [NSOperationQueue new];
   [q release];
   NSLog(@"Done");

   [pool release];

   return 0;
}

This produced:

2014-01-06 22:14:09.100 tmp[4301] Hello world
2014-01-06 22:14:09.101 tmp[4301] Done



I also tried the test suite you mentioned, and it seems to work correctly
for NSOperation (no errors were reported):

--- Running tests in base/NSObject ---
--- Running tests in base/NSOperation ---
--- Running tests in base/NSPointerArray ---

Here is a larger sample of my code, which shows where I first create the
queue.  I've trimmed a few comments, but otherwise this is the exact code
I am running:

<code>
- (void)doAnalysisWithEsLookupTool:(id)esLookupTool
{
  // Look up the AS and country for each IP.
  NSLog(@"Starting analysis of %@, with %u properties", [self domainName],
[[self propertyNames] count]);
    
  NSLog(@"Have %u IPs", [_ips count]);
    
  IPAddress *ip;
  NSEnumerator *e = [_ips objectEnumerator];
  while( (ip = [e nextObject]) != nil ) {
     NSAutoreleasePool *pool = [NSAutoreleasePool new];
        
     EsInfo *ipEsInfo;
     if( [esLookupTool isKindOfClass:[FPBridgeDaemon class]] ) {
        ipEsInfo = [esLookupTool esLookupForIp:ip];
     } else {
        NS_DURING
         ipEsInfo = [esLookupTool lookup:ip];
        NS_HANDLER
         NSLog(@"ES lookup of %@ failed", ip);
         ipEsInfo = nil;
        NS_ENDHANDLER
     }
     if (ipEsInfo == nil) {
       [pool release];
       continue;
     }
        
     [_esInfoForIp setObject:ipEsInfo forKey:ip];
     NSLog(@"ES info for %@: %@", ip, ipEsInfo);
     [pool release];
   }    
    
   // Handle static properties.
   NSLog(@"Generating StaticPropertyInfo object");      
   StaticPropertyInfo *spi = [self staticPropertyInfo:[NSSet
setWithArray:[self propertyNames]]
                                   forDomain:[self domainName]];
   NSLog(@"StaticPropertyInfo completed");
   if( [spi staticPropertyCount] == 0 ) {
       NSLog(@"No static properties in the time interval");
   } else {
       NSLog(@"Analyzed %u static properties", [spi staticPropertyCount]);
       [_spi release];
       _spi = [spi retain];
   }
    

   NSArray *xmlFilesWithTimestamp = [self
getXmlFilesWithTimestampForDomain:[self domainName]
                   
start:[self startDate]
                   
end:[self endDate]];
   NSLog(@"Got response: will parse %u XML files for domain %@, with %u
properties", 
           [xmlFilesWithTimestamp count], [self domainName], [[self
propertyNames] count]);
    
  // Loop through the XML files, and create an NSOperation for each one.
We'll
  // then add those to a queue.  The first queue will have just the first
task,
  // so we can prepopulate large items and avoid duplicate attempts to
repopulate
  // the same item.  Further maps will be professes by the mainOpQueue.
  NSOperationQueue *firstOpQueue = [[NSOperationQueue new] autorelease];
          <--------------- Hang occurs here
  NSOperationQueue *mainOpQueue = [[NSOperationQueue new] autorelease];
  NSMutableArray *ops = [[NSMutableArray new] autorelease];
  NSString *xmlFileWithTimestamp;
  e = [xmlFilesWithTimestamp objectEnumerator];
</code>



The hang occurs on the line where I set firstOpQueue to the result of
"[[NSOperationQueue new] autorelease]".

Please let me know if I can supply any further information- I really
appreciate your help.  One other thing to note is that this is an
Objective-C++ (.mm) file.  The compile commands when I modify just this
file look like this:

Making all for tool fpbridge...
g++ IpDiagSpec.mm -c \
              -MMD -MP -idirafter /usr/include/c++/4.1.3/ext -DGNUSTEP
-DGNUSTEP_BASE_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1
-fno-strict-aliasing -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -Wall
-Werror -Wno-unused -m32 -march=opteron -mno-3dnow -ggdb -O2 -Wall
-fgnu-runtime -fconstant-string-class=NSConstantString
-I/home/dlobron/build/fpbridge_2_12/akamai/common/GNUstep/Local/Library/Hea
ders/ObjectiveC2 -fexec-charset=UTF-8 -I ../common/include -I.
-I/home/dlobron/GNUstep/Library/Headers
-I/home/dlobron/build/fpbridge_2_12/akamai/common/GNUstep/Local/Library/Hea
ders 
-I/home/dlobron/build/fpbridge_2_12/akamai/common/GNUstep/System/Library/He
aders \
               -o obj/fpbridge.obj/IpDiagSpec.mm.o
g++  -rdynamic     -m32  -rdynamic -pthread   -fgnu-runtime -o
obj/fpbridge \
                ./obj/fpbridge.obj/DatacenterView.m.o 
./obj/fpbridge.obj/fpbridge.m.o
./obj/fpbridge.obj/FPBridgeDaemon.m.o ./obj/fpbridge.obj/MapDiff.m.o
./obj/fpbridge.obj/XmlStatsParser.m.o ./obj/fpbridge.obj/DCViewSpec.mm.o
./obj/fpbridge.obj/DiagTools.mm.o ./obj/fpbridge.obj/DsaMessage.mm.o
./obj/fpbridge.obj/EsInfo.mm.o ./obj/fpbridge.obj/FPBridgeSession.mm.o
./obj/fpbridge.obj/HeavyMappingSummary.mm.o
./obj/fpbridge.obj/IpDiagSpec.mm.o ./obj/fpbridge.obj/MapDiffSpec.mm.o
./obj/fpbridge.obj/PingSpec.mm.o
./obj/fpbridge.obj/StaticPropertyInfo.mm.o \
                  -L../common/lib    -L/home/dlobron/GNUstep/Library/Libraries
-L/home/dlobron/build/fpbridge_2_12/akamai/common/GNUstep/Local/Library/Lib
raries 
-L/home/dlobron/build/fpbridge_2_12/akamai/common/GNUstep/System/Library/Li
braries   -lFirstPointKit -lAkamaiKit -lXMLKit -lgtmcidrdbv6 -lcci -lcurl
-lopenssl -lexpat -lmapmessagesdatacenterstate
-lmapmessagesmapmakerheavymappingsummary -lmapdispatch -lmapuuid
-lradtreev6 -lswanslib -lmaputils -lmapfilelog -lakamai -lakautil -lasci
-laks -lcrypto -ldl -lstdc++ -ltcmalloc   -lgnustep-base   -lpthread
-lobjc   -lm


Thank you again,

David



On 1/6/14 5:20 PM, "Fred Kiefer" <fredkiefer@gmx.de> wrote:

>Hi David,
>
>I am no expert on NSOperationQueue others might be of more help here.
>From what I can tell looking at the GNUstep code I would expect that the
>code is hanging in the initialize method of that class. To understand
>this it would be necessary to know where you create this first queue.
>Would it be possible for you to provide the sample code you are using?
>One other thing, there is test code for NSOperation in the GNUstep base
>Test folder. Could you please run this tests and report back the results.
>
>Thank you,
>Fred
>
>On the road
>
>Am 06.01.2014 um 21:57 schrieb "Lobron, David" <dlobron@akamai.com>:
>
>> Hello All,
>> 
>> I wrote some Objective-C code on my Mac that I am now trying to port to
>> Linux.  The code runs correctly on the Mac, and it compiles without a
>> problem on Linux.  I am using gnustep-base-1.24.0 (I know this might be
>> obsolete, but it's what my group is using).
>> 
>> I'm finding that when I try to allocate a new NSOperationQueue object,
>>my
>> program hangs.  The code is simply:
>> 
>> NSOperationQueue *firstOpQueue = [[NSOperationQueue new] autorelease];
>> 
>> I tried separating the alloc and init steps, i.e.,
>> 
>> NSOperationQueue *firstOpQueue = [NSOperationQueue alloc];
>> [firstOpQueue init];
>> 
>> This did not make a difference: the code hung on the call to
>> [NSOperationQueue alloc].  I attached with gdb and printed a stack
>>trace,
>> and it looks like this:
>> 
>> #0  0xf77b3430 in __kernel_vsyscall ()
>> #1  0xf6a13589 in __lll_lock_wait () from
>> /lib/tls/i686/cmov/libpthread.so.0
>> #2  0xf6a0eba6 in _L_lock_95 () from /lib/tls/i686/cmov/libpthread.so.0
>> #3  0xf6a0e58a in pthread_mutex_lock () from
>> /lib/tls/i686/cmov/libpthread.so.0
>> #4  0xf69ff1a4 in __objc_mutex_lock () from /usr/lib/libobjc.so.1
>> #5  0xf69fe9ab in objc_mutex_lock () from /usr/lib/libobjc.so.1
>> #6  0xf69fe51b in objc_msg_lookup () from /usr/lib/libobjc.so.1
>> #7  0xf6bf72fe in -[NSRunLoop(OPENSTEP)
>> performSelector:target:argument:order:modes:] (self=0xa5c3b24,
>> _cmd=0xf6dfb0f8, aSelector=0xf6dfb0e8, target=0x1a9f2ba4,
>>    argument=0x0, order=0, modes=0x1a9f1704) at NSRunLoop.m:1430
>> #8  0xf6c29204 in -[GSRunLoopThreadInfo fire] (self=0xa5c3b84,
>> _cmd=0xf6e2b670) at NSThread.m:1091
>> #9  0xf6cb8ead in -[GSRunLoopCtxt pollUntil:within:] (self=0xa3ea764,
>> _cmd=0xf6def0d0, milliseconds=999, contexts=0xa5c3ae4) at
>> GSRunLoopCtxt.m:605
>> #10 0xf6bf68e2 in -[NSRunLoop acceptInputForMode:beforeDate:]
>> (self=0xa5c3b24, _cmd=0xf6def0f0, mode=0xf6def138, limit_date=0xa7814d4)
>> at NSRunLoop.m:1195
>> #11 0xf6bf5dd3 in -[NSRunLoop runMode:beforeDate:] (self=0xa5c3b24,
>> _cmd=0xf6def100, mode=0xf6def138, date=0xa7814d4) at NSRunLoop.m:1266
>> #12 0xf6bf5a44 in -[NSRunLoop runUntilDate:] (self=0xa5c3b24,
>> _cmd=0xf75ef830, date=0xa7814d4) at NSRunLoop.m:1297
>> 
>> 
>> Does anyone know what I might be doing wrong?  Is this is a bug in the
>> library?
>> 
>> Thank you very much in advance for any help you can provide.
>> 
>> Sincerely,
>> 
>> David Lobron
>> 
>> 
>> _______________________________________________
>> Discuss-gnustep mailing list
>> Discuss-gnustep@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnustep




reply via email to

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