bugGNU Octave - Bugs: bug #38159, dicom package: crash on calling...


bug #38159: dicom package: crash on calling dicomwrite function

Submitted by:  None
Submitted on:  Thu 24 Jan 2013 04:21:33 AM UTC  
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: John Donoghue <lostbard>
Originator Name: Chen XinjiaOriginator Email: -unavailable-
Open/Closed: ClosedRelease: other
Operating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Thu 23 Feb 2017 04:45:38 PM UTC, comment #11:

Closing as fixed - dicom 0.2.0 has been released

John Donoghue <lostbard>
Project MemberIn charge of this item.
Wed 01 Feb 2017 05:57:56 PM UTC, comment #10:

Pushed https://sourceforge.net/p/octave/dicom/ci/52d990244724bde98e72483daa001bdba1264421/

Fixes the bugs from comment #5

John Donoghue <lostbard>
Project MemberIn charge of this item.
Thu 24 Jan 2013 03:53:51 PM UTC, comment #9:

I am afraid that dicomwrite is extremely broken. I wrote most of the dicom package, but don't have time to implement dicomwrite. The problem is that I have not been able to find a general way of using the library (gdcm) to write all types of DICOM file. It looks like it would need lots of special cases implemented.

The fact that dicomwrite does not work is documented



I'm really sorry about this. Hopefully a better coder than me will come along and fix this for us.

Andy Buckle <blondandy>
Thu 24 Jan 2013 03:26:16 PM UTC, comment #8:

Thanks for your reply! Although I don't know how to fix the code and build the package (just a user : )).

Hope that it'll be fixed in the next release of the dicom package.

Thu 24 Jan 2013 03:08:27 PM UTC, comment #7:

Sorry about the confusion, the second code post is actually the fixed one.

Michael Goffioul <goffioul>
Project Member
Thu 24 Jan 2013 03:04:46 PM UTC, comment #6:

Reposting the code block with correct formatting:

Michael Goffioul <goffioul>
Project Member
Thu 24 Jan 2013 03:01:43 PM UTC, comment #5:

The bug can be easily identified in dicomwrite.cpp around line 82:

if (3<args.length()) { // no metadata supplied, need to make some
try {
genMinimalMetaData(&w, file);
} catch (std::exception) {
return retval ;
} else { // 3rd arg should be struct to turn into metadata
try {
struct2metadata(&w, file, args(2), trial, 0 /* depth of indent for SQ nesting */);
} catch (std::exception) {
return retval ;

The test in the if-statement is inverted. It should probably be: args.length() < 3

However after fixing that, I get another crash when running: dicomwrite(rand(10), 'test.dcm')

#0 0x00007fffe324c9d1 in Fdicomwrite (args=..., nargout=0) at dicomwrite.cpp:110
#1 0x00007ffff68a6f17 in octave_builtin::do_multi_index_op (this=0x10468c0, nargout=0, args=..., lvalue_list=0x0)

Michael Goffioul <goffioul>
Project Member
Thu 24 Jan 2013 02:50:36 PM UTC, comment #4:

I can reproduce the problem under Linux. Here's the backtrace:

#0 0x00007fffe324ffa8 in octave_value::is_map (this=0x7d4878) at /opt/sw/octave-classdef/include/octave-3.7.1+/octave/../octave/ov.h:561
#1 0x00007fffe324cd6f in struct2metadata (w=0x7fffffffd150, file=0x7d4c60, ov=..., trial=false, sequenceDepth=0) at dicomwrite.cpp:129
#2 0x00007fffe324c8e0 in Fdicomwrite (args=..., nargout=0) at dicomwrite.cpp:90
#3 0x00007ffff68a6f17 in octave_builtin::do_multi_index_op (this=0x1046350, nargout=0, args=..., lvalue_list=0x0)

Michael Goffioul <goffioul>
Project Member
Thu 24 Jan 2013 02:18:00 PM UTC, comment #3:

I don't know if it's a Windows-only problem since I don't have other operating system. However I have the same problem with another Win 7 x64 notebook.

When I run Octave as administrator, the error message

"unable to open `octave-core' for writing..."

indeed changes to

"save to `octave-core' complete".

However, Octave still crashed upon dicomwrite() with segmentation violation.

Thu 24 Jan 2013 12:28:14 PM UTC, comment #2:

It may be significant that you do not have
write permission for the folder in which Octave
is running. This is the reason for the last
line in the Octave out put:
warning: unable to open `octave-core' for writing...

Michael Godfrey <godfrey>
Project Member
Thu 24 Jan 2013 12:24:20 PM UTC, comment #1:

Do you know whether this is a Windows-only problem?

Michael Goffioul <goffioul>
Project Member
Thu 24 Jan 2013 04:21:33 AM UTC, original submission:

Operating system: Win 7 x64
Octave version: 3.6.2 VS2010
Octave Forge packages: dicom-0.1.1 VS2010
(downloaded from http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.2%20for%20Windows%20Microsoft%20Visual%20Studio/)

The dicom package can be loaded successfully, and dicomread or dicominfo function can be called without error. Howevere when the dicomwrite function is called, Octave crashed with error message "segmentation violation" (as in the following texts).

C:\Program Files (x86)\Octave-3.6.2\bin>octave-3.6.2.exe
GNU Octave, version 3.6.2
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.

Octave was configured for "i686-pc-mingw32".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

- Use `pkg list' to see a list of installed packages.
- MSYS shell available (C:\Program Files (x86)\Octave-3.6.2\msys).
- Graphics backend: qt.

octave-3.6.2.exe:1> pkg load dicom
octave-3.6.2.exe:3> dicomwrite(A,"d:/4502721/test.dcm")
panic: Segmentation violation -- stopping myself...
attempting to save variables to `octave-core'...
warning: unable to open `octave-core' for writing...



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by lostbard (Posted a comment)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by blondandy (Posted a comment)
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by goffioul (Posted a comment)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 23 Feb 2017 04:45:38 PM UTClostbardStatusReady For Test=>Fixed
    Wed 01 Feb 2017 05:57:56 PM UTClostbardStatusConfirmed=>Ready For Test
      Assigned toNone=>lostbard
    Thu 04 Jun 2015 02:08:02 AM UTCmtmillerStatusNone=>Confirmed
      Operating SystemMicrosoft Windows=>Any
      SummaryCrashed on calling dicomwrite function=>dicom package: crash on calling dicomwrite function

    Back to the top

    Powered by Savane 3.1-cleanup1