Skip to content

jsonpatch_error() shutdown crash #212

@andysCaplin

Description

@andysCaplin

Hi. I'm getting a weird error trying to catch a jsonpatch_error(). My code is quite simple -

        try {
                    jsoncons::jsonpatch::apply_patch(jsonob->json, delta);
...
            } catch ( std::exception& e ) {
...

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.

#0  0x0000003ae9a325e5 in raise () from /lib64/libc.so.6
#1  0x0000003ae9a33dc5 in abort () from /lib64/libc.so.6
#2  0x0000000000af6e75 in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x0000000000af6a26 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:38
#4  0x0000000000af6a53 in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x0000000000af6bcf in __cxxabiv1::__cxa_pure_virtual () at ../../../../libstdc++-v3/libsupc++/pure.cc:50
#6  0x00000000006a4971 in message (this=<synthetic pointer>) at /usr/include/c++/4.8.5/system_error:158
#7  std::system_error::system_error (this=this@entry=0x7f7e78de5f80, __ec=...) at /usr/include/c++/4.8.5/system_error:316
#8  0x00000000006b431e in jsonpatch_error (ec=..., this=0x7f7e78de5f80, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at ../../libs/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp:19
#9  jsoncons::jsonpatch::apply_patch<jsoncons::basic_json<char, jsoncons::sorted_policy, std::allocator<char> > > (target=...,
    patch=...) at ../../libs/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch.hpp:487

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions