<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">We have R tested with SimpleITK on a number of systems each night. And this morning we have run the tests on several systems, and it is running and passing OK, this was with what every old R version was on the systems</div><div class=""><br class=""></div><div class="">We should focus on getting the tests to pass on your system first. It’s a good sign that you can run the AddCommand with the sitk::Command class. Does the rest of the R tests pass when you run ctest?</div><div class=""><br class=""></div><div class="">I am still suspicious you are not running the latest development version. What is the git hash you are using?</div><div class=""><br class=""></div><div class="">As you were digging into the SimpleITK R code you were on the right track with the ProccessObject::AddCommand and the sitk::Command class. The other two parts you are missing is the RCommand C++ class [1], and the overridden ProcessObject::AddCommand method [2]. These were recently added to SimpleITK since the 0.9 release. You can see that the added procedure wraps the passed callable, into the RCommand class.</div><div class=""><br class=""></div><div class="">HTH,</div><div class="">Brad</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">[1] <a href="https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/R/sitkRCommand.h" class="">https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/R/sitkRCommand.h</a></div><div class="">[2] <a href="https://github.com/SimpleITK/SimpleITK/blob/2ffffba589b24465a09eed1303bbffd6fe3fe18e/Wrapping/R/R.i#L565-L589" class="">https://github.com/SimpleITK/SimpleITK/blob/2ffffba589b24465a09eed1303bbffd6fe3fe18e/Wrapping/R/R.i#L565-L589</a></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 11, 2016, at 3:59 AM, Mathew Guilfoyle <<a href="mailto:mrguilfoyle@gmail.com" class="">mrguilfoyle@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I tried running the code below as suggested - both in RStudio and the terminal - and get the same abort/segfault error.<div class=""><br class=""></div><div class="">Which version of R are you running? - I can install an older version to see if it works.</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 11 Apr 2016, at 01:02, Richard Beare <<a href="mailto:richard.beare@gmail.com" class="">richard.beare@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">This is a long shot, but lets try testing whether it is the R garbage collection causing issues. Modify the test so that every method call result is assigned to a different variable:<br class=""><br class=""></div>e.g.<br class=""><br class=""></div>a1 <- gaussian$SetVariance(2)<br class=""><div style="margin: 0px; font-size: 10px; font-family: Monaco;" class="">a2 <- gaussian$AddCommand( 'sitkStartEvent', f1 )</div><div class=""><div style="margin: 0px; font-size: 10px; font-family: Monaco;" class="">a3 <- gaussian$AddCommand( 'sitkEndEvent', f2 )</div></div><br class=""></div>I was running in a terminal on my mac, with an older version of R.<br class=""><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Apr 11, 2016 at 9:56 AM, Mathew Guilfoyle <span dir="ltr" class=""><<a href="mailto:mrguilfoyle@gmail.com" target="_blank" class="">mrguilfoyle@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Richard<div class=""><br class=""></div><div class="">It seems it must be something specific to my setup. I ran your example and get the same hard abort in Rstudio. Running the example in R.app I get the same error but a somewhat more graceful crash with the following error message:</div><div class=""><br class=""></div><div class=""><span class=""><div class=""><font face="Menlo" class="">gaussian$AddCommand( 'sitkStartEvent', f1 )</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div></span><div class=""><font color="#ff2600" face="Menlo" class=""> *** caught segfault ***</font></div><div class=""><font color="#ff2600" face="Menlo" class="">address 0x7ff511000080, cause 'memory not mapped'</font></div><div class=""><font color="#ff2600" face="Menlo" class=""><br class=""></font></div><div class=""><font color="#ff2600" face="Menlo" class="">Traceback:</font></div><div class=""><font color="#ff2600" face="Menlo" class=""> 1: .Call("R_swig_ProcessObject_AddCommand", self, event, cmd, as.logical(.copy), PACKAGE = "SimpleITK")</font></div><div class=""><font color="#ff2600" face="Menlo" class=""> 2: f(x, ...)</font></div><div class=""><font color="#ff2600" face="Menlo" class=""> 3: gaussian$AddCommand("sitkStartEvent", f1)</font></div><div class=""><font color="#ff2600" face="Menlo" class=""><br class=""></font></div><div class=""><font color="#ff2600" face="Menlo" class="">Possible actions:</font></div><div class=""><font color="#ff2600" face="Menlo" class="">1: abort (with core dump, if enabled)</font></div><div class=""><font color="#ff2600" face="Menlo" class="">2: normal R exit</font></div><div class=""><font color="#ff2600" face="Menlo" class="">3: exit R without saving workspace</font></div><div class=""><font color="#ff2600" face="Menlo" class="">4: exit R saving workspace</font></div><div class=""><br class=""></div><div class="">I have tried the version of SimpleITK built without the version of SWIG you patched to correct the character argument error, again I get the same behaviour. </div><div class=""><br class=""></div><div class="">Bradley - I’m using the latest SimpleITK 0.9 source compiled using the super build on OS X 10.11. I’ve done the build with the supplied SWIG and with a version patched by Richard and available here: <a href="https://github.com/richardbeare/swig.git" target="_blank" class="">https://github.com/richardbeare/swig.git</a>. I’m funning R 3.2.4 in Rstudio IDE.</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On 10 Apr 2016, at 23:17, Bradley Lowekamp <<a href="mailto:brad@lowekamp.net" target="_blank" class="">brad@lowekamp.net</a>> wrote:</div><br class=""><div class=""><div class="">Hello,<br class=""><br class="">I would like to know your environment. <br class=""><br class="">What version of SimpleITK? R? OS? Compiler? Did you use simpleITK's super build? If not what version of SWIG?<br class=""><br class="">Thanks<br class=""><br class=""><blockquote type="cite" class="">On Apr 10, 2016, at 9:46 AM, Mathew Guilfoyle <<a href="mailto:mrguilfoyle@gmail.com" target="_blank" class="">mrguilfoyle@gmail.com</a>> wrote:<br class=""><br class="">Richard<br class=""><br class="">Thanks for the reply. I hadn't appreciated that function being passed in the registration example was a closure. However, in the FiterProgressReporting example it is not a closure. <br class=""><br class="">I have modified my code to be a closure but still get a crash/abort; I have also run the code in the examples themselves verbatim and get the same problem.<br class=""><br class="">Any further ideas on how to get this working?<br class=""><br class="">Cheers <br class=""><br class=""><br class=""><blockquote type="cite" class="">On 10 Apr 2016, at 02:10, Mathew Guilfoyle <<a href="mailto:mrguilfoyle@gmail.com" target="_blank" class="">mrguilfoyle@gmail.com</a>> wrote:<br class=""><br class="">There seems to be a problem with using the $AddCommand function to ImageRegistrationMethod objects in the R wrapping to SimpleITK.<br class=""><br class="">Using R 3.2.4 on OS X 10.11<br class=""><br class="">Example:<br class=""><br class="">f <- function(x){print(x$GetMetricValue())}<br class=""><br class="">registration = ImageRegistrationMethod()<br class=""><br class="">registration$AddCommand(‘sitkIterationEvent’, f(registration))<br class=""><br class="">This last line causes R to abort/hard crash (no error message). This behaviour is irrespective of which event type I use or the function passed as the second argument (e.g. even something simple like print(‘Hello’))<br class=""><br class="">The AddCommand method is inherited from the SimpleITK ProcessObject type. Digging around in the SimpleITK.R file I can see that the ProcessObject$AddCommand method expects a second argument of type ‘_p_itk__simple__Command’.<br class=""><br class="">There is a ‘Command’ method that generates a new object of type ‘_p_itk__simple__Command’. If I pass this resulting object as the second argument to registration$AddCommand then I do not get an error. However, there doesn’t seem to be any way to point the ‘_p_itk__simple__Command’ object to my function or otherwise convert my function to a ‘_p_itk__simple__Command’ type.<br class=""><br class="">The $AddCommand method is used in a couple of example scripts on the SimpleITK site (using it for monitoring a registration and a filter e.g. <a href="https://github.com/SimpleITK/SimpleITK/blob/master/Examples/FilterProgressReporting.R" target="_blank" class="">https://github.com/SimpleITK/SimpleITK/blob/master/Examples/FilterProgressReporting.R</a>) so I don’t know if it was working previously and a bug has been introduced more recently? (the example scripts cause the same error when I run them now)<br class=""></blockquote><br class="">_____________________________________<br class="">Powered by <a href="http://www.kitware.com/" target="_blank" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" target="_blank" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class=""><a href="http://www.kitware.com/products/protraining.php" target="_blank" class="">http://www.kitware.com/products/protraining.php</a><br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class=""><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank" class="">http://www.itk.org/Wiki/ITK_FAQ</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank" class="">http://public.kitware.com/mailman/listinfo/insight-users</a><br class=""></blockquote></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div>_____________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class=""><a href="http://www.kitware.com/products/protraining.php" class="">http://www.kitware.com/products/protraining.php</a><br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class="">http://www.itk.org/Wiki/ITK_FAQ<br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class="">http://public.kitware.com/mailman/listinfo/insight-users<br class=""></div></blockquote></div><br class=""></div></body></html>