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

[Python] Image(initialized_from_array) += Image crashes #1114

Closed
cchriste opened this issue Mar 4, 2021 · 9 comments
Closed

[Python] Image(initialized_from_array) += Image crashes #1114

cchriste opened this issue Mar 4, 2021 · 9 comments

Comments

@cchriste
Copy link
Contributor

cchriste commented Mar 4, 2021

At least on Windows, kernel dies at "#### Comparing mean shapes before & after alignment" when trying to add and average Images.

  • it crashes at meanImage += image

Here is the stack trace:

[I 16:01:04.742 NotebookApp] Saving file at /notebooks/tutorials/getting-started-with-grooming-segmentations.ipynb
Windows fatal exception: access violation

Thread 0x00003584 (most recent call first):
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\zmq\utils\garbage.py", line 49 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 926 in _bootstrap_inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 890 in _bootstrap

Thread 0x00001688 (most recent call first):
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\parentpoller.py", line 94 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 926 in _bootstrap_inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 890 in _bootstrap

Thread 0x00002d5c (most recent call first):
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\history.py", line 764 in _writeout_input_cache
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\history.py", line 780 in writeout_cache
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\history.py", line 58 in needs_sqlite
  File "<decorator-gen-16>", line 2 in writeout_cache
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\history.py", line 834 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\history.py", line 58 in needs_sqlite
  File "<decorator-gen-17>", line 2 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 926 in _bootstrap_inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 890 in _bootstrap

Thread 0x00002738 (most recent call first):
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\heartbeat.py", line 100 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 926 in _bootstrap_inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 890 in _bootstrap

Thread 0x00001f54 (most recent call first):
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\selectors.py", line 314 in _select
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\selectors.py", line 323 in select
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\asyncio\base_events.py", line 1750 in _run_once
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\asyncio\base_events.py", line 541 in run_forever
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\platform\asyncio.py", line 199 in start
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\iostream.py", line 76 in _thread_main
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 870 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 926 in _bootstrap_inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\threading.py", line 890 in _bootstrap

Current thread 0x00003b20 (most recent call first):
  File "<ipython-input-55-40ab40512b04>", line 8 in <module>
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\interactiveshell.py", line 3437 in run_code
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\interactiveshell.py", line 3357 in run_ast_nodes
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\interactiveshell.py", line 3166 in run_cell_async
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\async_helpers.py", line 68 in _pseudo_sync_runner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\interactiveshell.py", line 2940 in _run_cell
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\IPython\core\interactiveshell.py", line 2895 in run_cell
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\zmqshell.py", line 539 in run_cell
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\ipkernel.py", line 302 in do_execute
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\gen.py", line 234 in wrapper
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\kernelbase.py", line 538 in execute_request
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\gen.py", line 234 in wrapper
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\kernelbase.py", line 261 in dispatch_shell
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\gen.py", line 234 in wrapper
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\kernelbase.py", line 358 in process_one
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\gen.py", line 775 in run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\gen.py", line 814 in inner
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\ioloop.py", line 741 in _run_callback
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\ioloop.py", line 688 in <lambda>
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\asyncio\events.py", line 88 in _run
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\asyncio\base_events.py", line 1786 in _run_once
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\asyncio\base_events.py", line 541 in run_forever
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\tornado\platform\asyncio.py", line 199 in start
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel\kernelapp.py", line 612 in start
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\traitlets\config\application.py", line 845 in launch_instance
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\site-packages\ipykernel_launcher.py", line 16 in <module>
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\runpy.py", line 85 in _run_code
  File "C:\Users\cam\anaconda3\envs\shapeworks\lib\runpy.py", line 193 in _run_module_as_main
@cchriste
Copy link
Contributor Author

Working on this today. The good news so far is imga += imgb seems to be working. Digging deeper into the specific notebook example now.

@cchriste
Copy link
Contributor Author

cchriste commented Mar 11, 2021

The reason for this failing is a function known to be currently broken. #965
So why did it work in the first place? Memory it copied happened to be there for the copying (i.e., some kind of luck).
Here are some more ways to crash it.
Screen Shot 2021-03-10 at 8 51 47 PM

@cchriste cchriste changed the title [Python] Image += Image crashes [Python] Image(initialized_from_array) += Image crashes Mar 11, 2021
@cchriste
Copy link
Contributor Author

# let's compute the mean shape - note that all images have the same reference
# dimensions so no need to worry about different size images and no need for padding

dims      = refSeg.dims()
meanShapeAfterAlignment = sw.Image(np.zeros((dims[2], dims[1], dims[0]))) # note the flipped dims

for shapeSeg, shapeName in zip(shapeSegList, shapeNames):
    meanShapeAfterAlignment += shapeSeg
    
meanShapeAfterAlignment /= num_samples

is now rewritten as

# let's compute the mean shape - note that all images have the same reference
# dimensions so no need to worry about different size images and no need for padding

dims      = refSeg.dims()
meanShapeAfterAlignment = shapeSetList[0].copy()  # start with a copy of the first shape

# add all the other shapes
for i in range(1, num_samples):
    meanShapeAfterAlignment += shapeSegList[i]
    
# compute their average
meanShapeAfterAlignment /= num_samples

@cchriste cchriste added the QA label Mar 11, 2021
@cchriste
Copy link
Contributor Author

fixed in pull request #1147

@sheryjoe
Copy link
Contributor

@cchriste has this been tested? can we close this issue?

@cchriste
Copy link
Contributor Author

Please see the comment in the #1073. The fix has long been committed, but it's not been built in a release candidate.
It's waiting for RC10 and I'm not sure what else might be holding up creating that.

@sheryjoe
Copy link
Contributor

@akenmorris RC10?

@akenmorris
Copy link
Contributor

I'd like to finalize the ellipsoid before creating RC10. See #1162

@sheryjoe
Copy link
Contributor

@cchriste RC10 is available. Could you start testing?

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

No branches or pull requests

4 participants