Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Finalizer Segment Fault #6208

@nealef

Description

@nealef
  1. Application Version: Trunk
  2. redhat 6.5
  3. intel x86
  4. Description:
    Running nunit runner we are getting a segment fault when the nunit running is exiting. After painful debugging of commits to the trunk I found the commit that was causing the problem. It was this one.

be9821f

I commented out the cached_module_cleanup(); and magically the segment faulting went away.

What I found was when nunitrunner was exiting , this method would get executed and in the middle of the executing I noticed the finalizers were running and in our finalizers we do c++ interop calls
To do c++ memory cleanup and its during the c++ cleanup it ends up crashing related to what seems to be happening in the cached_module_cleanup() process.

I put some debugging around the call and this is what I got:

Tests run: 306, Errors: 0, Failures: 0, Inconclusive: 0, Time: 54.5821201 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

11MpiNUnitWrapper MPI Finalize called
1a
Deleting ObjectCatalog...

Still holding on to 11 objects
Segmentation fault (core dumped)
[root@cgy-itsec2 Release]# ls *core*

Note that the message 1a is printed just before the cached_module_cleanup() is called and 2a is called just after. Note there is no 2a message printed and the 'Deleting ObjectCatalog' message
Is coming from c++ and was initiated by one of our c# object finalizers.
So It looks like this cached_module_cleanup() method is getting called and in the middle of it .net finalizers are getting called and somehow this cleanup is messing up the finalizer calls.

My question is shouldnt it wait for the finalizers before doing this cleanup?

This is the dump of the core dump file:

(gdb) backtrace
#0 0x00007f9dd333878b in boost::detail::sp_counted_impl_pd<domainmodel::cppobjectcatalog::ObjectCatalog*, domainmodel::cppobjectcatalog::ObjectCatalog::Deleter>::dispose() ()
from /build/COFLOW/Bin/redhat6/x64/gcc/Release/libDrms.Server.compute.domainmodel.cppobjectcatalog.so
#1 0x00007f9dd3338691 in boost::shared_ptr<domainmodel::cppobjectcatalog::ObjectCatalog>::~shared_ptr() ()
from /build/COFLOW/Bin/redhat6/x64/gcc/Release/libDrms.Server.compute.domainmodel.cppobjectcatalog.so
#2 0x00007f9e1d5a0dba in __cxa_finalize () from /lib64/libc.so.6
#3 0x00007f9dd3336c83 in __do_global_dtors_aux () from /build/COFLOW/Bin/redhat6/x64/gcc/Release/libDrms.Server.compute.domainmodel.cppobjectcatalog.so
#4 0x00007ffc586b5e40 in ?? ()
#5 0x00007f9e1e47d829 in _dl_close_worker () from /lib64/ld-linux-x86-64.so.2
Backtrace stopped: frame did not save the PC

Note that its in the middle of some c++ code that was initiated by a c# objects finalizer when it crashed and the ObjectCatalog::Deleter is doing some cleanup related to some pinned objects on the .net side that are shared with c++.

That's are far as I could go without really knowing what the purpose of this cached_module_cleanup() is and why its happening here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions