rafaeldimauro / mdcm

Automatically exported from code.google.com/p/mdcm
0 stars 0 forks source link

Mutual recursion between classes Dicom.Implementation and Dicom.Data.DicomUID throws NullReferenceException #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There seems to be a bug due to mutual recursion between
Dicom.Implementation.ClassUID and Dicom.Data.DicomUID.InstanceRootUID.

In detail, here's what happens:

1. Dicom.Implementation.ClassUID is of type DicomUID, and it's a static
field (assigned when the class is first used, right?).

2. Use the class Dicom.Implementation in any way you like. Anything will do,
System.Console.WriteLine(Dicom.Implementation.Version) is enough.

3. This triggers the initialization of the ClassUID field, and to assign
it, a DicomUID instance will be created.

4. As this is the first time we're using DicomUID the static fields should
be set. One of the field is InstanceRootUID which when initialized will
eventually use ClassUID of Dicom.Implementation.

5. Dicom.Implementation.ClassUID is still null, as it's not yet assigned.

6. You will get a NullReferenceException.

This is the callstack, copy'n'pasted from VS:

Dicom.dll!Dicom.Data.DicomUID.Generate(Dicom.Data.DicomUID baseUid = null,
long nextSeq = 114354090805) Line 116
Dicom.dll!Dicom.Data.DicomUID.CreateInstanceRootUID() Line 82
Dicom.dll!Dicom.Data.DicomUID.DicomUID() Line 73
[Native to Managed Transition]  
[Managed to Native Transition]  
Dicom.dll!Dicom.Implementation.Implementation() Line 30

As far as I'm aware, this should be something that all users of the library
should see, and I'm a bit surprised nobody reported this until now?
Or maybe I've confused something... :)

My project using mDCM compiled and could listen to sockets, but when
receiving connections it failed during parsing PDUs.

I'm using the latest SVN Revision 66. I did not have this issue with SVN #64.

Original issue reported on code.google.com by lennart....@vgregion.se on 23 Oct 2009 at 3:05

GoogleCodeExporter commented 8 years ago
Corrected in SVN 67.

Thanks!

Original comment by colby.di...@gmail.com on 3 Nov 2009 at 4:16