Archive for the ‘Memory Visualization’ Category

The Memory Visualization Question from Webinar

Wednesday, September 1st, 2010

If you attended Fundamentals of Complete Crash and Hang Memory Dump Analysis you probably remember the memory dump visualization question that I repeat here on this slide fragment:

I got a few responses:

“Unfortunately they are not identical - visual inspection shows that. I tried differencing the relevant sub-images in Photoshop and I can’t get zero.  Of course this can be due to compression artifacts and, more likely, the fact that the duplication is not required to be aligned to the borders. A stronger confirmation/refutation would require unrolling the bitmap to one dimension and sliding it back and forth until maximum correlation is found. Since I have not done the examples step by step, I am left guessing about just what the dump you show illustrates. An aliased memory mapped area is my first guess, and a flip/flop garbage collector is my second.”

“perhaps some module such as a .NET assembly is getting loaded twice in a .NET app, pre .NET 4, such as is dicsussed in this thread:
http://forum.sysinternals.com/why-some-net-assemblies-are-duplicated-in-memory_topic15279_post121591.html

Initially I also thought that there was the same module loaded twice from different location like in Duplicated Module pattern. Unfortunately lm command didn’t show any duplicated loaded and unloaded modules as well as any hidden modules. So I looked at address information and found two identical relatively large regions at the beginning:

0:000> !address
[...]
BaseAddress EndAddress+1 RegionSize Type       State      Protect       Usage
[...]
0`00470000  0`007f0000   0`00380000 MEM_MAPPED MEM_COMMIT PAGE_READONLY <unclassified>
[…]
0`01f10000  0`02290000   0`00380000 MEM_MAPPED MEM_COMMIT PAGE_READONLY <unclassified>
[…]

The image above was scaled by ImageMagic from a bitmap generated by Dump2Picture:

The original image from Dump2Picture had different colors:

I quickly checked the colorimetric structure of those regions: 0`00470000  0`007f0000 and 0`01f10000  0`02290000 using MemPicture WinDbg script and they seem to conform with the magnified picture above:

0:000> $$>a< d:\Dump2Picture\mempicture.txt 0`00470000 L?0`007f0000-0`00470000
Writing 380000 bytes

C:\Program Files\Debugging Tools for Windows (x64)>dump2picture d2p-range.bin d2p-range.bmp

Dump2Picture version 1.1
Written by Dmitry Vostokov, 2007

d2p-range.bmp
d2p-range.bin
        1 file(s) copied.

C:\Program Files\Debugging Tools for Windows (x64)>d2p-range.bmp
.shell: Process exited

Here is the magnified slice from the original picture:

We see the same partitioning if we juxtapose the original picture and the picture of the address region:

Also these regions are completely identical if we compare their data:

0:000> c 0`00470000 L?(0`007f0000-0`00470000)/8 0`01f10000

So it looks like some file was mapped twice. Inspected via dc command it shows remarkable regularity not seen in executable modules. This regularity also manifests itself in color:

 

In order to verify I modeled this by writing a simple program that maps a file twice passed as a command line parameter:

int _tmain(int argc, _TCHAR* argv[])
{
 if (argc < 2)
 {
  puts("Usage: MappedFiles.exe <File_Name_To_Map>\n");
  return -1;
 }

 HANDLE hf = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 HANDLE hm = CreateFileMapping(hf, NULL, PAGE_READONLY, 0, 0, NULL);
 MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0);

 hf = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 hm = CreateFileMapping(hf, NULL, PAGE_READONLY, 0, 0, NULL);
 MapViewOfFile(hm, FILE_MAP_READ, 0, 0, 0);

 DebugBreak();
 return 0;
}

I ran it and chose to map explorer.exe because it was a sufficiently large image file:

C:\MappedFiles\Release>MappedFiles.exe c:\windows\explorer.exe

The dump file was saved and its processing shows this picture:

 

We clearly see identical regions and double check them from the dump file:

0:000> !address
BaseAddr EndAddr+1 RgnSize Type       State         Protect       Usage
[...]
a60000   d1d000    2bd000  MEM_MAPPED MEM_COMMIT    PAGE_READONLY <unclassified>
d1d000   d20000    3000    MEM_FREE   PAGE_NOACCESS Free
d20000   fdd000    2bd000  MEM_MAPPED MEM_COMMIT    PAGE_READONLY <unclassified>
[…] 

0:000> $$>a< d:\Dump2Picture\mempicture.txt 0`00470000 L?0`007f0000-0`00470000
Writing 380000 bytes

C:\Program Files\Debugging Tools for Windows (x64)>dump2picture d2p-range.bin d2p-range.bmp 

Dump2Picture version 1.1
Written by Dmitry Vostokov, 2007

d2p-range.bmp
d2p-range.bin
        1 file(s) copied.

C:\Program Files\Debugging Tools for Windows (x64)>d2p-range.bmp
.shell: Process exited

 

We see the same partitioning if we juxtapose results:

The application can be downloaded from here: MappedFiles.zip

- Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

Software Glitches as Art

Monday, August 30th, 2010

Just noticed this little book and ordered it to browse and write a review later Glitch: Designing Imperfection

Notice the patterns with glitches on the cover similar to the fabric of memory and some pictures from inside remind me natural memory visualization images you can find in the print form in DLL List Landscape: The Art from Computer Memory Space book. I would therefore welcome the fact that the memory space art has more and more followers (and becomes the true art movement according to the institutional theory of art). There are more art books coming later this year:

  • Patterns of Computer Memory (ISBN: 978-1906717711)

  • Spikes, Hangs, Crashes, Leaks and Dumps of Imagination: The Art of the Debugging Art (ISBN: 978-1906717841)

  • Also the museum of debugging and memory dumps will hold an exhibition soon.

    In a few days the following book about glitches (as negative business impact annoyances) will be released:

    Glitch: The Hidden Impact of Faulty Software

    “Search inside the book” on Amazon suggests that the latter book doesn’t consider the positive impact of glitches including art but, anyway, because of my speciality in software debugging and maintenance I would like to review that book too.

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Hot Computation: Memory On Fire

    Tuesday, August 17th, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Picture Frame for Memory Dumps

    Tuesday, August 17th, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Bleeding Memory

    Thursday, August 12th, 2010

    Under microscope:

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Memory Interfaces

    Thursday, August 12th, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Race Condition in a Kernel Pool

    Wednesday, August 11th, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Virtual to Physical Memory Mapping

    Wednesday, August 11th, 2010

    There are many different approaches to illustrate virtual to physical memory mapping on systems with paging like Windows. Here is another approach that uses natural memory visualization. An image of a user process was generated and juxtaposed to an image of kernel memory dump generated afterwards to produce the combined picture of the full virtual space. Of course, uncommited regions were not included in it as they were not present in user and kernel dumps. Then, after reboot, the same application was launched again and an image of a complete memory dump was generated. Finally, both images were juxtaposed to produce this approximate picture:

    In the virtual memory space to the left we see much more granularity. On the contrary, the physical memory space to the right is more uniform and has a different coloring.

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    The March, 2010 issue of Debugged! MZ/PE is available online

    Monday, August 9th, 2010

    The magazine issue features my article on adjoint threads, the first part of a long article on Windows thread classification, a comparison article on Citrix CDF analysis tools and a review of Advanced .NET Debugging book.

    The issue can be found on either www.debuggingexpert.com or www.debuggingexperts.com:

    http://www.debuggingexperts.com/debugged-march-10

    The print issue will be available in September with the back cover featuring the summary of WinDbg multithreading commands.

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Memory Dump Analysis Services Cap and T-Shirt

    Saturday, July 31st, 2010

    Started testing marketing materials to increase Dublin people awareness of memory dump analysis. Here are the first exemplars of what I’m going to wear by the end of this week while commuting and in local pubs :-)

     

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    User/Kernel Diagramming Styles

    Tuesday, July 27th, 2010

    Similar to different C/C++ styles like where to put the right brace we have User/Kernel Space/Mode architecture diagramming styles. Some prefer to put User part on top (Windows Internals team) and some prefer to put Kernel on top (like me). Marc Sherman in the comment here explains the former style as “calling down into the kernel”. Originally I thought about a psychological explanation where you put on top what you value the most or use the most. However, the reason I put Kernel on top is because I value Space over Mode in depicting memory and dependencies. In stack traces from complete memory dumps you have kernel portions on top as well. Also Google and Bing favour “stack grows down” slightly over “stack grows up” and I prefer “down” as well. Additionally, if you value User on top you would be forced to put Managed on top as well. If you put Kernel on top than Managed is at the bottom like on this flag that became a logo of Memory Dump Analysis Services. So here are two diagrams where I prefer the first (Kernel on top) with any stack growing down (in address decrement sense) and any stack trace from WinDbg having Kernel on top too:

     

    The second diagram has any stack growing up:

    I also suggest this variant (but people who write and read from right to left may prefer its reflection):

    Another diagram style that is consistent with the traditional depiction of Privilege Mode rings (here Kernel is also on top but can be put in any direction):

    What style do you favour? Please let me know.

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Fabric of Memory Dumps

    Monday, July 19th, 2010











    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Can A Memory Dump Be Blue?

    Sunday, July 18th, 2010

    Yes, it can. Here’s the Dump2Picture image of a kernel memory dump (3 GB) from a 128 GB system:

    Now it’s time to listen to Klaus Schulze album In Blue again.

    Buy from Amazon

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Inside A Memory File

    Sunday, July 11th, 2010

    Twitter epoch gives an additional aesthetic dimension to this artwork. 

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Debugging Venue

    Wednesday, July 7th, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Computer Memory Gardens

    Wednesday, June 23rd, 2010

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Museum of Debugging and Memory Dumps

    Wednesday, June 23rd, 2010

    Looks like reading Darwin biography influenced me in the direction of founding a museum. So I did and here’s its draft logo:

    This multi-dimensional museum will show exhibitions dedicated to the history of debugging, memory dump artifacts and art. Stay tuned. The first exhibition opens very soon.

    If you would like to donate an exhibit (for example, an old memory dump or a picture related to debugging) please use this page: http://www.dumpanalysis.org/contact. Any donations are greatly appreciated!

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    MDAAV1-3 Color Supplement has been published!

    Monday, May 10th, 2010

    Previously announced book is now available on Amazon:

    Memory Dump Analysis Anthology: Color Supplement for Volumes 1-3

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Forthcoming Memory Dump Analysis Anthology: Color Supplement for Volumes 1-3

    Friday, April 30th, 2010

    Memory Dump Analysis Anthology lacks full color inserts. This is rather a current limitation of POD technology that OpenTask publisher uses at the present time. The solution previously announced a year ago is to print a separate full color title with selected articles and illustrations. Finally, it is about to be published next month. The book front and back covers are collages from covers of individual memory dump analysis volumes:

    TOC will be available soon. Here is the book data:

    • Title: Memory Dump Analysis Anthology: Color Supplement for Volumes 1-3
    • Author: Dmitry Vostokov
    • Publisher: OpenTask (May 2010)
    • Language: English
    • Product Dimensions: 21.6 x 14.0
    • Paperback: 110 pages
    • ISBN-13: 978-1906717698

    OpenTask also plans a separate color supplement for volumes 4 and 5 once they are published. 

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -

    Memory Map Visualization Tools (Revised)

    Thursday, April 29th, 2010

    Yesterday I discovered the blog j00ru//vx where I was pleased to see another memory visualization approach which I classify as synthetic:

    x86 Kernel Memory Space Visualization (KernelMAP v0.0.1)

    So far now I put a bit more extended (but in no way complete) classification with links (based on my previous blog post where every category is presented in chronological order of my encounter with links):

    1. Synthetic

    2. Natural

    a. Static

    b. Semi-dynamic

    c. Dynamic 

    Please let me know any other approaches or links you know. 

    PS. I’m currently a big fan of artificial evolution and recommend this fantastic full-color book that has good ideas about expression-based visualization:

    The Art of Artificial Evolution: A Handbook on Evolutionary Art and Music (Natural Computing Series)

    Buy from Amazon

    - Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -