View Issue Details

IDProjectCategoryView StatusLast Update
0004519Slicer4Module Editorpublic2018-03-15 12:26
Reporterinorton Assigned Topieper  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionno change required 
Product Version 
Target VersionFixed in Version 
Summary0004519: Segfault when using Editor paint tool
Description

Segfault when using Editor paint tool:

<pre>
(lldb) bt

  • thread 0000024, stop reason = EXC_BAD_ACCESS (code=2, address=0x11b715670)
    • frame #0: 0x00007fffd35e5f5a libsystem_platform.dylib_platform_memmove$VARIANT$Haswell + 186 frame 0000001: 0x00007fffd348e42e libsystem_c.dylib__memcpy_chk + 22
      frame 0000002: 0x000000011bf8d596 libvtkIO-9.0.1.dylibflush_pending(strm=0x0000700001134ad0) at deflate.c:547 frame 0000003: 0x000000011bf8cf0b libvtkIO-9.0.1.dylibslicer_zlib_deflate(strm=0x0000700001134ad0, flush=4) at deflate.c:765
      frame 0000004: 0x000000011bf8a2f6 libvtkIO-9.0.1.dylibslicer_zlib_compress2(dest=&quot;UH\x89?H??0&quot;, destLen=0x0000700001134c78, source=&quot;&quot;, sourceLen=5790091168, level=-1) at compress.c:49 frame 0000005: 0x000000011b7156e7 libvtkIO-9.0.1.dylibvtkZLibDataCompressor::CompressBuffer(unsigned char const, unsigned long, unsigned char, unsigned long) + 119
      frame 0000006: 0x00000001516bff61 libvtkSlicerEditorLibModuleLogic.dylibvtkImageStash::Stash(this=0x00000001591dc7a0) at vtkImageStash.cxx:107 frame 0000007: 0x00000001516bf8b9 libvtkSlicerEditorLibModuleLogic.dylibvtkImageStash_ThreadFunction(genericData=0x0000000148f4c740) at vtkImageStash.cxx:66
      frame 0000008: 0x00007fffd35ec93b libsystem_pthread.dylib_pthread_body + 180 frame 0000009: 0x00007fffd35ec887 libsystem_pthread.dylib_pthread_start + 286
      frame 0000010: 0x00007fffd35ec08d libsystem_pthread.dylib`thread_start + 13
      </pre>
Steps To Reproduce

Load MRHead
Go to Editor, use default suggested MRHead-label
Select Paint button, default size
Click in middle of axial slice

Additional Information

I tried reducing the "Editor" paint tool size to 2, still see crash but takes 1-2 seconds instead of immediate

"Segment Editor" paint tool works

macOS 10.12, up-to-date superbuild at 4aa762f94d81448b9890e76793ca0c0579e2640f

TagsNo tags attached.

Activities

pieper

pieper

2018-03-13 17:07

administrator   ~0015551

Interesting - this doesn't happen on my build. Maybe try deleting Slicer-superbuild/VTK* and rebuilding? Does it happen with a nightly build?

inorton

inorton

2018-03-13 17:46

developer   ~0015552

Can't reproduce with nightly. I guess I'll try deleting VTK later and let it build overnight.

By the way, there is a significant lag when moving the cursor in paint mode, even in SlicerPreview release build. The circle freezes and doesn't move again until I stop moving the mouse. I realize Editor isn't really maintained going forward, but the performance is much worse than 4.8.1 so I'm curious about the root cause.

  • in 4.8.1 the Editor paint interaction is about the same responsiveness as Segment Editor paint (except for brief slight hiccups)
  • in SlicerPreview, Segment Editor paint doesn't seem noticeably worse than in 4.8.1
inorton

inorton

2018-03-13 23:24

developer   ~0015553

Last edited: 2018-03-13 23:26

View 5 revisions

Can't reproduce in updated local release build. So I guess it may be specific to debug build.
Looks like the stack is being corrupted in between vtkImageStack::Stash and the call to
zlib_compress2. See frame 4 with garbage source/target and sourceLen=140200226884976.

<pre>
(lldb)
frame 0000006: 0x000000014daf1f61 libvtkSlicerEditorLibModuleLogic.dylibvtkImageStash::Stash(this=0x00007f82e8b88d70) at vtkImageStash.cxx:107 104 vtkIdType scalarSize = size * numPrims; 105 106 unsigned char *p = static_cast&lt;unsigned char *>(scalars->WriteVoidPointer(0, numPrims)); -> 107 this->GetCompressor()->SetCompressionLevel(this->GetCompressionLevel()); 108 vtkUnsignedCharArray* compressedBuffer=this->GetCompressor()->Compress(p, scalarSize); // returns a new buffer that has to be deleted 109 // The compressor allocates space that has the size of an uncompressed volume 110 // and even if it uses less memory the buffer size is not reduced. (lldb) down frame 0000005: 0x0000000121e136e7 libvtkIO-9.0.1.dylibvtkZLibDataCompressor::CompressBuffer(unsigned char const, unsigned long, unsigned char, unsigned long) + 119
libvtkIO-9.0.1.dylibvtkZLibDataCompressor::CompressBuffer: 0x121e136e7 &lt;+119>: cmpl $0x0, %eax 0x121e136ea &lt;+122>: je 0x121e13976 ; &lt;+774> 0x121e136f0 &lt;+128>: movq -0xa0(%rbp), %rax 0x121e136f7 &lt;+135>: movq %rax, -0x58(%rbp) (lldb) frame 0000004: 0x00000001226882f6 libvtkIO-9.0.1.dylibslicer_zlib_compress2(dest="UH\x89?H??0", destLen=0x0000700008c6fc78, source="", sourceLen=140200226884976, level=-1) at compress.c:49
46 err = deflateInit(&stream, level);
47 if (err != Z_OK) return err;
48
-> 49 err = deflate(&stream, Z_FINISH);
50 if (err != Z_STREAM_END) {
51 deflateEnd(&stream);
52 return err == Z_OK ? Z_BUF_ERROR : err;
(lldb)
</pre>

pieper

pieper

2018-03-14 15:41

administrator   ~0015560

I haven't been able to reproduce this with either my own build or with (yesterday's) nightly build.

Also at least on my machine the paint brush performance seems completely normal for both my local build and the nightly. (Window/Level and slice scrolling do have odd delays for me with Qt5, but none of the Editor or Segment Editor effects seem to have problems.

To confirm Isaiah, you consistently get the crash with a Qt5 debug build, right? I'm trying a rebuild of that from scratch.

This code has been in Slicer for a long time, but maybe something is triggered by the updated VTK or use of zlib.

inorton

inorton

2018-03-14 16:41

developer   ~0015561

To confirm Isaiah, you consistently get the crash with a Qt5 debug build, right?

Yes.

I didn't try deleting the VTK build yet. Will let you know if that helps.

pieper

pieper

2018-03-14 17:11

administrator   ~0015563

My mac qt5 debug build (just built from scratch) doesn't crash when I paint. Hopefully the same will work for you.

Regarding the performance issue, I do notice that the circle lags a bit in debug build (but not the recent nightly download) but there isn't a lag while I've got the button down to paint.

pieper

pieper

2018-03-15 11:37

administrator   ~0015569

The nightly mac build from today works and I couldn't replicate the crash there either.

But today I did see the same performance issue with the paint brush circle cursor (not during actual painting).

inorton

inorton

2018-03-15 12:25

developer   ~0015570

I deleted and rebuilt VTK in my debug build last night, and now can't reproduce it.

Issue History

Date Modified Username Field Change
2018-03-13 16:49 inorton New Issue
2018-03-13 16:49 inorton Status new => assigned
2018-03-13 16:49 inorton Assigned To => pieper
2018-03-13 16:54 inorton Description Updated View Revisions
2018-03-13 16:55 inorton Description Updated View Revisions
2018-03-13 17:07 pieper Note Added: 0015551
2018-03-13 17:46 inorton Note Added: 0015552
2018-03-13 23:24 inorton Note Added: 0015553
2018-03-13 23:25 inorton Note Edited: 0015553 View Revisions
2018-03-13 23:25 inorton Note Edited: 0015553 View Revisions
2018-03-13 23:26 inorton Note Edited: 0015553 View Revisions
2018-03-13 23:26 inorton Note Edited: 0015553 View Revisions
2018-03-14 15:41 pieper Note Added: 0015560
2018-03-14 16:41 inorton Note Added: 0015561
2018-03-14 17:11 pieper Note Added: 0015563
2018-03-15 11:37 pieper Note Added: 0015569
2018-03-15 12:25 inorton Note Added: 0015570
2018-03-15 12:26 inorton Status assigned => closed
2018-03-15 12:26 inorton Resolution open => no change required