Comments (10)
I see.. maybe it cause from static function (nsregularexpression)
I'll find out the reason and fix it ASAP.
from libphonenumber-ios.
That makes sense. Just after posting this I saw another crash, this time crashing in libicucore:
Thread 9 Crashed:
0 libsystem_kernel.dylib 0x0000000198cc7270 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000198d65170 pthread_kill + 108
2 libsystem_c.dylib 0x0000000198c3eb18 abort + 108
3 libsystem_malloc.dylib 0x0000000198d023e4 nanozone_error + 316
4 libsystem_malloc.dylib 0x0000000198d02550 _nano_malloc_check_clear + 360
5 libsystem_malloc.dylib 0x0000000198d01064 nano_malloc + 40
6 libsystem_malloc.dylib 0x0000000198cf13e4 malloc_zone_malloc + 112
7 libsystem_malloc.dylib 0x0000000198cf5a04 malloc + 52
8 libicucore.A.dylib 0x0000000197f36664 icu::UnicodeSet::UnicodeSet() + 104
9 libicucore.A.dylib 0x0000000197ff8214 icu::RuleBasedTimeZone::getLocalDelta(int, int, int, int, int, int) const + 7076
10 libicucore.A.dylib 0x0000000197ff6afc icu::RuleBasedTimeZone::getLocalDelta(int, int, int, int, int, int) const + 1164
11 libicucore.A.dylib 0x000000019800ecb8 icu::RegexPattern::compile(UText*, unsigned int, UParseError&, UErrorCode&) + 280
12 libicucore.A.dylib 0x000000019804d174 uregex_open + 336
13 Foundation 0x0000000187b79a34 -[NSRegularExpression initWithPattern:options:error:] + 400
14 Foundation 0x0000000187c885d4 +[NSRegularExpression regularExpressionWithPattern:options:error:] + 68
15 WhereToKit 0x00000001005b0948 -[NBPhoneNumberUtil regularExpressionWithPattern:options:error:] (NBPhoneNumberUtil.m:167)
16 WhereToKit 0x00000001005b07bc -[NBPhoneNumberUtil entireRegularExpressionWithPattern:options:error:] (NBPhoneNumberUtil.m:144)
17 WhereToKit 0x00000001005be318 -[NBPhoneNumberUtil matchesEntirely:string:] (NBPhoneNumberUtil.m:3848)
18 WhereToKit 0x00000001005b8c28 -[NBPhoneNumberUtil isNumberMatchingDesc:numberDesc:] (NBPhoneNumberUtil.m:2255)
19 WhereToKit 0x00000001005b890c -[NBPhoneNumberUtil getNumberTypeHelper:metadata:] (NBPhoneNumberUtil.m:2209)
20 WhereToKit 0x00000001005b924c -[NBPhoneNumberUtil getRegionCodeForNumberFromRegionList:regionCodes:] (NBPhoneNumberUtil.m:2377)
21 WhereToKit 0x00000001005b9034 -[NBPhoneNumberUtil getRegionCodeForNumber:] (NBPhoneNumberUtil.m:2350)
22 WhereToKit 0x00000001005b8c7c -[NBPhoneNumberUtil isValidNumber:] (NBPhoneNumberUtil.m:2272)
There was also another active thread in the crash log that had accessed libPhoneNumber before.
Thanks for looking into this.
from libphonenumber-ios.
Thank you. and sorry for "not safe" multile thread issue. :)
from libphonenumber-ios.
Please check with latest code. I removed static NSRegularExpressions.
from libphonenumber-ios.
Thanks. I'll integrate the code and ship the next update with it. Should I see any crashes, I'll let you know!
from libphonenumber-ios.
OK, Thank you very much.
from libphonenumber-ios.
So I shipped the update and received one crash report so far, caused by NBPhoneNumberUtil:
Thread 13 Crashed:
0 libsystem_kernel.dylib 0x0000000195373270 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000195411170 pthread_kill + 108
2 libsystem_c.dylib 0x00000001952eab18 abort + 108
3 libsystem_malloc.dylib 0x00000001953ae3e4 nanozone_error + 316
4 libsystem_malloc.dylib 0x00000001953ae550 _nano_malloc_check_clear + 360
5 libsystem_malloc.dylib 0x00000001953ad064 nano_malloc + 40
6 libsystem_malloc.dylib 0x000000019539d3e4 malloc_zone_malloc + 112
7 libsystem_malloc.dylib 0x00000001953a1a04 malloc + 52
8 libicucore.A.dylib 0x00000001945e2664 icu::UnicodeSet::UnicodeSet() + 104
9 libicucore.A.dylib 0x00000001946a4214 icu::RuleBasedTimeZone::getLocalDelta(int, int, int, int, int, int) const + 7076
10 libicucore.A.dylib 0x00000001946a2afc icu::RuleBasedTimeZone::getLocalDelta(int, int, int, int, int, int) const + 1164
11 libicucore.A.dylib 0x00000001946bacb8 icu::RegexPattern::compile(UText*, unsigned int, UParseError&, UErrorCode&) + 280
12 libicucore.A.dylib 0x00000001946f9174 uregex_open + 336
13 Foundation 0x0000000184225a34 -[NSRegularExpression initWithPattern:options:error:] + 400
14 Foundation 0x00000001843345d4 +[NSRegularExpression regularExpressionWithPattern:options:error:] + 68
15 WhereToKit 0x00000001006184d4 -[NBPhoneNumberUtil regularExpressionWithPattern:options:error:] (NBPhoneNumberUtil.m:167)
16 WhereToKit 0x0000000100618a38 -[NBPhoneNumberUtil replaceStringByRegex:regex:withTemplate:] (NBPhoneNumberUtil.m:242)
17 WhereToKit 0x000000010061a9ac -[NBPhoneNumberUtil extractPossibleNumber:] (NBPhoneNumberUtil.m:530)
18 WhereToKit 0x0000000100624d64 -[NBPhoneNumberUtil buildNationalNumberForParsing:nationalNumber:] (NBPhoneNumberUtil.m:3583)
19 WhereToKit 0x00000001006240f4 -[NBPhoneNumberUtil parseHelper:defaultRegion:keepRawInput:checkRegion:error:] (NBPhoneNumberUtil.m:3391)
20 WhereToKit 0x00000001006239e0 -[NBPhoneNumberUtil parse:defaultRegion:error:] (NBPhoneNumberUtil.m:3251)
Looks like the exact same backtrace. This time, there was no other active thread using NBPhoneNumberUtil, though.
from libphonenumber-ios.
I'm afraid that I can't raise that crash.
Could you tell me your execution environment ?
and, see below... (my test code)
- (NSString *)stringWithRandomNumber
{
NSString *numbers = @"0123456789";
NSMutableString *randomString = [NSMutableString stringWithCapacity:11];
for (int i=0; i<12; i++) {
[randomString appendFormat: @"%C", [numbers characterAtIndex: arc4random() % [numbers length]]];
}
return randomString;
}
- (NSString *)randomRegion
{
NBMetadataHelper *aHelper = [[NBMetadataHelper alloc] init];
NSDictionary *metadata = [[aHelper getAllMetadata] objectAtIndex:(arc4random() % [aHelper getAllMetadata].count)];
if (metadata) {
NSString *region = [metadata objectForKey:@"code"];
if (region) {
return region;
}
}
return nil;
}
- (void)testForMultithread
{
NBPhoneNumberUtil *aUtil = [[NBPhoneNumberUtil alloc] init];
NSString *testRegion = [self randomRegion];
if (!testRegion) {
return;
}
NSLog(@"- START [%@]", testRegion);
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error = nil;
for (int i=0; i<1000; i++) {
[aUtil parse:[self stringWithRandomNumber] defaultRegion:testRegion error:&error];
if (error && ![error.domain isEqualToString:@"INVALID_COUNTRY_CODE"]) {
NSLog(@"error [%@]", [error localizedDescription]);
}
error = nil;
}
NSLog(@"OK [%@]", testRegion);
});
}
- (void)testWithGCD
{
for (int i = 0; i<1000; i++) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self testForMultithread];
});
}
}
from libphonenumber-ios.
I'm creating (and releasing) my NBPhoneNumberUtil
objects on the fly on a background thread. Looking over your tests, it seems you're running -parse:
completely on the main thread, no?
I'll probably have to write some concurrency tests for my use case…
from libphonenumber-ios.
Yes, please show me. I will test it.
from libphonenumber-ios.
Related Issues (20)
- Problem getting correct country code
- 689 area code became valid in 2019 and is not accepted
- isValidNumber returning false for MVNO telecom company prefix for SA
- isValidNumber returning false for NG Area Code +234
- CocoaPods could not find compatible versions for pod "libPhoneNumber-iOS"
- I am getting "invalid number" error even If the number is valid
- Invalid Number Issue for Valid Number
- Phone number validation is not validating for Kuwait in iOS HOT 1
- how to handle errors
- The library doesn't support US number from new area code 572 in Oklahoma HOT 1
- Missing version tags HOT 1
- `isPossibleNumber(withReason...` returns incorrect case for local number
- Invalid Australian phone number HOT 2
- Dallas phone numbers don't work (945) HOT 1
- Xcode 14.3 Analyzer Warnings Related To Assumed Nullability HOT 1
- ERROR in XCode 14.3.1 libarclite_iphoneos.a clang: error: linker command failed with exit code 1
- ERROR in XCode 14.3.1 libarclite_iphoneos.a clang: error: linker command failed with exit code 1 HOT 1
- Missing spec for v1.1 in Cocoapods HOT 5
- In China, mobile numbers starting with "192" (for example: +86 19203868088) might not be recognized as valid phone numbers by standard phone number validation rules. This is because these numbers are often assigned to special services or virtual numbers, rather than regular mobile phone numbers.
- New version?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libphonenumber-ios.