starmessage / libSoftMeter

Application analytics (software usage analytics) for Windows, MacOS and IOS software
https://www.starmessagesoftware.com/softmeter
Other
50 stars 23 forks source link

Crash in libSoftMeter.dylib 64 bit v0.6.3 during start() #6

Closed sprgchma closed 5 years ago

sprgchma commented 5 years ago

Extract from the crashreport:

Code Type:             X86-64 (Native)
OS Version:            Mac OS X 10.10.5 (14F2511)
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               0x00007fff914a8f72 strlen + 18
1   libSoftMeter.dylib              0x000000010be6a14f cpccOS::getOSNameVersionAndBuild() + 93
2   libSoftMeter.dylib              0x000000010be6a067 cpccOS::getOSNameAndVersion() + 15
3   libSoftMeter.dylib              0x000000010be5d998 cAnalyticsTracker::cAnalyticsTracker(char const*, char const*, char const*, char const*, char const*) + 1426
4   libSoftMeter.dylib              0x000000010be5c681 cTrackerFactory::createWithConsent(char const*, char const*, char const*, char const*, char const*, bool) + 75
5   libSoftMeter.dylib              0x000000010be5c5f2 start + 129
...
starmessage commented 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

sprgchma commented 5 years ago

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
starmessage commented 5 years ago

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.

sprgchma commented 5 years ago

Oh, step by step:

starmessage commented 5 years ago

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.

starmessage commented 5 years ago

can you please test this new dylib? libSoftMeter-test-2.dylib.zip

sprgchma commented 5 years ago

With this version (test2) the crash gone. Thanks a lot.

starmessage commented 5 years ago

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.