Skip to content

Conversation

@radical
Copy link
Member

@radical radical commented Nov 29, 2023

This removes the need for having access to a local filesystem for reading the runtimeconfig . Thus the app can be run with wasmtime run foo.wasm.

  • [wasi] WasiAppBuilder: error out for single file bundles, if there ..
  • [wasi] driver.c: bundle runtimeconfig.bin, and use that for the single file bundle case
  • [wasi] Don't add '--dir' for single file bundles

Fixes #94407 .

@radical radical added the arch-wasm WebAssembly architecture label Nov 29, 2023
@ghost
Copy link

ghost commented Nov 29, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

This removes the need for having access to a local filesystem for reading the runtimeconfig .

  • [wasi] WasiAppBuilder: error out for single file bundles, if there ..
  • [wasi] driver.c: bundle runtimeconfig.bin, and use that for the single file bundle case
  • [wasi] Don't add '--dir' for single file bundles

TODO: add test for invariantglobalization

Fixes #94407 .

Author: radical
Assignees: -
Labels:

arch-wasm

Milestone: -

@ghost ghost added the area-Build-mono label Nov 29, 2023
@ghost ghost assigned radical Nov 29, 2023
@radical radical requested review from fanyang-mono, maraf and mdh1418 and removed request for fanyang-mono and mdh1418 November 29, 2023 03:29
@radical
Copy link
Member Author

radical commented Nov 29, 2023

Tests here would overlap with #95281 .

This fixes the case when `RunAOTCompilation=true` in the project, but we
only build with relinking.
@radical
Copy link
Member Author

radical commented Nov 29, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical radical marked this pull request as ready for review November 29, 2023 06:09
@radical
Copy link
Member Author

radical commented Nov 29, 2023

cc @ilonatommy

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure this is how we want to handle extrafilestodeploy in this case?

@radical
Copy link
Member Author

radical commented Nov 29, 2023

are we sure this is how we want to handle extrafilestodeploy in this case?

Till we figure out how we want to handle it, I want to catch attempts to use this when it will just silently fail.

@pavelsavara
Copy link
Member

pavelsavara commented Nov 29, 2023

interesting Log

#94820

[05:58:23] info: Discovering: System.Security.Cryptography.Tests.dll (method display = ClassAndMethod, method display options = None)
[05:58:23] warn: 
[05:58:23] warn: Unhandled Exception:
[05:58:23] warn: System.PlatformNotSupportedException: Operation is not supported on this platform.
[05:58:23] warn:    at System.Security.Cryptography.RSA.Create()
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.SignatureSupport..cctor()
[05:58:23] warn: 
[05:58:23] warn: Unhandled Exception:
[05:58:23] warn: System.PlatformNotSupportedException: System.Security.Cryptography.X509Certificates is not supported on this platform.
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.CertificatePal.FromBlob(ReadOnlySpan`1 rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.CertificateCreation.CertificateRequestChainTests.DetectPssSupport()
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.CertificateCreation.CertificateRequestChainTests..cctor()
[05:58:24] warn: 
[05:58:24] warn: Unhandled Exception:
[05:58:24] warn: System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception.
[05:58:24] warn:  ---> System.DllNotFoundException: libSystem.Security.Cryptography.Native.OpenSsl
[05:58:24] warn:    at Interop.CryptoInitializer..cctor()
[05:58:24] warn:    --- End of inner exception stack trace ---
[05:58:24] warn:    at Interop.Crypto..cctor()
[05:58:24] warn: 
[05:58:24] warn: Unhandled Exception:
[05:58:24] warn: System.PlatformNotSupportedException: Operation is not supported on this platform.
[05:58:24] warn:    at System.Security.Cryptography.DSA.CreateCore()
[05:58:24] warn:    at System.Security.Cryptography.DSA.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DefaultDSAProvider.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAFactory.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAKeyGeneration.GetHasSecondMinSize()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAKeyGeneration..cctor()
[05:58:26] info: Discovered:  System.Security.Cryptography.Tests.dll (found 1558 of 4184 test cases)
[05:58:26] info: Using random seed for test cases: 1765878136
[05:58:26] info: Using random seed for collections: 1765878136
[05:58:26] info: Starting:    System.Security.Cryptography.Tests.dll
[05:58:26] info: [2023-11-29T05:58:26.769Z] [PASS] System.Security.Cryptography.Tests.Sha256ManagedTests.InvalidInput_NegativeOffset
[05:58:26] info: [2023-11-29T05:58:26.774Z] [PASS] System.Security.Cryptography.Tests.Sha256ManagedTests.HashData_BufferTooSmall

...

[05:58:57] info: [2023-11-29T05:58:57.013Z] [PASS] System.Security.Cryptography.Tests.Sha256Tests.InvalidInput_TooBigOffset
[05:59:10] info: Unable to evaluate script: tab crashed


<_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(_AppBundleDirForRunCommand), '$(AssemblyName).runtimeconfig.json'))</_RuntimeConfigJsonPath>
<RunArguments Condition="'$(RunArguments)' == ''">exec &quot;$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))&quot; --runtime-config &quot;$(_RuntimeConfigJsonPath)&quot; $(WasmHostArguments)</RunArguments>
<RunArguments Condition="'$(RunArguments)' == '' and '$(WasmSingleFileBundle)' != 'true'">exec &quot;$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))&quot; --runtime-config &quot;$(_RuntimeConfigJsonPath)&quot; $(WasmHostArguments)</RunArguments>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would prefer concatenating the arguments one by one and having a condition on the dir one rather than duplicating the whole line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's simple enough right now, so I'll keep it as-is. But I wanted to take the same approach as you suggested, but it would make a little more complicated, tracking to make sure that we don't add the extra argument when RunArguments was set before these lines.

Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, except for one question.

@radical
Copy link
Member Author

radical commented Nov 29, 2023

interesting Log

#94820

[05:58:23] info: Discovering: System.Security.Cryptography.Tests.dll (method display = ClassAndMethod, method display options = None)
[05:58:23] warn: 
[05:58:23] warn: Unhandled Exception:
[05:58:23] warn: System.PlatformNotSupportedException: Operation is not supported on this platform.
[05:58:23] warn:    at System.Security.Cryptography.RSA.Create()
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.SignatureSupport..cctor()
[05:58:23] warn: 
[05:58:23] warn: Unhandled Exception:
[05:58:23] warn: System.PlatformNotSupportedException: System.Security.Cryptography.X509Certificates is not supported on this platform.
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.CertificatePal.FromBlob(ReadOnlySpan`1 rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.CertificateCreation.CertificateRequestChainTests.DetectPssSupport()
[05:58:23] warn:    at System.Security.Cryptography.X509Certificates.Tests.CertificateCreation.CertificateRequestChainTests..cctor()
[05:58:24] warn: 
[05:58:24] warn: Unhandled Exception:
[05:58:24] warn: System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception.
[05:58:24] warn:  ---> System.DllNotFoundException: libSystem.Security.Cryptography.Native.OpenSsl
[05:58:24] warn:    at Interop.CryptoInitializer..cctor()
[05:58:24] warn:    --- End of inner exception stack trace ---
[05:58:24] warn:    at Interop.Crypto..cctor()
[05:58:24] warn: 
[05:58:24] warn: Unhandled Exception:
[05:58:24] warn: System.PlatformNotSupportedException: Operation is not supported on this platform.
[05:58:24] warn:    at System.Security.Cryptography.DSA.CreateCore()
[05:58:24] warn:    at System.Security.Cryptography.DSA.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DefaultDSAProvider.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAFactory.Create()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAKeyGeneration.GetHasSecondMinSize()
[05:58:24] warn:    at System.Security.Cryptography.Dsa.Tests.DSAKeyGeneration..cctor()
[05:58:26] info: Discovered:  System.Security.Cryptography.Tests.dll (found 1558 of 4184 test cases)
[05:58:26] info: Using random seed for test cases: 1765878136
[05:58:26] info: Using random seed for collections: 1765878136
[05:58:26] info: Starting:    System.Security.Cryptography.Tests.dll
[05:58:26] info: [2023-11-29T05:58:26.769Z] [PASS] System.Security.Cryptography.Tests.Sha256ManagedTests.InvalidInput_NegativeOffset
[05:58:26] info: [2023-11-29T05:58:26.774Z] [PASS] System.Security.Cryptography.Tests.Sha256ManagedTests.HashData_BufferTooSmall

...

[05:58:57] info: [2023-11-29T05:58:57.013Z] [PASS] System.Security.Cryptography.Tests.Sha256Tests.InvalidInput_TooBigOffset
[05:59:10] info: Unable to evaluate script: tab crashed

Yeah -- #94820 . I'll also update xharness to handle this tab crashed case a little better.

@radical radical merged commit 042c11d into dotnet:main Nov 29, 2023
@radical radical deleted the wasi-fix-runtimeconfig branch November 29, 2023 18:51
@github-actions github-actions bot locked and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Build-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enabling InvariantGlobalization breaks int.Parse in WASI apps

7 participants