-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
jsonpatch_error() shutdown crash #212
Comments
Catching a reference to a Updating my earlier reply. From the error message, it appears that you are using gcc 4.8.5. I think this error on termination is related to the fact that the inline
const std::error_category& jsonpatch_error_category()
{
static jsonpatch_error_category_impl instance;
return instance;
} is performed during constant initialization, which can lead to a static deinitialization issue, and which you would most likely observe when using shared libraries. I don't think you would see this error on termination with gcc 4.9 or later. If it's possible for you to check with 4.9, that would be much appreciated. In any case, I'll implement a work around that should work with 4.8. Daniel |
Thank your for replying so quickly. All our build and development machines are on version 4.8.5 - but I'll try to get a machine with 4.9 and update here when I do that. The issue we have is repeatable so I'll be able to verify any fix. I noticed that you created an error_category branch. I'll try testing that today. In response to your earlier question the value of ec at frame 8 ( jsonpatch_error ) is
One more question about this. Do you think that this issue could also have caused the messages to have been misdiagnosed as invalid in the 1st place ? |
Ok - looks like I jumped the gun. I got this compile error using gcc 4.8.5 when I built the new branch you created.
|
Too soon to try error_categry branch :-) |
Yeah -sorry. Got excited. Will try 4.9 if I can get a machine with it installed. |
While comparing Thanks, |
Yes. I'll test today and get back as soon as I have a result. Thanks. |
Sorry, I just found out that we won't be able to test this til next week. As soon as we have tested it - I'll let you know the results. Thanks again for the quick response. |
Sorry but the crash still happens. I double checked the code to make sure that I had the latest changes. I printed the version string in the binary but it's 144 and that hasn't changed for a while. I pulled the latest code today and noticed there are more changes but they don't seem related to the error message issue. I'll test with that as well though and add another note for those results. Here's the stack trace info
|
Finally got a build on Red Hat 6 with a later tool chain containing GCC 8.3.1 and it fixes one of the 2 problems - i.e. the crash. This was with a binary with the original jsoncons i.e. without the fixes you implemented. We still get deltas being misinterpreted as incorrect after shutdown but this is not an issue as we're shutting down anyway so we don't need to process these updates. |
I don't understand what you mean by "We still get deltas being misinterpreted as incorrect after shutdown". I understand that the line
is throwing an exception. But that line has to be executed in order for the exception to be thrown, why is it being executed during shutdown? In what context is this happening? Can you provide an example? Daniel |
Sure. We have various threads processing incoming messages. These messages are
These delta messages are all pretty much identically generated from a bench tool and just the values inside are changing - i.e. the deltas we're receiving are always going to be valid. Up to the point that I shut down no delta messages are logged as being invalid. When I shut down the binary I can see the log for the shutdown and it's immediately followed by multiple logs saying some received deltas are invalid. There is obviously a period after shutdown when the threads processing the incoming messages are still running, the bench tool is still running and pumping deltas up to the binary and we're still receiving messages and processing them before we completely shut down. I can see the content of the "invalid" delta messages in the log and they're definitely valid. For us this isn't such a big issue because it just means we don't process some messages we receive during shutdown and that's not a problem because we're shutting down. The only minor thing is we have to log the error when it occurs but these deltas aren't invalid so it's a little misleading. But we can tell customers to ignore any of these invalid messages if they occur after the shutdown message. The other thing is that since the tool upgrade solved the crash I thought it would solve this as well but like I say it's something we can live with. |
With the latest code from master ( i.e. with the shutdown fix code ) there is a new memory issue. We're catching and logging the JSON patch error and we get this invalid read issue memory issue. Looks like jsoncons::jsonpatch::jsonpatch_error::what() is being deleted as we access it.
The error is all happening on the same line where we log the what() i.e. the ds_log() line of code below
This doesn't happen with the 0.144.0 release. Looks like the message is being deleted before we can use it. |
This is with gcc 4.8, right? And happening during the shutdown process? My first suggestion would be to change the code so that the threads are allowed to stop before the shutdown process begins. That would fix everything. But without that, could you do an experiment? When compiling with gcc 4.8, replace the lines in inline
const std::error_category& jmespath_error_category()
{
static jmespath_error_category_impl instance;
return instance;
} to inline
const std::error_category& jmespath_error_category()
{
static jmespath_error_category_impl* instance = nullptr;
if (instance == nullptr)
{
instance = new jmespath_error_category_impl();
}
return *instance;
} Thanks, |
It's RedHat Developer tool set 8.1, gcc version 8.3.1. I'll try that - cheers. |
Ok, so that didn't fix the invalid read. I changed this code ( couldn't find jmespath_error_category ) jsonpatch_error.hpp
jsonpath_error.hpp
This issue doesn't happen with 0.144.0 |
Okay, I've reverted the The experiment I suggested was only for 4.8. It should have worked around the crash you observed with that compiler during shutdown. |
ohh - sorry. I though that was for the invalid read. |
Fair enough. We don't currently have test coverage for the situation where threads continue after exiting the main thread, which leads to the possibility of issues with order of de-initialization of static data. I think that the crash you observed was the result of gcc 4.8 |
Hi. I'm getting a weird error trying to catch a jsonpatch_error(). My code is quite simple -
I'm assuming that std::exception is ok here - is that correct ?
This code works fine normally but sometimes I'm getting this crash during shutdown.
i.e. It's saying a pure virtual method is being called when the patch errror message is being accessed.
Also, the patch message being processed is not invalid but is being interpreted as invalid.
This seems to happen only when we're shutting down the application.
I noticed that I can call the patch method and pass an errorcode ref and that won't throw an error so I could avoid the crash that way.
The text was updated successfully, but these errors were encountered: