BUG: check if vtrype is not INVALID#2553
BUG: check if vtrype is not INVALID#2553mrc-sys wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
Conversation
|
@mrc-sys Thanks for contributing to ITK 💯 ! Can you please remove commit 4ed3b6f in the branch, as it is a duplicate of the latter b300ae2, this one having the appropriate style for an ITK commit? Thanks ! |
Can you describe me, how to remove the commit? I am happy to get the later commit in the appropriate style.... |
If it´s possible to avoid the crash in a better way, I would prefer the better solution. But for now I have not found this better solution and this segfault is a showstopper for me. |
You should rebase interactively using |
Can this be done in the github web-gui too? |
You'll need to provide us more detail on how to reproduce the segfault. Or simply dump part of the backtrace (eg. 'bt' under gdb). |
I don't know. I use the command line for these tasks. Sorry. |
|
I don't think rebase can be done in GitHub WebUI. But it can be done in e.g. TortoiseGit and |
I will try to reproduce the error again, but I have patched ITK 4.13.1 about 4 years ago (ubuntu 16.04) and the bug popped up again on porting our application to ubuntu 20.04 and ITK 4.13.3. As the patch solved the problem again and the source was not changed in the meantime, I have not tested without the patch again. |
Only access the value of si , if vrtype is not invalid.
|
Addressing style issues |
|
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
|
Reviving this for resolution. I've opened #6185 which carries the same fix forward, addresses @malaterre's CHANGES_REQUESTED concern from this thread, and adds regression-test coverage (a Google Test that demonstrates the crash on What changed vs. this PRThe fix in #6185 lifts the Two regression
@mrc-sys — thanks for spotting and reporting this in 2021. If #6185 looks reasonable to you and the maintainers, this PR can be closed as superseded. |
Adds two regression tests that demonstrate the bug originally reported in PR InsightSoftwareConsortium#2553: when MetaDataDictionary contains a key that parses as a well-formed (group,element) DICOM tag but is not in GDCM's public dictionary (e.g., a private vendor tag, or any custom tag added by ITK clients without a private creator), GDCMImageIO::Write() looks up its VR via gdcm::Dict::GetDictEntry(tag).GetVR() which returns gdcm::VR::INVALID. The downstream call to gdcm::StringFilter::FromString hits the switch's default branch in gdcmStringFilter.cxx, which calls gdcm_assert(0) and terminates the process. These two tests run against the unfixed code and reproduce the crash (EXPECT_NO_THROW fails because the writer dies inside gdcm_assert(0)). They are added in this separate commit so the bisection / regression window is unambiguous. The accompanying COMP commit lifts the gdcm::VR::INVALID detection out of the per-VR dispatch in itkGDCMImageIO.cxx and routes unknown tags through the existing problematicKeys warning channel, after which both tests pass. Adds the first creategoogletestdriver() entry to Modules/IO/GDCM/test/ CMakeLists.txt; subsequent gtests for this module can be appended to ITKIOGDCMGTests. Co-Authored-By: mrc-sys <65188023+mrc-sys@users.noreply.github.com>
GDCMImageIO::Write looks up each MetaDataDictionary entry's DICOM VR via gdcm::Dict::GetDictEntry(tag).GetVR() against the public dictionary. For tags that are not in the public dictionary (private vendor tags, custom client-added tags, typos), the lookup returns gdcm::VR::INVALID. The downstream call to gdcm::StringFilter::FromString in the VRASCII branch hits the switch's default case in gdcmStringFilter.cxx and calls gdcm_assert(0), terminating the host process. PR InsightSoftwareConsortium#2553 (mrc-sys, 2021-05-26) proposed guarding the inner FromString call only, but as Mathieu Malaterre noted in his CHANGES_REQUESTED review, that approach silently writes an empty Data Element to the DICOM header --- masking the symptom rather than fixing the underlying issue. Lift the VR::INVALID check ahead of the per-VR dispatch and route the tag through the existing problematicKeys channel (already used in this function for unrecognized non-DICOM keys). The problematicKeys accumulator emits a single warning at the end of the dictionary iteration listing every unknown key, which is the same UX a typo or a mis-encoded private tag has always produced for ITK clients --- now extended to cover well-formed-(group,element)-but-unknown tags. The two regression tests added in the preceding commit (itkGDCMImageIOInvalidVRTypeGTest.cxx) which crashed against the previous tip now complete cleanly and produce the expected warning. Supersedes PR InsightSoftwareConsortium#2553. Co-Authored-By: mrc-sys <65188023+mrc-sys@users.noreply.github.com>
GDCMImageIO::Write looks up each MetaDataDictionary entry's DICOM VR via gdcm::Dict::GetDictEntry(tag).GetVR() against the public dictionary. For tags that are not in the public dictionary (private vendor tags, custom client-added tags, typos), the lookup returns gdcm::VR::INVALID. The downstream call to gdcm::StringFilter::FromString in the VRASCII branch hits the switch's default case in gdcmStringFilter.cxx and calls gdcm_assert(0), terminating the host process. PR InsightSoftwareConsortium#2553 (mrc-sys, 2021-05-26) proposed guarding the inner FromString call only, but as Mathieu Malaterre noted in his CHANGES_REQUESTED review, that approach silently writes an empty Data Element to the DICOM header --- masking the symptom rather than fixing the underlying issue. Lift the VR::INVALID check ahead of the per-VR dispatch and route the tag through the existing problematicKeys channel (already used in this function for unrecognized non-DICOM keys). The problematicKeys accumulator emits a single warning at the end of the dictionary iteration listing every unknown key, which is the same UX a typo or a mis-encoded private tag has always produced for ITK clients --- now extended to cover well-formed-(group,element)-but-unknown tags. The two regression tests added in the preceding commit (itkGDCMImageIOInvalidVRTypeGTest.cxx) which crashed against the previous tip now complete cleanly and produce the expected warning. Supersedes PR InsightSoftwareConsortium#2553. Co-Authored-By: mrc-sys <65188023+mrc-sys@users.noreply.github.com>
BUG: Fix GDCMImageIO::Write crash on unknown DICOM tags (supersedes #2553)
Adds two regression tests that demonstrate the bug originally reported in PR InsightSoftwareConsortium#2553: when MetaDataDictionary contains a key that parses as a well-formed (group,element) DICOM tag but is not in GDCM's public dictionary (e.g., a private vendor tag, or any custom tag added by ITK clients without a private creator), GDCMImageIO::Write() looks up its VR via gdcm::Dict::GetDictEntry(tag).GetVR() which returns gdcm::VR::INVALID. The downstream call to gdcm::StringFilter::FromString hits the switch's default branch in gdcmStringFilter.cxx, which calls gdcm_assert(0) and terminates the process. These two tests run against the unfixed code and reproduce the crash (EXPECT_NO_THROW fails because the writer dies inside gdcm_assert(0)). They are added in this separate commit so the bisection / regression window is unambiguous. The accompanying COMP commit lifts the gdcm::VR::INVALID detection out of the per-VR dispatch in itkGDCMImageIO.cxx and routes unknown tags through the existing problematicKeys warning channel, after which both tests pass. Adds the first creategoogletestdriver() entry to Modules/IO/GDCM/test/ CMakeLists.txt; subsequent gtests for this module can be appended to ITKIOGDCMGTests. Co-Authored-By: mrc-sys <65188023+mrc-sys@users.noreply.github.com>
GDCMImageIO::Write looks up each MetaDataDictionary entry's DICOM VR via gdcm::Dict::GetDictEntry(tag).GetVR() against the public dictionary. For tags that are not in the public dictionary (private vendor tags, custom client-added tags, typos), the lookup returns gdcm::VR::INVALID. The downstream call to gdcm::StringFilter::FromString in the VRASCII branch hits the switch's default case in gdcmStringFilter.cxx and calls gdcm_assert(0), terminating the host process. PR InsightSoftwareConsortium#2553 (mrc-sys, 2021-05-26) proposed guarding the inner FromString call only, but as Mathieu Malaterre noted in his CHANGES_REQUESTED review, that approach silently writes an empty Data Element to the DICOM header --- masking the symptom rather than fixing the underlying issue. Lift the VR::INVALID check ahead of the per-VR dispatch and route the tag through the existing problematicKeys channel (already used in this function for unrecognized non-DICOM keys). The problematicKeys accumulator emits a single warning at the end of the dictionary iteration listing every unknown key, which is the same UX a typo or a mis-encoded private tag has always produced for ITK clients --- now extended to cover well-formed-(group,element)-but-unknown tags. The two regression tests added in the preceding commit (itkGDCMImageIOInvalidVRTypeGTest.cxx) which crashed against the previous tip now complete cleanly and produce the expected warning. Supersedes PR InsightSoftwareConsortium#2553. Co-Authored-By: mrc-sys <65188023+mrc-sys@users.noreply.github.com>
…-gdcm-invalid-vrtype-crash BUG: Fix GDCMImageIO::Write crash on unknown DICOM tags (supersedes InsightSoftwareConsortium#2553)
BUG: Only access the value of si , if vrtype is not invalid. This prevents a SegmentationFault in the case of an invalid tag
PR Checklist
Refer to the ITK Software Guide for
further development details if necessary.