QTKit / QTKitServer malloc error

Discussion in 'Mac Programming' started by jamesheliker, Mar 9, 2011.

  1. jamesheliker macrumors newbie

    Joined:
    Mar 9, 2011
    Location:
    Los Angeles, California
    #1
    Hi All -

    I'm running in to a disturbing failure with QTKit, I have a simple command line utility that trims N number of seconds from the beginning of a QTMovie object, and then writes that QTMovie object back to disk (to a new file).

    The code compiles and runs flawlessly. The executable runs exactly as intended from the command line, provided that I run less than say, 10 instances simultaneously. If additional instances are running, two errors crop up in STDERR:

    Code:
    QTKitServer(94967,0xb038d000) malloc: *** error for object 0xffda: pointer being freed was not allocated 
    *** set a breakpoint in malloc_error_break to debug
    
    Code:
    QTKitServer(95112,0xb0185000) malloc: *** error for object 0x221220: incorrect checksum for freed object - object was probably modified after being freed. 
    *** set a breakpoint in malloc_error_break to debug
    
    This utility is intended to be used with a very large corporate library of media files (all valid Quicktime mov's)
    - and *anywhere from 1 to 1000 instances of the utility running at any one time is absolutely required.*

    The "important code" is below:

    Code:
    NSNumber *yes = [NSNumber numberWithBool:YES];
    NSDictionary *attrbs = [NSDictionary dictionaryWithObjectsAndKeys:
                            inputFilePath, QTMovieFileNameAttribute,
                            yes, QTMovieEditableAttribute,
                            nil];
    
    QTMovie *movie = [[QTMovie alloc] initWithAttributes: attrbs error: nil];
    
    long seconds = strtoull([secondsVal UTF8String], NULL, 0);
    QTTime startTime = QTMakeTime(0, 1);
    QTTime duration = QTMakeTime(seconds, 1);
    
    QTTimeRange range = QTMakeTimeRange(startTime, duration);
    
    [movie deleteSegment: range];
    
    [NSDictionary *writeDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                     yes, QTMovieFlatten,
                                     nil];
    [movie writeToFile: outputFilePath withAttributes: writeDictionary error: nil];
    
    movie = nil;
    [movie release];
    
    Any help or insight would be GREATLY appreciated! :D

    -James Heliker
    james.heliker@gmail.com
     
  2. foidulus, Mar 9, 2011
    Last edited: Mar 9, 2011

    foidulus macrumors 6502a

    Joined:
    Jan 15, 2007
    #2
    I would file a bug with Apple, QTKitServer is actually the name of the process that branches off from QTKit applications that does the actual work(namely because most of QTKit is still really not 64 bit)

    It does a lot of interprocess communication and it could very well be that by having 10 instances of QTKit running at the same time the communication is failing in some fashion and thus the QTKitServer malloc bugs.

    File a report with Apple, include the code and explanation you wrote for this post. You could also try mailing the quicktime api support list, but more than likely all they are going to tell you to do is to file a bug report.
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    This is unlikely related to your problem, but:
    movie = nil;
    [movie release];

    Is going to lead to the object movie was pointing to never getting the release message. This means a leak (though it sounds like the life of a process is processing one movie, then quitting).

    -Lee
     
  4. jamesheliker thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    Location:
    Los Angeles, California
    #4
    Thanks for the replies!

    So short of getting apple to fix it, is there anything I can do in my code to at least catch the error, allowing me to retry without hard failure?


    Also, thanks for the "nil" point(er). :D

    -James Heliker
    james.heliker@gmail.com
     
  5. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #5
    I would check the returns from your functions. does initWithAttributes:error: return a non-nil pointer? Does writeToFile:withAttributes:error return YES or NO when you get this failure? I think your best shot would be checking for this, and hopefully when this failure occurs you can detect it.

    -Lee
     
  6. jamesheliker thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    Location:
    Los Angeles, California
    #6
    I've implemented nil & YES/NO checks on both as you suggested - however both are returning normally even when QTKitServer is failing behind the scenes.

    Since the error is showing up directly from QTKitServer, I'm not sure how else I would attempt to catch additional data?
     
  7. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #7
    Are you running this as x86_64 or i386? Maybe try i386 which may not require using QTKitServer (?).
     

Share This Page