Two Windows 8 feature requests

by Miha Markič 19. August 2011 14:43

Microsoft started blogging about Windows 8 (there is twitter account @BuildWindows8 as well) and I started thinking what I’d like to see in Windows 8. I can think of two features right now, out of my head:

  1. Make .net first class development tool. You might say that it is, but in reality it isn’t. Not all APIs are accessible through .net. Just look at (abandoned) Windows® API Code Pack for Microsoft® .NET Framework. Furthermore it is ridden with bugs. There are other APIs requiring black magic to use them from .net. Why are we, .net developers, supposed to mess with that?
  2. Give us a chance to store non-OS essential files on a separate drive. Starting with hibernation file which is as large as your RAM is. More or less. If that is 12GB it means you’ll have to give up 12GB of OS disk space. You might say who cares, 12GB is nothing with current disk prices. Sure, if you don’t look at obscene prices of non-mainstream disks (i.e. SSD) where 12GB matters. A lot. Then there are temporary files, user related documents, etc. A lot of stuff I’d be happy to offload to a cheaper and larger disk. Some of these can be redirected already, but mostly in obscure ways.

That much for now. What do you think?

Tags: ,

Windows | .net

Windows Home Server 2011 restore is just horribly flawed

by Miha Markič 9. June 2011 23:27

I am a long time user of Windows Home Server (first version) and it saved me quite a lot times. Its restore had only one annoying flaw – that is it didn’t properly recognized my Realtek integrated netwok card (instead it tried to use drivers for another version and didn’t let me to select proper ones). So in order to restore I had to put in a recognizable network card and only then it worked. I guess a bit of hardware work here and there isn’t that bad for my strength after all.

Here comes Windows Home Server 2011 and my first restore experience. Initially it started very well, network card was properly recognized and I was happy. But then, oh well. I successfully connected to server and all went well until I had to select the partitions to restore. For beginning the partition letters were mixed up. Luckily I recognized the partitions by their names and their size. I’ve picked only the system partition to restore. When it should start restoring it worked for a minute and then yielded an unknown error has occurred. Gulb. After looking at the end of its log file it was saying that it can’t lock the volume for reason 5. So how come it can’t lock an unused partition. After googling I discovered that I am not the only one with this locking issue (https://connect.microsoft.com/WindowsHomeServer/feedback/details/665345/unable-to-restore-windows-7-client-with-raid-0). The workaround: delete the partition, create the partition and don’t format it. So I did. However, previously the partition was exactly 150,000 MB and now it shrunk to 149,999 MB. One MB shouldn’t make the difference, should it – the partition wasn’t full to the last byte? It turns out that WHS restore is so dumb that it will refuse the restore to this new partition due to the missing MB even though partition was used like 60%. And there is no way to make it bigger because next to this partition is another one and I don’t want to delete is as well. Very stupid and worse than WHS v1 was. Much worse.

So here is my plan now: attach an external disk, restore there, boot from external disk, manually copy the system partition files to original shrunk partition, make it bootable and run as usual. Will I succeed? I certainly hope so.

I am very disappointed in WHS 2011. The half of the key features (backup, restore) is seriously flawed.

Update: Even a non formatted partition can't be locked for some reason. I guess it has something to do with Intel Rapid Storage since the partition in question is a RAID1 one. Don't forget, it worked just fine with previous WHS.

Update2:

Here is the final workaround after a day of trial and errors:

  1. Restore system partition using WHS recovery CD to other (external) disk (I've mounted a spare disk in a Sharkoon dock).
  2. (optional) Again restore system partition to the disk above or some other disk, just to have a untouched copy.
  3. Boot from other disk - system is now bootable but not from original disk.
  4. Delete the original boot partition (the one that WHS can't restore).
  5. Install Acronis Disk Director 11 Home (it isn't free but I bought it just for this purpose and it is well worth it) and copy partition from step 2 (or the from step 1) to the original location (to replace the one you deleted in step 4). This software is required to copy partitions - I guess any partition copy software would do.
  6. Reset and boot the original system.

In case either other disk or original disk isn't bootable anymore you might do one of these:

  1. Boot from Windows 7 CD and try "Startup Repair".
  2. Boot from Windows 7 CD and do the "Custom Installation" on that partition. That will make partition bootable. Once it is bootable repeat the process described above.

I also think I know why WHS can't lock my original partition. It is most probably because it is located on Intel Rapid Storage RAID1. Note that WHS v1 didn't have any problem whatsoever with the same configuration. Bad bad WHS 2011.

I lost a working day and 24€ but at least I restord my workstation. Next time it will be much faster.

Let me know if it works for you.

Update: Here is the issue on connect (thanks to Henk Panneman for re-finding it).

Tags: , , ,

Windows

The long path of installing Windows Home Server 2011 under Hyper-V R2

by Miha Markič 6. June 2011 23:06

Here is my experience of Windows Home Server 2011 aka Vail installation under Hyper-V R2 server (Core2 Duo E7600, 8GB RAM, 500GB RAID 1 and 3TB RAID5). What could have gone wrong it actually went but let’s go by steps.

  1. During file copy at the very beginning I was experiencing couldn’t copy file XY. Problem: corrupt ISO file I was using. Solution: re-download the file.
  2. The setup make it further but I started experiencing random reboots and BSODs during install, this time it was happening soon after initial files copy finished. On the bright side I caught few of them and they were mostly mentioning memory corruption. Time for memtest86+ and for RAM test. It turned out that one of four Patriot DDR2 2GB CAS6 memory sticks was bad. Solution: Throw out the problematic stick and run the server with three sticks. Also donated to memtest86+, well deserved.
  3. Memory issues were still present during setup. Argh.  Solution: Throw out the third memory stick (they like to work in pair it seems and a pair and a third wheel obviously isn’t something one should use) and replaced it with two older 1GB sticks I had collecting dust.
  4. I’ve made it to the step when setup says “Waiting for installation to continue” and shows a marquee progress bar. Except it didn’t finish. Ever. Now what. After peeking into log files located at C:\Users\All Users\Microsoft\Windows Server\Logs I’ve more or less soon understood that it has something to do with the “waiting for a web page to show”. After more digging I’ve found out that there were problems connecting to the internet and the internal web page wasn’t showing. Problem: the network card didn’t get an address from my DHCP for some reason. Solution: I’ve set a fixed IP and DNS records.
    Hint: Type Ctrl+Alt+End to simulate Ctrl+Alt+Del from Hyper-V client. Pick Start Task Manager and File/Run. Run explorer.exe and you can browse around the file system.

It took me a couple of days to make it through but at least I did it. Hura. It took me that much because I was installing on a 1TB VHD disk on a RAID5 array and setup takes time each retry.

So, that’s it. Now it looks fine.

Tags: , , ,

Windows

Jinxing your application

by Miha Markič 26. October 2009 13:22

If you ever wrote a multithreading application you should understand how hard is to get it right. If you don’t understand it then your application most probably isn’t written correctly.

You’ve written a multithreaded application and now what. How can you test it whether it is written correctly or not. Unit testing won’t be of great help because there are complex currency issues that might manifest in a bug only under certain circumstances. Imagine this piece of code:

class Program
{
    static int x;
    static Random rnd = new Random();

    static void Main(string[] args)
    {
        List<Thread> threads = new List<Thread>();
        for (int i = 0; i < 4; i++)
        {
            Thread t = new Thread(Runner) { IsBackground = true };
            t.Start();
            threads.Add(t);
        }
        foreach (Thread t in threads)
        {
            t.Join();
        }
    }

    static void Runner()
    {
        for (int i = 0; i < 1000000; i++)
        {
            Thread.Sleep(rnd.Next(10));
	   int orig = x;
            x += 5;
            Debug.Assert(x == orig+5);        
} } }

I am increasing a shared static variable from multiple threads without any synchronization. Will it work? It might or might not (try it!). It depends on when different threads are accessing the variable x. One thing is for sure, this code isn’t correct and it most probably won’t work and for sure it won’t work always. That is the biggest problem with multithreading – if something works it doesn’t mean that it it is correctly written and that it will work always. More about this later. If you use unit testing to test runner method the test will pass because unit testing doesn’t test multithreading, at least not easily.

So, how does one test such code and scenarios. One way is to use a static analysis tool. The other way is to put a jinx on your application. Once your application is jinxed it will be much more prone to displaying concurrency and other multithreading errors. And that’s exactly what Jinx does. Behind the scenes it makes your application fail more often that it would fail in normal circumstances. I mean that it shows faults in the application (if any) that would otherwise remain hidden and would occur only randomly here and there (you know, your user will find it after 2 minutes of running the application) – it doesn’t fail your application for no reason, it just emphasizes your bugs.

The most interesting aspect of Jinx is its the way it works. Jinx is a sort of hypervisor. You certainly know Hyper-V hypervisor whose task is to run guest operating systems. Jinx’s task is to make a clone of your OS and debugged application within and run multiple versions of it under various conditions. This is done so that any multithreading error is more likely to appear. Just by running more versions of the same application the error is more likely to manifest itself. But Jinx throws all sort of other jinxes to your application as well. That’s the shallow explanation. You’ll find more on official overview page and FAQ page.

So, let’s jinx the code above. Note that if you don’t want to you don’t need any modification of an existing code. Jinx can be set to do its task on any newly run application. However, some fine control is a better way to go. Here are the simple steps for selective jinxing:

  1. Reference jinxinterface assembly. It contains a single static JinxInteface class with a bunch of static methods and serves as a communication bridge between application and Jinx.
  2. Add jinx.cs file to your project. Again it contains a single static Jinx class that is a wrapper around JinxInteface class mentioned above. Its purpose is mostly to apply Conditional("DEBUG") over methods so they won’t get executed for non-debug version of the application.
  3. Call Jinx.RegisterApplication(); method at start of the application. This way you’ll let Jinx know that your application should use some jinxing.
  4. Replace Debug.Assert with Jinx.Assert. The only difference with both asserts is that the latter send statistical information to Jinx.

After the changes the code should look like this:

class Program
{
    static int x;
    static Random rnd = new Random();

    static void Main(string[] args)
    {
        Jinx.RegisterApplication();
        List<Thread> threads = new List<Thread>();
        for (int i = 0; i < 4; i++)
        {
            Thread t = new Thread(Runner) { IsBackground = true };
            t.Start();
            threads.Add(t);
        }
        foreach (Thread t in threads)
        {
            t.Join();
        }
    }

    static void Runner()
    {
        for (int i = 0; i < 1000000; i++)
        {
            Thread.Sleep(rnd.Next(10));
            int orig = x;
            x += 5;
            Jinx.Assert(x == orig + 5);
        }
    }
}

Before any analyzing takes place Jinx should be enabled and set – this is a system wide option. There are two ways to open the Jinx console – either through Tool/Jinx Visual Studio menu item or directly from All Programs via start menu. Either way you need Administrator privileges. Enabling is easy, just check Enable Jinx checkbox and that’s it. As per what programs are analyzed I’ll use “Analyze the most recent program I have registered.” option.

jinx

You can adjust some strategy settings on Strategy tab, I’ll skip this as it is an advanced option. And you can see the statistics on Status tab. Let’s run the application now. Jinx will kick in and the CPU will get under heavy load and the system might shutter due to Jinx running versions of the application in parallel. But the assert failure pops up almost immediately – the bug was caught for sure. If you run the application without jinxs there error would manifest much more later if at all and note that the test code in question is an extreme example. Here is the status tab page after a couple of errors caught:

status

The asserts observed counter is increased thanks to Jinx.Assert method call. Jinx analyzer isn’t limited to asserts and it might catch other type of errors as well according to PetraVM guys. Jinx is much more than this simple example.

So far I’ve run few examples like this and Jinx performed well and I think Jinx is a good weapon against multithreading bugs. However there might be a problem for testing. Since Jinx is a hypervisor on its own it won’t get along with other hypervisors such as Hyper-V. In other words forget about running Jinx on guest OS. A dedicated machine is required. Perhaps this issue will change in the future.

Also be careful when experimenting with Jinx as it is in beta phase right now (you can apply for testing over here). Running a beta hypervisor might result in a BSOD and all the consequences from BSOD such as non bootable Windows after. Which happened when I was writing this post. Perhaps this post is jinxed as well :-). Humor aside, I am sure guys behind Jinx will make it rock solid for the RTM. They obviously know very well the hypervisor craft.

Happy jinxing your applications!

Tags:

.net | Parallel programming | Windows

Putting sleepless Windows 7 to sleep

by Miha Markič 21. September 2009 09:11

A while ago I had the problem with Vista. The thing was that it woke up randomly from the sleep state. The same problem reappeared when I’ve upgraded to Windows 7 x64. But the solution I’ve found previously didn’t work anymore. Even turning off all wake up features for each device didn’t make any difference. Computer would just wake up in the middle of night and stay awake. Besides unpleasant noise there is also unnecessary power consumption.

However it looks like I’ve found the solution once again and this time it is a much more clean and an obvious one. Go to Control Panel, Power Options and click on Change plan settings of the currently selected plan.

poweroptions

Next click on Change advanced power settings

balanced

And finally disable Allow wake timers in Sleep node.

final

That’s it. Your Windows 7 computer will sleep like a baby again.

Tags:

Windows | Windows 7

Investigating Windows BSOD cause for dummies

by Miha Markič 13. September 2009 21:57

Does your Windows displays nice, we all love, BSOD once in a while or perhaps, god forbid, often? There are two most plausible suspects for this behavior. And no, it is rarely Windows fault. Instead it is either hardware or driver and I won’t even dig into the quality of drivers produced by various hardware companies.

But the big question here is, which one? Which driver? Which hardware? It is even harder to pinpoint the cause in case when BSOD occurs at random times. Luckily there is a tool that might shade some light on the mystery and point cyber finger at the offending driver: Microsoft Debugging Tools for Windows.

Recipe for using Debugging Tools

The recipe is shown on Windows 7 but it is very much the same for other Windows flavors.

1. Make sure your BSODs are producing memory dumps.

  1.  
    1. Right click on Computer, pick Properties
    2. On the left side click Advanced system settings
    3. Select Advanced tab, you’ll see this window
      dm1
    4. Click Settings… button in Startup and Recovery Group to see this window
      dm2
    5. Make sure that Kernel memory dump or at least Small memory dump (256KB) is selected (it should be on by default). That way Windows will store the forensic evidence of the crash.

2. Install appropriate (x86, x64 or Itanium) version of Microsoft Debugging Tools for Windows.

3. Run WinDbg debugger (installed as a part of package in previous step) as administrator (Right click/Run as administrator).

4. Setup symbols server path so the tool can output human readable information instead of hex codes.

Pick File/Symbol File Path… menu item and enter the following line into the text box:
SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
This line instructs WinDbg where to download symbols from (in this case it will be public Microsoft server). Also note that c:\symbols is folder on my disk where WinDbg will cache the symbols. You are free to use whatever other folder.
Note: there are other ways for obtaining the symbols, this is just the easiest one.
d1

5. Now you are ready for some real action. If your BSOD produced memory dump you’ll find it in C:\Windows\Minidump folder (default location). Pick File/Open Crash Dump… menu item and search for a memory dump file. Once you open a file WinDbg will present you a window like this (note, the first time it make take a while because WinDbg will download symbols from the internet):
d2
Here you’ll find the first clue of the offender, see line which starts with Probably caused by. The text probably won’t tell you much more, so here is the magic wand command.

6. Either click on !analyze –v or type it into the command line at the bottom and press enter. A better description of the error will appear such as this one:
d3
Here is a much more (human readable) information you can use to understand the cause of the BSOD. There is an offending process or driver and even a call stack. Specially the former should give you a hint who is causing the problem. Or perhaps you’ll find it in the call stack among system functions. Unfortunately the given sample is not the best one because at the moment I don’t have any better since I didn’t run into BSOD for a long time except the given sample on my wife’s computer. Csrss.exe doesn’t tell me much because the real source is hidden probably by a hardware issue. But if it was soundblaster.dll or nvidia.dll or ati.dll it would be very obvious who is the cause, wouldn’t it.

Here is my advice: search for a known dll/exe on this screen and if you find one you probably found the cause.

Well, I am not a die hard debugging guy but I often did find the cause of my BSODs this way. I am sure skilled people can use WinDbg much better than me. However often you’ll be able to understand the BSOD cause by yourself simply running WinDbg and !analyze –v command. And you’ll agree that there is no better feeling than solving such an annoying problem by yourself.

Happy hunting!

Tags:

Windows

Change the HAL of Windows OS

by Miha Markič 25. January 2009 21:00

I am doing a presentation on Visual Studio 2010/.net 4 parallel programming enhancements in the near future. [MS] released Visual Studio 2010 CTP and that’s fine. The problem was that the one and only release comes in the form of a VirtualPC image. This is not a problem by itself but it is a problem if one wants to show parallelism. You see, VirtualPC supports only single processor guests ([MS] isn’t exactly pushing for VirtualPC enhancements, is it – at the time [MS] bought VirtualPC it was on the same level as [VMWare] Workstation, now it is lightyears away). How can one show performance enhancements of parallelism with one CPU?

Part of the solution is [VMWare] Workstation 6.5 (and earlier, don’t know exactly which ones): it supports multiprocessor guests. Great. However once I’ve imported VirtualPC image into Workstation the OS was still showing only one processor even though device manager recognized two processors. Even updating the computer driver (node Computer\Advanced Configuration and Power Interface (ACPI) PC) didn’t help – there were no choices. Luckily I’ve googled over this blog post: Hyper-V How To: Change the HAL on your vm. Oh, the joy, the trick just worked.

The other problem with this presentation is that Visual Studio 2010 CTP expired by the end 2008. The solution is to change date backwards (silly, isn’t it) but Workstation/Windows keep synchronizing the time with current and thus yielding all sort of activation and expiration warnings. The solution is a twofold one:

- add these lines to Workstation’s configuration file so the Workstation won’t synchronize the guest on every occasion (thanks to Virtual Time Freeze):

tools.syncTime = "FALSE"
time.synchronize.continue = "FALSE"
time.synchronize.restore = "FALSE"
time.synchronize.resume.disk = "FALSE"
time.synchronize.shrink = "FALSE"

- remove or disable guest’s network capabilities so the OS won’t synchronize as well.

Ah, the joys of presentations based on CTPs.

Tags:

Windows | Virtualization | VS 2010 | Slovenia | VMWare | .net 4.0

Windows Live Writer doesn’t work well under Windows 7 beta x64

by Miha Markič 19. January 2009 15:01

I’ve tried to run Windows Live Writer under Windows 7 beta today. It runs but it can’t upload pictures through FTP. There are two indications of the problem:

  • when you configure FTP connection it will yield this warning
  • The remote server could not be contacted to verify the settings. Do you want to continue anyway?

  • Publish or save draft to server will yield an error:
  • Error occurred while transferring file [picture name here]

    (Publishing Error) A publishing error occurred: The source of the error is unknown.

I wonder whether this bug is related to x64, Windows 7 beta or to both.

Tags:

Windows | Windows Live | Windows 7

VMWare Workstation's Easy Install

by Miha Markič 19. January 2009 14:54

When you think that [VMWare] invented everything they push the innovations even further. These days I've finally accomplished Windows 7 beta download and since I don't have a spare computer right now I've though of installing it under Workstation 6.5. I have to admit that I didn't install any new OS for a while now (thanks to Workstation's excellent snapshot management system). So I created a new typical configuration and entered the path to the Windows 7 beta x64 iso file. Workstation recognized it as Vista (W7 is enhanced Vista after all, but I am sure Workstation will be updated to reflect the proper name in the future) and notified me that it will be installed using Easy Install.

ei

I didn't know about Easy Install and I was pleasantly surprised about it. It lets you enter all the required data for the installation in the next next dialog:

eii

and that’s it. After you put in all the required configuration data Workstation will install the OS for you, no interaction required whatsoever. That’s right, after some time you’ll be greeted by running OS. A huge timesaver even if you don’t install a lot.

Tags:

Windows | Virtualization | VMWare

Lost Windows Live Writer

by Miha Markič 15. January 2009 14:26

Today I lost my Windows Live Writer. I was doing a Windows Live update of installed WL applications. The update performed an uninstall first and install after. But the install failed and fails with an error 0x80070643. Of course it didn't rollback the original installation.

Quick googling for the solution doesn't help as well. Great error message and hidding installation log file is a great feature, [MS]. Damn, I'll just use Sysinternals to figure out what goes wrong.

Tags:

Windows

Miha Markic

About me
Righthand
 
Microsoft MVP
 
Developer Express' DXSquad
INETA Country Leader for Slovenia
INETA Country Leader for Slovenia

Slovene Developer Users Group Lead
Friends of Red-Gate
LLBLGenPro Partner

Miha currently works as a free lance consultant and software developer specialized in .net area.
He graduated in Computer and information science at the University of Ljubljana, Slovenia. He has accumulated experience in various programming languages such as Java, Visual Basic 3-6 (MCP), Visual C++, Delphi, C# and VB.Net through years.
He has experience in practically all (technical) stages of project development, including planning, framework development, user interface, business processes, as well as testing and documenting. He has worked on big and small projects in Slovenia and abroad (e.g. participated in completing level 3 IS for the Nucor steel plant, Hertford, USA).
Currently he enjoys programming in .net environment using C#. Since 2000 he has been active in Developer Express' DX Squad and has been ECDL trainer and tester. He also gives lectures on conferences and other events in Slovenia.

Month List

Tag cloud

Most comments

Paulius Paulius
1 comments
us United States
Meh Meh
1 comments
us United States
bart dm bart dm
1 comments
nl Netherlands

RecentComments

Comment RSS