• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSRegularExpression segfault
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSRegularExpression segfault


  • Subject: NSRegularExpression segfault
  • From: ecir hana <email@hidden>
  • Date: Mon, 15 Dec 2014 17:38:30 +0100

Hi!

I recently needed to match some patterns but I encountered a problematic
situation.

Please, can anyone explain to me why does the following program
consistently segfault after 50000 characters? I'm running 10.9.5...

    #import <Cocoa/Cocoa.h>

    int main () {
        NSString *pattern =
@"(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)|(0+)|(a+)";
        NSRegularExpression *expression = [NSRegularExpression
regularExpressionWithPattern:pattern options:0 error:nil];
        for (NSUInteger i = 0; i < 100000; i += 10000) {
            NSString *string = [@"" stringByPaddingToLength:i withString:@"a"
startingAtIndex:0];
            NSTextCheckingResult *result = [expression
firstMatchInString:string options:0 range:NSMakeRange(0, i)];
            NSLog(@"%@", NSStringFromRange([result range]));
        }
        return 0;
    }

It says:

    {0, 0}
    {0, 10000}
    {0, 20000}
    {0, 30000}
    {0, 40000}
    {0, 50000}
    Segmentation fault: 11

Thanks in advance!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: NSRegularExpression segfault
      • From: "Stephen J. Butler" <email@hidden>
    • Re: NSRegularExpression segfault
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: WTF is happening?
  • Next by Date: Re: NSRegularExpression segfault
  • Previous by thread: Re: Replace -lockFocus with Block-Based Drawing Method
  • Next by thread: Re: NSRegularExpression segfault
  • Index(es):
    • Date
    • Thread