Skip to content

-[PKReader setString:] conflict terminates app due to Assertion failure #58

@98B

Description

@98B

Hi,
some designated initializer[s] will setString: and also setStream: properties,
more than once, it seems, and in a way that makes NSAssert(!_stream, @"")
fail in PKReader.

For minimizing the problem description, I had ParserGenApp work on the
following grammar, using defaults, and produce AParser.[hm]:

  a = 'A'
    ;

Then, I ran this command line utility:

#import <Foundation/Foundation.h>
#import <PEGKit/PEGKit.h>
#import "AParser.h"

void startParsing(NSInputStream* input) {
    NSError* report;
    PKParser* simplyA = [[AParser alloc] initWithDelegate:nil];
    [simplyA parseStream:input error:&report];
}

int main(int argc, const char * argv[]) {
    NSData* const pseudoFile = [@"A" dataUsingEncoding:NSUTF8StringEncoding];
    
    @autoreleasepool {
        NSInputStream* input = [NSInputStream inputStreamWithData:pseudoFile];
        startParsing(input);
    }
    return 0;
}

which terminated with backtrace, the second time setString: was called:

  ...
  4   PEGKit  0x0000000100013d1c -[PKReader setString:] + 204
  ...

Following call sequences with breakpoints set at -[PKReader setString:] and
at -[PKReader setStream:] reveals that a stream is set (as expected), and then,
later, another setString:nil effectively asserts the stream to be nil, which it isn't.

Is the above program using the PK-types properly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions