[ITK] [ITK-dev] Insight-developers Digest, Vol 149, Issue 8
Simon Warfield
simon.warfield at childrens.harvard.edu
Tue Sep 20 15:46:02 EDT 2016
It is a bug in the interpolation API.
It doesn't account for the size of the region in which the function
evaluation is done.
Only the point at which an evaluation is done is ever checked in the
hierarchy of code that is called. The points which are evaluated to get
the interpolated value are not checked, and if they are not valid, then
an invalid memory read or segmentation fault occurs.
--Simon
On 9/20/2016 12:00 PM, insight-developers-request at itk.org wrote:
> Send Insight-developers mailing list submissions to
> insight-developers at itk.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_insight-2Ddevelopers&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=WbKAgN9KwXSjz8u0FDu7jhXRlLIeA5UUkqkvHeli9ek&e=
> or, via email, send a message with subject or body 'help' to
> insight-developers-request at itk.org
>
> You can reach the person managing the list at
> insight-developers-owner at itk.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Insight-developers digest..."
>
>
> Today's Topics:
>
> 1.
> itk::LinearInterpolateImageFunction::EvaluateAtContinuousIndex()
> -- what is intended behaviour outside of image? (Steve M. Robbins)
> 2. Re:
> itk::LinearInterpolateImageFunction::EvaluateAtContinuousIndex()
> -- what is intended behaviour outside of image? (D?enan Zuki?)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 19 Sep 2016 16:38:58 -0500
> From: "Steve M. Robbins" <steve at sumost.ca>
> To: ITK developer mailing list <insight-developers at itk.org>
> Cc: elastix at bigr.nl
> Subject: [ITK-dev]
> itk::LinearInterpolateImageFunction::EvaluateAtContinuousIndex() --
> what is intended behaviour outside of image?
> Message-ID: <20160919213858.yx4rb56iie4k7mvm at sumost.ca>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> The doc for this function doesn't make it clear whether the user may
> call it with an index point that lies outside the image or not. I can
> tell you that the code doesn't check the bounds, resulting in
> uninitialized memory reads [1].
>
> My question is: is that a user error or bug in the evaluation
> function?
>
> If I read the ITK 4.8.2 code correctly, it looks like it takes care of
> the lower index bound, but not the upper index bound -- so ITK bug?
>
>
> Thanks,
> -Steve
>
>
> [1] https://urldefense.proofpoint.com/v2/url?u=http-3A__my.cdash.org_viewDynamicAnalysisFile.php-3Fid-3D3780109&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=dAaswv1c2FewCPDUiwr98T1ca9lOmmzukQgitIsrXok&e=
>
> Elastix test suite creates a 2D image of size 10x10, then calls
> the interpolator with coordinates { 12.7, 15.3 }. I believe
> that is the cause of this diagnostic:
>
> UMR ==26834== Invalid read of size 2
> ==26834== at 0x62AE77: itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::EvaluateOptimized(itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::Dispatch<2u> const&, itk::ContinuousIndex<double, 2u> const&) const (itkLinearInterpolateImageFunction.h:172)
> ==26834== by 0x62228A: itk::LinearInterpolateImageFunction<itk::Image<short, 2u>, double>::EvaluateAtContinuousIndex(itk::ContinuousIndex<double, 2u> const&) const (itkLinearInterpolateImageFunction.h:99)
> ==26834== by 0x61C431: bool TestInterpolators<2u>() (itkAdvancedLinearInterpolatorTest.cxx:171)
> ==26834== by 0x616CD2: main (itkAdvancedLinearInterpolatorTest.cxx:279)
>
> (Later, the code does an out-of-image call in 3D as well)
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 801 bytes
> Desc: not available
> URL: <https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_pipermail_insight-2Ddevelopers_attachments_20160919_ed2a4b74_attachment-2D0001.sig&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=7_cM6yi5GMBfxeVRyX9FDCNaXTT_nwTsg01NLa-30j0&e= >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 20 Sep 2016 09:00:24 -0400
> From: D?enan Zuki? <dzenanz at gmail.com>
> To: "Steve M. Robbins" <steve at sumost.ca>
> Cc: "Hans J. Johnson" <hans-johnson at uiowa.edu>, ITK developer mailing
> list <insight-developers at itk.org>, elastix at bigr.nl
> Subject: Re: [ITK-dev]
> itk::LinearInterpolateImageFunction::EvaluateAtContinuousIndex() --
> what is intended behaviour outside of image?
> Message-ID:
> <CAPf2UMS9VXW9UAQ0PwkFNiRHJZNqOwm1C7deyYYF+uZ=g2Gv9g at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi Steve,
>
> this function is not supposed to do bounds checking. Bounds checking can be
> done with IsInsideBuffer(). The commit which introduced the code:
>
> Revision: 6abbc7969a90786c4c73f5d191f634db536c2d1d
> Author: Hans Johnson <hans-johnson at uiowa.edu>
> Date: 2010-08-05 22:35:42
> Message:
> Made USE_OPTIMIZED_REGISTRATION the default
>
>
> The ITK_USE_OPTIMIZED_REGISTRATION is now the default
> behavior. There is no longer another option.
>
> Maybe Hans can explain why the lower bounds are checked but not the upper.
> Otherwise you can try removing them and submitting
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__itk.org_Wiki_ITK_Git_Develop&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=ZfDuSqeuqNURhOT8lNMXJXYMBhp73A4icvZnVrpogxA&e= > a patch Steve.
>
> Regards,
> D?enan
>
> On Mon, Sep 19, 2016 at 5:38 PM, Steve M. Robbins <steve at sumost.ca> wrote:
>
>> Hi,
>>
>> The doc for this function doesn't make it clear whether the user may
>> call it with an index point that lies outside the image or not. I can
>> tell you that the code doesn't check the bounds, resulting in
>> uninitialized memory reads [1].
>>
>> My question is: is that a user error or bug in the evaluation
>> function?
>>
>> If I read the ITK 4.8.2 code correctly, it looks like it takes care of
>> the lower index bound, but not the upper index bound -- so ITK bug?
>>
>>
>> Thanks,
>> -Steve
>>
>>
>> [1] https://urldefense.proofpoint.com/v2/url?u=http-3A__my.cdash.org_viewDynamicAnalysisFile.php-3Fid-3D3780109&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=dAaswv1c2FewCPDUiwr98T1ca9lOmmzukQgitIsrXok&e=
>>
>> Elastix test suite creates a 2D image of size 10x10, then calls
>> the interpolator with coordinates { 12.7, 15.3 }. I believe
>> that is the cause of this diagnostic:
>>
>> UMR ==26834== Invalid read of size 2
>> ==26834== at 0x62AE77: itk::LinearInterpolateImageFunction<itk::Image<short,
>> 2u>, double>::EvaluateOptimized(itk::LinearInterpolateImageFunction<itk::Image<short,
>> 2u>, double>::Dispatch<2u> const&, itk::ContinuousIndex<double, 2u> const&)
>> const (itkLinearInterpolateImageFunction.h:172)
>> ==26834== by 0x62228A: itk::LinearInterpolateImageFunction<itk::Image<short,
>> 2u>, double>::EvaluateAtContinuousIndex(itk::ContinuousIndex<double, 2u>
>> const&) const (itkLinearInterpolateImageFunction.h:99)
>> ==26834== by 0x61C431: bool TestInterpolators<2u>() (
>> itkAdvancedLinearInterpolatorTest.cxx:171)
>> ==26834== by 0x616CD2: main (itkAdvancedLinearInterpolatorTest.cxx:279)
>>
>> (Later, the code does an out-of-image call in 3D as well)
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=Rc4Rwkix_LmsETzhqKvf7Q-kEcFPtKkVb1xzRn5k1B8&e=
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__kitware.com_products_protraining.php&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=Z9xgtbLlbYxa0EsHHoBoxlm_7hRlGiNDxmAo36JDWSg&e=
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.itk.org_Wiki_ITK-5FFAQ&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=r4DOIPoHB1kBr-eH7IGUEB4Bz0c_tjw6UM2TcWf3UE0&e=
>>
>> Follow this link to subscribe/unsubscribe:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_insight-2Ddevelopers&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=WbKAgN9KwXSjz8u0FDu7jhXRlLIeA5UUkqkvHeli9ek&e=
>>
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_pipermail_insight-2Ddevelopers_attachments_20160920_87669e73_attachment-2D0001.html&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=IqLCJKLvdLlRAask4nBb1yqbajH_LGSvGX-5JE1Fdgw&e= >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_insight-2Ddevelopers&d=CwICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=spboX-Qn5Dn-uyspT__O0BtpSEF5erHIiRAwdzSaa_QAQ58afxHcHSMuB76pSgfl&m=HFczLLy-F4uhK-1hDmjBJAGPlMm2sUfpyYm6eA1dNzw&s=WbKAgN9KwXSjz8u0FDu7jhXRlLIeA5UUkqkvHeli9ek&e=
>
>
> ------------------------------
>
> End of Insight-developers Digest, Vol 149, Issue 8
> **************************************************
--
Simon K. Warfield, Ph.D.
Thorne Griscom Chair and Professor of Radiology
Harvard Medical School
Director of Radiology Research
Director Computational Radiology Laboratory
Department of Radiology
Boston Children's Hospital
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-developers
More information about the Community
mailing list