文章出處

前兩天在Windows Server 2012上編譯生成.NET Core Framework的代碼庫corefx,遭遇了幾個問題,在這篇博文中記錄一下。

編譯生成操作方法是在命令行(Developer Command Prompt for VS2014)中運行corefx中的build.cmd命令。

(一)

遇到的第1個問題[#560]是:"Err445! Got unexpected exception: System.IO.IOException: There is not enough space on the disk."

問題發生在 System.IO.MemoryMappedFiles\tests\MemoryMappedFile\CreateViewAccessor.cs 的第378行:

using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(
s_fileNameForLargeCapacity,
FileMode.Open,
"CVA_RunTestLargeCapacity",
capacity))

問題引發點:

// 2^31-1, 2^31, 2^31+1, 2^32-1, 2^32, 2^32+1
Int64[] capacities = { 2147483647, 2147483648, 2147483649, 4294967295, 4294967296, 4294967297 };

foreach (Int64 capacity in capacities)
{
    RunTestLargeCapacity(capacity);
}

出問題時,capacity的值是4294967296(4G)。

當時corefx代碼庫所在的硬盤分區剩余空間只有4.81G,后來將剩余空間增加至9.21G,問題消失。

(二)

遇到的第2個問題[#564]是:有時運行build.cmd之后,硬盤分區的卷標被修改為BCLTest。

 經過分析源代碼,發現問題的引發點在 System.IO.FileSystem.DriveInfo\tests\GetVolumeLabelTests.cs 的97行:

for (int i = 0; i < drives.Length; i++)
{
    if (originalVolumeInfo.ContainsKey(drives[i].Name))
    {
        try
        {
            drives[i].VolumeLabel = (String)originalVolumeInfo[drives[i].Name];
        }
        catch (UnauthorizedAccessException) { }
    }
    //...
}

GetVolumeLabelTests在測試過程中會修改硬盤分區的卷標,修改之后會恢復原來的卷標。但如果在恢復過程中出現UnauthorizeAccessException異常(比如當前硬盤分區正在某些文件操作不允許修改卷標),硬盤分區卷標就會變成BCLTest而回不去了。

該問題可以通過下面的代碼進行重現:

//Scenario 3: We will revert to the original volume value and check
for (int i = 0; i < drives.Length; i++)
{
    if (originalVolumeInfo.ContainsKey(drives[i].Name))
    {
        try
        {
            drives[i].VolumeLabel = (String)originalVolumeInfo[drives[i].Name];
            throw new UnauthorizedAccessException();
        }
        catch (UnauthorizedAccessException) { }
    }
    //...
}

(三)

遇到的第3個問題[#566]是運行Microsoft.Win32.Registry.Tests單元測試時出現“Error Key value is incorrect...”異常。

問題的引發點在 Microsoft.Win32.Registry\tests\RegistryKey\RegistryKey_GetValue_str_obj_regvalopt.cs:line 43:

try
{
    Object obj = _rk1.GetValue(null, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
    if (obj != null)
    {
        Assert.False(true, "Error Key value is incorrect...");
    }
}

當時obj的值是0。

在gitbuh上提交issue之后,根據 @stephentoub 的回復,找到了問題的原因,原來是注冊表HKEY_CURRENT_USER中"(Default)"的值為0引起的。

刪除該注冊表項之后,Windows會自動創建空的"(Default)"。

之后,問題解決。

但是,后來過一段時間再看,HKEY_CURRENT_USER中"(Default)"的值又變為0,問題沒有根本解決。


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()