Skip to content
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

Update input refactor #1450

Closed
wants to merge 10 commits into from
Closed

Update input refactor #1450

wants to merge 10 commits into from

Conversation

alliepiper
Copy link
Contributor

@aashish24 @doutriaux1 @sankhesh @chaosphere2112

Done with the update_input refactor and ported the VTK pipeline-related stuff from VTKPlots.update_input into the pipeline classes.

There was a unfinished/nonworking/untested bit of update_input that was for vector plots that gets removed by this PR. I'll push another branch (no PR) shortly and file a bug for this.

I ended up leaving the map returned from pipeline.plot(...) in and just fixed the leaks that were causing the segfaults. Now Canvas.close() must be called in user scripts to avoid the crashes. These can be further refined in the future as needed. See af6eafd and dd81ee3. Once the rest of the leaks that are preventing canvases from cleaning up when going out of scope are cleaned up, this caveat can go away.

vcs2vtk.doWrap is now wrapped in a VTK filter so that it can be called as part of the VTK pipeline execution. See 457c5fd to see how this can be done for other parts of the code that may need it down the road.

Goes with CDAT/uvcdat-testdata#58, as this fixed some bugs and many of the vcs baselines were actually incorrect.

@alliepiper
Copy link
Contributor Author

Looks like there's an issue with the testdata sync. I'll fix this now...

David C. Lonie added 10 commits July 9, 2015 15:41
Otherwise it will reset WIP branches to use master.
Adding this logic to a filter will allow us to setup the pipelines
and simply re-execute them, rather than rebuilding them for each
frame of an animation.
Until the reference cycles that prevent the canvases from being cleaned
up when going out of scope are cleaned up, exiting without closing will
trigger a segfault.
Modified some pipelines to remove SetInputData calls to ensure than
an actual visualization pipeline exists.

It is no longer necessary to rebuild the pipeline between animation steps,
just update the inputs and reexecute it.

This removes a half-finished implementation of update_input for vector
animation. Since it wasn't working / tested, I'll push a separate branch
that contains the ported implementation and adds a test, though there is
still work to be done to get it working.
@alliepiper alliepiper force-pushed the update_input_refactor branch from fab23e8 to b4199e3 Compare July 9, 2015 19:41
@alliepiper
Copy link
Contributor Author

Should be fixed. Works here, we'll see if the buildbot picks it up.

@alliepiper
Copy link
Contributor Author

That did it -- ready for review/testing.

@aashish24
Copy link
Contributor

@dlonie what was the issue with atexit and its callback?

@alliepiper
Copy link
Contributor Author

Registering a bound method with atexit creates a reference to the object.

More concretely, atexit.register(myObject.someMethod) creates a reference to myObject that will persist until the interpreter shuts down. This means that myObject (along everything it holds a reference to) will never have its memory released for the duration of the interpreter's lifetime.

@@ -122,8 +122,6 @@ def __init__(self,vcs_self):
self.renderers = []
self.last_size = None
self.modified_listener = None
import atexit
atexit.register(self.close)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlonie I'm about to test now. But did you check that pngs are now cleared? The reason this was put in is that the del function was never reached hence leaving tons of temporary png file around.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can unregister it in the close function? Anyway I will double check the pngs are removed properly. Maybe I will simply use tempfile module instead in order to make sure the pngs are removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as close is called explicitly, it should behave just as before. The reason __del__ wasn't getting called is likely due to reference leaks -- if there are lingering references due to cycles or atexit registrations, __del__ will never be called since the garbage collector will never be notified to clean the objects up.

+1 for using platform temporary files instead of the home directory.

@doutriaux1
Copy link
Contributor

@dlonie on my ubuntu all animation tests seg fault now. see: https://open.cdash.org/viewTest.php?onlyfailed&buildid=3901832

@doutriaux1
Copy link
Contributor

on my mac all test fail... but I think it's an issue with ctest not picking up the right python. See:
https://open.cdash.org/viewTest.php?onlyfailed&buildid=3901833

@alliepiper
Copy link
Contributor Author

Which version of Ubuntu?

Can you rerun the mac tests in a new shell session? Looks like that should fix that.

@doutriaux1
Copy link
Contributor

python trace back:

Program received signal SIGSEGV, Segmentation fault.
subtype_dealloc (self=0x7fffb75e9c90) at Objects/typeobject.c:955
955     ++ tstate->trash_delete_nesting;
(gdb) bt
#0  subtype_dealloc (self=0x7fffb75e9c90) at Objects/typeobject.c:955
#1  0x00007fffd7b5bc54 in vtkPythonAlgorithm::~vtkPythonAlgorithm (this=0x167fff0, __in_chrg=<optimized out>)
    at /home/doutriaux1/build/build/VTK/Filters/Python/vtkPythonAlgorithm.cxx:49
#2  0x00007fffd7b5bcb0 in vtkPythonAlgorithm::~vtkPythonAlgorithm (this=0x167fff0, __in_chrg=<optimized out>)
    at /home/doutriaux1/build/build/VTK/Filters/Python/vtkPythonAlgorithm.cxx:50
#3  0x00007fffeb9a537d in vtkObjectBase::UnRegisterInternal (this=0x167fff0, check=0)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkObjectBase.cxx:232
#4  0x00007fffeb9a7827 in vtkObject::UnRegisterInternal (this=0x167fff0, o=0x7fffffffda10, check=0)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkObject.cxx:900
#5  0x00007fffeb934484 in vtkGarbageCollectorToObjectBaseFriendship::UnRegister (obj=0x167fff0, from=0x7fffffffda10)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkGarbageCollector.cxx:141
#6  0x00007fffeb932c13 in vtkGarbageCollectorImpl::CollectComponent (this=0x7fffffffda10, c=0x1a29670)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkGarbageCollector.cxx:702
#7  0x00007fffeb931e3c in vtkGarbageCollectorImpl::CollectInternal (this=0x7fffffffda10, root=0x1972fc0)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkGarbageCollector.cxx:473
#8  0x00007fffeb933c29 in vtkGarbageCollector::Collect (root=0x1972fc0)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkGarbageCollector.cxx:904
#9  0x00007fffeb9a5391 in vtkObjectBase::UnRegisterInternal (this=0x1972fc0, check=1)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkObjectBase.cxx:240
#10 0x00007fffeb9a7827 in vtkObject::UnRegisterInternal (this=0x1972fc0, o=0x0, check=1)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkObject.cxx:900
#11 0x00007fffe799d87c in vtkAlgorithm::UnRegister (this=0x1972fc0, o=0x0)
    at /home/doutriaux1/build/build/VTK/Common/ExecutionModel/vtkAlgorithm.cxx:951
#12 0x00007fffeb9a4f98 in vtkObjectBase::Delete (this=0x1972fc0)
    at /home/doutriaux1/build/build/VTK/Common/Core/vtkObjectBase.cxx:134
#13 0x00007fffebde0265 in vtkPythonObjectMap::~vtkPythonObjectMap (this=0xb1cf00, __in_chrg=<optimized out>)
    at /home/doutriaux1/build/build/VTK/Wrapping/PythonCore/vtkPythonUtil.cxx:86
#14 0x00007fffebde06e7 in vtkPythonUtil::~vtkPythonUtil (this=0xb1cec0, __in_chrg=<optimized out>)
    at /home/doutriaux1/build/build/VTK/Wrapping/PythonCore/vtkPythonUtil.cxx:217
#15 0x00007fffebde0506 in vtkPythonUtilDelete ()
    at /home/doutriaux1/build/build/VTK/Wrapping/PythonCore/vtkPythonUtil.cxx:189
#16 0x00007ffff7b00f96 in call_ll_exitfuncs () at Python/pythonrun.c:1769
#17 Py_Finalize () at Python/pythonrun.c:560
#18 0x00007ffff7b17694 in Py_Main (argc=-135784288, argv=0x0) at Modules/main.c:665
#19 0x00007ffff7405a40 in __libc_start_main (main=0x400710 <main>, argc=2, argv=0x7fffffffdf68, init=<optimized out>, 
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf58) at libc-start.c:289

@alliepiper
Copy link
Contributor Author

Yep -- that's the stack from the crash when a VTKPythonAlgorithmBase subclass is leaked. ~vtkPythonAlgorithm calls Py_XDECREF on the python object that represents the algorithm, but the interpreter is gone so the python call crashes.

We might just have to hold off on merging this until the reference leaks are fixed. I'd gotten this working on Arch Linux, but it looks like some of the leaks are platform specific.

@doutriaux1
Copy link
Contributor

same seg fault on mac, plus a few more, see: https://open.cdash.org/viewTest.php?onlyfailed&buildid=3901852

@doutriaux1
Copy link
Contributor

@dlonie ubunutu 15. Also pointed to newer mac test with correct python picked up.

@aashish24
Copy link
Contributor

@doutriaux1 could you please look into these seg fautls as they seem to be related to leaks..

@alliepiper
Copy link
Contributor Author

I'll split this branch up into two branches: one with the bug fixes and another with the last bit of the refactor. We can get the bugfixes in and merge the refactor branch once the memory leaks are cleaned up so that we can start using the VCSPythonAlgorithmBase filters in the pipeline.

@alliepiper alliepiper mentioned this pull request Jul 16, 2015
@aashish24
Copy link
Contributor

@UV-CDAT/developers I am closing this as we have most of the components in master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants