Possible memory leak in ML_Epetra::MultiLevelPreconditioner::ComputePreconditioner()
Created by: wfspotz
Testing PyTrilinos with CMAKE_BUILD_TYPE=DEBUG
, I run the test exMLAPI_Simple.py
, get the expected output, and then an exception is thrown during the cleanup phase:
libc++abi.dylib: terminating with uncaught exception of type Teuchos::DanglingReferenceError: /Users/wfspotz/Development/Trilinos/packages/teuchos/core/src/Teuchos_RCPNode.hpp:605
The call stack is
[s1005034:94953] *** Process received signal ***
[s1005034:94953] Signal: Abort trap: 6 (6)
[s1005034:94953] Signal code: (0)
[s1005034:94953] [ 0] 2 libsystem_platform.dylib 0x00007fff8871452a _sigtramp + 26
[s1005034:94953] [ 1] 3 ??? 0x0000000046207930 0x0 + 1176533296
[s1005034:94953] [ 2] 4 libsystem_c.dylib 0x00007fff87e3d6df abort + 129
[s1005034:94953] [ 3] 5 libc++abi.dylib 0x00007fff8f6d4c11 __cxa_bad_cast + 0
[s1005034:94953] [ 4] 6 libc++abi.dylib 0x00007fff8f6fadff_ZL25default_terminate_handlerv + 243
[s1005034:94953] [ 5] 7 libobjc.A.dylib 0x00007fff88b756c3 _ZL15_objc_terminatev + 124
[s1005034:94953] [ 6] 8 libc++abi.dylib 0x00007fff8f6f800e _ZSt11__terminatePFvvE + 8
[s1005034:94953] [ 7] 9 libc++abi.dylib 0x00007fff8f6f8083 _ZSt9terminatev + 51
[s1005034:94953] [ 8] 10 libml.12.dylib 0x000000010beb9d70_ZN9ML_Epetra24MultiLevelPreconditionerD1Ev + 32
[s1005034:94953] [ 9] 11 libml.12.dylib 0x000000010beb9da9_ZN9ML_Epetra24MultiLevelPreconditionerD0Ev + 25
[s1005034:94953] [10] 12 _ML.so 0x000000011131852a_ZN7Teuchos13DeallocDeleteINSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEE4freeEPS5_ + 58
[s1005034:94953] [11] 13 _ML.so 0x000000011135ab90_ZN7Teuchos11RCPNodeTmplIN9ML_Epetra24MultiLevelPreconditionerENS_13DeallocDeleteIS2_EEE10delete_objEv + 112
[s1005034:94953] [12] 14 libteuchoscore.12.dylib 0x000000010f698c95_ZN7Teuchos13RCPNodeHandle9unbindOneEv + 85
[s1005034:94953] [13] 15 _ML.so 0x0000000111310f21_ZN7Teuchos13RCPNodeHandle6unbindEv + 81
[s1005034:94953] [14] 16 _ML.so 0x0000000111310eb1_ZN7Teuchos13RCPNodeHandleD2Ev + 17
[s1005034:94953] [15] 17 _ML.so 0x0000000111310e95_ZN7Teuchos13RCPNodeHandleD1Ev + 21
[s1005034:94953] [16] 18 _ML.so 0x0000000111310e79_ZN7Teuchos3RCPINS_24TimeMonitorSurrogateImplEED2Ev + 25
[s1005034:94953] [17] 19 _ML.so 0x000000011130b8c5_ZN7Teuchos3RCPINS_20CommandLineProcessor20TimeMonitorSurrogateEED1Ev + 21
[s1005034:94953] [18] 20 _ML.so 0x0000000111258c4a_Z37_wrap_delete_MultiLevelPreconditionerP7_objectS0_ + 554
The function _wrap_delete_MultiLevelPreconditioner()
is part of the PyTrilinos wrappers generated by SWIG, the destructor for wrapped MultiLevelPreconditioner
objects.
Playing with the exMLAPI_Simple.py
script, I was able to isolate the source of the dangling reference exception to the following line:
prec.ComputePreconditioner()
where prec
is a MultiLevelPreconditioner
object. So it looks to me like MultiLevelPreconditioner::ComputePreconditioner()
creates some time of dangling reference that Teuchos::RCP
detects when the object is destructed.