Closed sprgchma closed 5 years ago
Thanks for reporting this. I will check it right away. Does the error happen in other Mac OS versions, or only in Yosemite? Can you please do a quick test and use this attached temporary .dylib? test libSoftMeter.dylib.zip
I guess it is because locale for that macbook is non-english. When the region is set to US (at System Prefs->Region&Language->Region) there is no crashing.
OS Version: Mac OS X 10.10.5 (14F2511)
Code Type: X86-64 (Native)
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_c.dylib 0x00007fff99962f72 strlen + 18
1 libSoftMeter.dylib 0x0000000108c894e5 std::__1::char_traits<char>::length(char const*) + 21
2 libSoftMeter.dylib 0x0000000108cd0583 cpccOS::getOSNameVersionAndBuild() + 483
3 libSoftMeter.dylib 0x0000000108ccfef8 cpccOS::getOSNameAndVersion() + 40
4 libSoftMeter.dylib 0x0000000108c92dad cAnalyticsTracker::cAnalyticsTracker(char const*, char const*, char const*, char const*, char const*, char const*, cLicense&) + 3709
5 libSoftMeter.dylib 0x0000000108c8a02f cAnalyticsTracker::cAnalyticsTracker(char const*, char const*, char const*, char const*, char const*, char const*, cLicense&) + 95
6 libSoftMeter.dylib 0x0000000108c88194 cTrackerFactory::create(char const*, char const*, char const*, char const*, char const*, bool, char const*, int) + 932
7 libSoftMeter.dylib 0x0000000108c87d20 start + 592
...
/ Starting selftest:cpccPathHelper_SelfTest
\ Ending selftest:cpccPathHelper_SelfTest
/ Starting selftest:aTest_cpccUrl
\ Ending selftest:aTest_cpccUrl
/ Starting selftest:aTest_NumberXd
\ Ending selftest:aTest_NumberXd
/ Starting selftest:cpccNumberWithBounds_SelfTest
\ Ending selftest:cpccNumberWithBounds_SelfTest
/ Starting selftest:cpccStringUtil_SelfTest
\ Ending selftest:cpccStringUtil_SelfTest
/ Starting selftest:cpccFileSystemMini_SelfTest
\ Ending selftest:cpccFileSystemMini_SelfTest
cpccLogManager constructor
... crash here
Impressive finding! How did you come up with the idea that it is a region related thing? I will try to replicate the problem here. Which region is problematic? I also do not have the US region but the software runs ok.
Oh, step by step:
The region and primary language that macbook is Ukraine and Ukrainian — 'uk_UA' locale.
Application that i testing supports this locale. In other words it has uk.lproj
in the bundle Resources
folder.
Judging from the source of cpccOS::getOSNameVersionAndBuild()
the library uses NSProcessInfo.processInfo.operatingSystemVersionString
property.
For my case the property is Версія 10.10.5 (складення 14F2511)
Then the library calls [... cStringUsingEncoding:NSASCIIStringEncoding] method. Because of cyrillic letters in the version string this method returns NULL.
I could not prepare command line example to demonstrate such behavior — it seems to get non-english version string an application should be Cocoa GUI application with support for a particular locale.
Thanks a lot. Your assumptions are correct. The function that crashes contains the following code (code updated with comments about today's findings):
NSString * operatingSystemVersionString = [[NSProcessInfo processInfo] operatingSystemVersionString];
// returns: Version 10.12.6 (Build 16G29)
// under ukrainian — 'uk_UA' locale it returns:
// Версія 10.10.5 (складення 14F2511)
if (!operatingSystemVersionString)
return "Mac OS X Version ?";
// std::string result = [operatingSystemVersionString cStringUsingEncoding:NSASCIIStringEncoding];
std::string result = [operatingSystemVersionString cStringUsingEncoding : NSUTF8StringEncoding]; // test utf8 enconding as a solution to the crash
result.erase(0, 8); // replace the hardcoded 8 with a find() for "10."
result.insert(0,"Mac OS X ");
return result; // returns: Mac OS X 10.12.6 (Build 16G29)
// todo: change the function to return just the version numbers. No build number ot other text
I needed to rewrite or completely trash this function anyhow. Thanks for the specific string. I will just put it in to force a crash.
can you please test this new dylib? libSoftMeter-test-2.dylib.zip
With this version (test2) the crash gone. Thanks a lot.
great news. Please note that is a debug version. You can use it for your tests. Please give me a couple of days to publish the 0.6.4 release that you can use for your distributed application. Thank you for all your help to spot this problem.
Extract from the crashreport: