runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[ubuntu x64] many coreclr tests fails because of "Unable to load DLL 'kernel32.dll'"

Open sergign60 opened this issue 9 years ago • 22 comments

The latest version of coreclr with the latest version of corefx gives many coreclr test fails with the message:

baseservices/threading/paramthreadstart/ThreadStartBool_1/ThreadStartBool_1.sh
               BEGIN EXECUTION
               export CDPATH=.
               /bin/sh -c ../ThreadStartBool/ThreadStartBool.sh
               BEGIN EXECUTION
               /home/signatov/coreclr/Tests/Tests/coreoverlay/corerun ThreadStartBool.exe true
               
               Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'kernel32.dll': The specified module could not be found.
                (Exception from HRESULT: 0x8007007E)
                  at Interop.Kernel32.GetStdHandle(Int32 nStdHandle)
                  at System.ConsolePal.GetStandardFile(Int32 handleType, FileAccess access)
                  at System.Console.<>c.<get_Out>b__25_0()
                  at System.Console.EnsureInitialized[T](T& field, Func`1 initializer)
                  at System.Console.WriteLine(Boolean value)
                  at ThreadStartBool.ThreadWorker(Object o)
                  at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                  at System.Threading.ThreadHelper.ThreadStart(Object obj)
               Aborted (core dumped)
               Expected: 100
               Actual: 134
               END EXECUTION - FAILED
               Expected: 0
               Actual: 1
               END EXECUTION - FAILED

First of all the latest version of corefx doesn't create directory

.../corefx/bin/Linux.x64.Debug/Native

that is required by the coreclr/tests/runtest.sh script but

.../corefx/bin/Linux.x64.Debug/native

So the testing command

coreclr/tests/runtest.sh --testRootDir=.../coreclr/Tests --testNativeBinDir=.../coreclr/bin/obj/Linux.x64.Debug/tests --coreClrBinDir=.../coreclr/bin/Product/Linux.x64.Debug --coreFxBinDir=".../corefx/bin/Linux.AnyCPU.Debug;.../corefx/bin/Unix.AnyCPU.Debug;..../corefx/bin/AnyOS.AnyCPU.Debug" --coreFxNativeBinDir=.../corefx/bin/Linux.x64.Debug 

fails with the message

Running on  CPU- x64
Directory specified by --coreNativeFxBinDir does not exist: .../corefx/bin/Linux.x64.Debug/Native

So I have been forced to create the link 'Native' to corefx/bin/Linux.x64.Debug/native'

After this many coreclr tests fail because of no library 'kernel32.dll'

the used system

uname -a
Linux  4.4.0-59-generic dotnet/coreclr#80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

the used version of coreclr

git log | head                                                                                                                                                  *[master] 
commit 62ac5f04456e517b76bcfc3d386859a506eed6d1
Author: Koundinya Veluri <[email protected]>
Date:   Sun Jan 22 23:10:14 2017 -0800

    Report by-ref-like types to the GC (SpanOfT) (#9034)
    
    Report by-ref-like types to the GC (SpanOfT)
    
    Fixes dotnet/runtime#7103

the used version of corefx

commit a2cc082202e23e9934acd6f0406b539af7ada988
Merge: 1e7c415391 6290362355
Author: Stephen Toub <[email protected]>
Date:   Sun Jan 22 09:38:17 2017 -0500

    Merge pull request dotnet/coreclr#14686 from JonHanna/fix_14488
    
    ExcludeFromCodeCoverageAssemblyAttribute for excluding assemblies

the used version of tests:

https://ci.dot.net/job/dotnet_coreclr/job/master/job/debug_windows_nt_bld/lastSuccessfulBuild/artifac/bin/tests/

Artifacts of debug_windows_nt_bld dotnet/coreclr#514

sergign60 avatar Jan 23 '17 08:01 sergign60

CC: @Dmitri-Botcharnikov

sergign60 avatar Jan 23 '17 08:01 sergign60

CC: @janvorli @sivarv

sergign60 avatar Jan 23 '17 10:01 sergign60

I have hit the same issue in my local testing on Friday. There was a breaking change in the folder structure that corefx generates compiled assemblies into. I was actually suprised that it works fine in the CI lab and I was thinking that someone has already fixed the test invocation in there. So it turns out the CI just picked the corefx change a bit later. @gkhanna79, @weshaggard the tests/runtests.sh script in CoreCLR is no longer valid with the recent changes in the corefx branch. This results in the runtest.sh script using windows versions of some of the assemblies that it copies from the Core_Root folder when the tests are built on Windows. These should be overwritten by the files from the Unix corefx build, but since the files are generated to a different folder, it doesn't work anymore. The problem is here in the script where it assumes the previous structure of the corefx output folders, essentially assuming that the built assemblies are stored in ASSEMBLY_NAME/ASSEMLBY_NAME.dll under each of the target folders like bin/Linux.AnyCPU., Unix.AnyCPU., AnyOS.AnyCPU.* etc.

https://github.com/dotnet/coreclr/blob/master/tests/runtest.sh#L371-L382

janvorli avatar Jan 23 '17 11:01 janvorli

I believe @ellismg was looking into ensuring that CoreCLR test infrastructure will work with the new layout that CoreFX dev/eng changes brought in, since he originally pinned the build of CoreFX used by CoreCLR testing.

@ellismg do you have an ETA for this?

gkhanna79 avatar Jan 23 '17 15:01 gkhanna79

I believe that @RussKeldorph was also looking into updating this.

weshaggard avatar Jan 23 '17 22:01 weshaggard

@weshaggard, I'm working on the coreclr jobs that run corefx tests. If there is a fix required to coreclr's runtests.sh, that hasn't been on my radar up to this point. I'm not necessarily opposed to fixing it, but there's probably a better person since I'm so slow.

RussKeldorph avatar Jan 24 '17 01:01 RussKeldorph

@gkhanna79 is this something that @wtgodbe might be able to assist with?

weshaggard avatar Jan 24 '17 01:01 weshaggard

Yes, @wtgodbe will help take a look at this tomorrow.

gkhanna79 avatar Jan 24 '17 05:01 gkhanna79

@gkhanna79 @wtgodbe CC: @Dmitri-Botcharnikov

please review these diffs:

diff --git a/tests/runtest.sh b/tests/runtest.sh
index b48cffb4a..d856e3e0c 100755
--- a/tests/runtest.sh
+++ b/tests/runtest.sh
@@ -356,7 +356,7 @@ function create_core_overlay {
     if [ -z "$coreFxNativeBinDir" ]; then
         exit_with_error "$errorSource" "One of --coreOverlayDir or --coreFxBinDir must be specified." "$printUsage"
     fi
-    if [ ! -d "$coreFxNativeBinDir/Native" ]; then
+    if [ ! -d "$coreFxNativeBinDir/native" ]; then
         exit_with_error "$errorSource" "Directory specified by --coreNativeFxBinDir does not exist: $coreFxNativeBinDir/Native"
     fi
 
@@ -374,14 +374,17 @@ function create_core_overlay {
                 exit_with_error "$errorSource" "Directory specified in --coreFxBinDir does not exist: $currDir"
             fi
             pushd $currDir > /dev/null
-            for dirName in $(find . -iname '*.dll' \! -iwholename '*test*' \! -iwholename '*/ToolRuntime/*' \! -iwholename '*/RemoteExecutorConsoleApp/*' \! -iwholename '*/net*' \! -iwholename '*aot*' -exec dirname {} \; | uniq | sed 's/\.\/\(.*\)/\1/g'); do
-                cp -n -v "$currDir/$dirName/$dirName.dll" "$coreOverlayDir/"
+		    for dirName in $(find . -iname '*.dll' \! -iwholename '*test*' \! -iwholename '*/ToolRuntime/*' \! -iwholename '*/RemoteExecutorConsoleApp/*' \! -iwholename '*aot*' -exec dirname {} \; | uniq | sed 's/\.\/\(.*\)\/netstandard.*/\1/g'); do
+	        	cp -n -v "$currDir/$dirName/netstandard/$dirName.dll" "$coreOverlayDir/"
+		        cp -n -v "$currDir/$dirName/netstandard1.0/$dirName.dll" "$coreOverlayDir/"
+		        cp -n -v "$currDir/$dirName/netstandard1.1/$dirName.dll" "$coreOverlayDir/"
+
             done
             popd $currDur > /dev/null
         done
     done <<< $coreFxBinDir
 
-    cp -f -v "$coreFxNativeBinDir/Native/"*."$libExtension" "$coreOverlayDir/" 2>/dev/null
+    cp -f -v "$coreFxNativeBinDir/native/"*."$libExtension" "$coreOverlayDir/" 2>/dev/null
 
     cp -f -v "$coreClrBinDir/"* "$coreOverlayDir/" 2>/dev/null
     cp -f -v "$mscorlibDir/mscorlib.dll" "$coreOverlayDir/" 2>/dev/null

sergign60 avatar Jan 24 '17 08:01 sergign60

@sergign60 , @gkhanna79, @wtgodbe It looks like all the CoreFX binaries needed for the tests are collected in bin/runtime/netcoreapp-Linux-Debug-x64 folder. So it seems that we could change the script to use those instead of the files from $testRootDir/Tests/Core_Root subfolder of the tests and get rid of this loop that tries to find and copy the binaries from the various bin subfolders completely.

janvorli avatar Jan 24 '17 11:01 janvorli

Thank you @janvorli. @wtgodbe will drive validating the fix with this.

gkhanna79 avatar Jan 24 '17 16:01 gkhanna79

@janvorli that is correct. Now in stead of needing to hunt through all the directories they are in the one flat runtime folder.

weshaggard avatar Jan 24 '17 17:01 weshaggard

@ellismg I had heard that you had pinned the version of CoreFX to be used. Is that something that will no longer be needed once @wtgodbe fixes this? If so, can you please share more details about it?

gkhanna79 avatar Jan 24 '17 19:01 gkhanna79

@sergign60 I believe you want to copy all .dll's and .$libExtension's from bin/runtime/netcoreapp-Linux-Debug-x64, instead of copying "$currDir/$dirName/netstandard/$dirName.dll" and "$currDir/$dirName/netstandard/$dirName.dll" - @weshaggard does that sound right to you?

wtgodbe avatar Jan 24 '17 20:01 wtgodbe

@wtgodbe we should just copy everything from that folder. No need to filter it. The files that need to come from the coreclr will just overwrite the existing ones.

janvorli avatar Jan 24 '17 20:01 janvorli

@janvorli do we need the .PDB's as well?

wtgodbe avatar Jan 24 '17 20:01 wtgodbe

@wtgodbe I think they can be useful for debugging the tests.

janvorli avatar Jan 24 '17 20:01 janvorli

Correct you should just copy everything.

@wtgodbe you shouldn't need anything from the any netstandard directories. For running all that should be needed is the bin/runtime/netcoreap-Linux-Debug-x64 where those options match what build flavor and want. It is way easier then it used to be.

weshaggard avatar Jan 24 '17 20:01 weshaggard

Sweet, I'll put together a PR.

wtgodbe avatar Jan 24 '17 20:01 wtgodbe

https://github.com/dotnet/coreclr/pull/9092 should fix - see the description of that PR for why the Ubuntu/OSX test legs are failing

wtgodbe avatar Jan 25 '17 00:01 wtgodbe