-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application get crash calling LDClientSDK_Identify right after system wake up from sleep on Windows 10. #425
Comments
Hello @ngangomsamananda, Thank you for the report. I will see if there is anything I can ascertain from the information you have provided so far. One thing that strikes me as interesting is that the callstack only seems to have information which is likely related to logging. I am curious what the implementation of the log back-end you are using looks like. There isn't anything in the SDK itself that calls LDLogLevel_Name, so I assume you may be calling it during logging? (Though maybe the stack is symbolicating improperly) Thank you, |
we have a global logger similar to
which I have in the sample code. We are not calling any other API except |
@ngangomsamananda In the global logger are you not converting the LDLogLevel, which is part of the signature, to a string? |
If you are converting it, then it means that the calls in the stack could be related to real calls. If you are not, then it for sure means the stack is not providing actionable information. |
To clarify you see that exact stack trace with the stub code, and that stack trace isn't from production code which does more actual work in those methods. |
LDLogLevel is not converting to a string. LDLogLevel in globalLogger is a constant.
|
It is a constant, but a normal implementation would create a string from that constant for the purposes of putting it into a log message. So that your log message can have "info" for instance instead of a number. That is what the |
It may be, due to the way the binary is built, that all the calls inside the SDK are being reported as |
We are using our logging level (info, warning and error). LDLogLevel in globalLogger is use only to get the log level by comparing with. |
Yes, I am using the pre-build DLLs available in the repository. |
We provide 2 DLLs, one which is a multi-threaded debug DLL (/MDd) and one which is a multi-threaded DLL (/MD). I want to verify which of these, and what build configuration your application and any other DLLs are using. One way that things become problematic is, for instance if you are using the non-debug DLL, which links to MSVCRT.lib, with an application linking to MSVCRTD.lib. (Or the opposite a debug DLL with a non-debug configuration). |
There is some behavior different in SDK between MacOS and Windows. I have added that in this ticket. I am wondering why that happened. On MacOS I am not getting crash anymore. FYI, I build the binaries for MacOS myself. |
There was a similar issue which gets on MacOS. But that got resolved by following the suggestion in #385 (comment) |
I am able to produce a crash when a network is not available. Likely network availability may take some time to recover after sleep. I will look into it and let you know. |
Thank you. It was not easy to reproduce for us too. Sometimes nothing happens and sometimes it gets the crash. |
Hello @ngangomsamananda I published a release with a fix for the crash I was able to find. I cannot be completely certain that this was your problem, but it seems likely. https://github.com/launchdarkly/cpp-sdks/releases/tag/launchdarkly-cpp-client-v3.6.3 Please let me know if it resolves your problem. Thank you, |
@kinyoklion Thank you so much. We will try this fix and see if that resolves the issue. |
Hi @kinyoklion, I was testing the sdk v3.6.3 which you had released for the fix. Now it gets crash when the new client-side SDK is construct. The crash happens at |
Hello @ngangomsamananda, I ran your sample code, with just the mobile key changed, and it initialized the client successfully using both the debug and the release versions of the DLLs (when built in the correct configuration.). I would again verify you are using a compatible compiler in exactly the same build configuration as the release DLLs, or to build the DLLs with your configuration. I tested using Visual Studio Community 2022 version 17.10.1. Thank you, |
I will do additional testing running it many times. |
TLS config implementation was fine. Usage was incorrect. |
There is a problem with your example code. The configuration of TLS is happening after the configuration builder is already invalid. It has been consumed by creating the config. You need to configure TLS before building the configuration. Thank you, |
|
@ngangomsamananda Was that crash with the debug version of the library? I see msvcp140d.dll which indicates a debug build, so I again want to validate that the debug DLL is used in debug and the release DLL in release. If it is the release DLL, then use the debug one and we can get a correct stack. This crash is in locking a std::mutex (if you are using the debug version, if you are using the release build it could be anywhere.) Which likely indicates it is either memory corruption (similar to creating the TLS config after the config is no longer valid), or because of something like an ABI mismatch, or potentially initialization order. I can really only act on it if I know that the stack trace can be trusted. The first crash, that started this thread, was from an exception being thrown under a specific condition, which should have been handled by the SDK. At this point I cannot reproduce either. I updated your example to run inside a loop (with the corrected config and without global variables) and executed it continuously for about 5 hours and encountered no issues. |
I also think you should be able to get the debug symbols for msvcp140.dll from Microsoft symbol servers. |
At this point I would do the following. 1.Comment out all but the minimum of configuration. If it runs with this configuration, then incrementally re-add configuration until it doesn't. Then that will either reveal what the problem was (for instance the TLS config initialization order when I did this process.) Or reveal that even the basic configuration has some problem.
The only difference for the SDK version to resolve the identify issue was catching the exception. So whatever else is different is between the version of the DLL you were using and the intermediate releases. So, another possibility is to download a few of those versions and see if one specific one starts crashing. Then we can isolate changes between those. Thank you, |
I have removed and keep only the minimum code still get the crash
The crash started from v3.6.1. v3.6.2 also get the same crash. I had tried v3.6.0 and it works fine. |
I use the debug version of library to see the call stack. It crashes on both release and debug version. |
Hi @ngangomsamananda , I can't see anything in 3.6.1 and 3.6.2 that would introduce an issue. I have noticed a bug in the example. The SDK is not freed. Could you add |
The crash occurs at I am wondering why the same code does not get crash in the version 3.6.0 and the versions released before and it gets crash in v3.6.1, v3.6.2 and v3.6.3. |
Can you remove all of the code after #include <iostream>
#include <launchdarkly/client_side/bindings/c/sdk.h>
#include <launchdarkly/bindings/c/context_builder.h>
#include <launchdarkly/client_side/bindings/c/config/builder.h>
LDClientSDK g_pLDClient = nullptr;
int main()
{
const char* userid = "user_id";
const char* mobile_key = "mob-123-abc";
LDClientConfigBuilder configBuilder = LDClientConfigBuilder_New(mobile_key);
LDClientConfig config;
LDStatus status = LDClientConfigBuilder_Build(configBuilder, &config);
if (!LDStatus_Ok(status)) {
std::cout << "ldcsdk client config builder failed";
}
LDContextBuilder context_builder = LDContextBuilder_New();
LDContextBuilder_AddKind(context_builder, "user", userid);
LDContext context = LDContextBuilder_Build(context_builder);
g_pLDClient = LDClientSDK_New(config, context);
} Please make sure you are performing a totally clean build when testing. Additionally, if you are able, it would help to try building the SDK from source using Lastly, you might trying clicking |
As you have suggested I have tried by removing all the codes after I will try to build the SDK locally from the source and see if that solve the issue. |
Hi @cwaldren-ld I am not getting the crash at |
@cwaldren-ld We are not able to reproduce the crash anymore with the fixed provided in v3.6.3. Thanks |
Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the code in this library. If you're not sure whether the problem you are having is specifically related to this library, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here and clicking "submit a request", or by emailing [email protected].
Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
Describe the bug
Application gets crash calling
LDClientSDK_Identify
right after system wake up from sleep on Windows 10. There was a similar issue on MacOS but I was able to fix that by having a check for Initialize before callingLDClientSDK_Identify
but on Windows the behavior looks different.Difference notice on log between MacOS and Windows:
MacOS:
When system go sleep the internet got disconnected then the SDK reach a timeout after 5-10 minutes after that backing off log started. I also get the status
LDDataSourceStatus_State::LD_DATASOURCESTATUS_STATE_SHUTDOWN
.LDClientSDK_Initialized
is falseWindows
When system go to sleep the internet get disconnected then backing off message started. I don't see reach to timeout log nor
LDDataSourceStatus_State::LD_DATASOURCESTATUS_STATE_SHUTDOWN
.LDClientSDK_Initialized
is true. But callingLDClientSDK_Identify
gets the crash.Note: The crash does not happen all the time sometimes it just works fine but we get quite a number of crashes.
To reproduce
resetNewUserContext(newUserid) is call right after its internet get connected. On MacOS the crash does not happen.
I have done what you have suggested for the MacOS.
Expected behavior
Calling
LDClientSDK_Identify
should not get crash similar to MacOS.I am out of ideas why the crash happened. I am also wondering why there is behavior difference between MacOS and Windows.
Could you provide some suggestion on what I am doing wrong or what I should be doing to avoid the crash?
Logs
This is the call stack of the crash, but I don't get much useful information from it.
SDK version
3.5.0
Language version, developer tools
C++17
OS/platform
Windows 10
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: