ClearScript icon indicating copy to clipboard operation
ClearScript copied to clipboard

.NET local tool that using the ClearScript.V8 library quietly crashes on macOS 12.1

Open Taritsyn opened this issue 3 years ago • 7 comments

Hello!

Initially, this error was discovered by Sergey Zwezdin. By many characteristics, this error is very similar to another issue registered in this repository.

This error occurs in macOS 12.1 not only on ARM64 processors, but also on x64 processor architecture. In the case of x64 processor architecture, this error occurs only if the .NET 6.0.101 SDK was installed cleanly (without additional runtimes and other SDKs).

In order for you to reproduce this error, I created a sample project on GitHub. In macOS's terminal, you need to perform the following steps:

  • Clone a repository.
    • mkdir TemporaryProjects && cd TemporaryProjects
    • git clone https://github.com/Taritsyn/ClearScriptV8Tester.DotNetTool
  • Build a NuGet package.
    • cd ClearScriptV8Tester.DotNetTool
    • dotnet pack
  • Install and run a tool locally.
    • cd ..
    • mkdir TestDotNetTool && cd TestDotNetTool
    • dotnet new tool-manifest
    • dotnet tool install ClearScriptV8Tester.DotNetTool --add-source ../ClearScriptV8Tester.DotNetTool/nupkg
    • dotnet tool run clearscript-v8-tester

If the .NET 6.0.101 SDK is installed cleanly, then a quiet crash will occur during script execution:

before-dotnet-runtime-5 0 13-osx-x64-installation-marked

If you install the .NET 5.0.13 Runtime and then run a local tool, this error will no longer occur:

after-dotnet-runtime-5 0 13-osx-x64-installation-marked

Taritsyn avatar Jan 18 '22 16:01 Taritsyn

Hi Andrey,

Yes, this is the same issue. Oddly, the tool works when run as a normal application (dotnet run). This would appear to be an issue in the .NET runtime. We'll investigate internally.

Thanks!

ClearScriptLib avatar Jan 18 '22 18:01 ClearScriptLib

Hello!

After updating the ClearScript library to version 7.2.2, the error began to appear more clearly:

clearscript-v8-error-original-marked

<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#

Taritsyn avatar Feb 08 '22 08:02 Taritsyn

After updating the ClearScript library to version 7.2.2, the error began to appear more clearly:

Hmm, we aren't seeing that. In our testing the behavior is exactly the same as before – a silent crash attributed to a bad signature.

What you're seeing – V8's debugging output – is usually emitted only from debug V8 builds. Also, the signature crash wouldn't give V8 a chance to dump debug information, so this looks like something else.

ClearScriptLib avatar Feb 08 '22 14:02 ClearScriptLib

Nothing has changed in the system and using the ClearScript library version 7.2.1 gives the old result.

Taritsyn avatar Feb 08 '22 15:02 Taritsyn

Hi Andrey,

Nothing has changed in the system and using the ClearScript library version 7.2.1 gives the old result.

We're seeing exactly the same results with 7.2.1 and 7.2.2. We had been using an older version of .NET 6, so we just updated to the latest and repeated your procedure several times, but there was no change:

csl@Sebulba tool % dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.1
 OS Platform: Darwin
 RID:         osx.12-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  6.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
csl@Sebulba tool % dotnet tool run clearscript-v8-tester
Start script execution...
csl@Sebulba tool %

BTW, here's the modified .csproj file we used:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PackAsTool>true</PackAsTool>
    <ToolCommandName>clearscript-v8-tester</ToolCommandName>
    <PackageOutputPath>./nupkg</PackageOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.ClearScript.osx-arm64" Version="7.2.2" />
  </ItemGroup>

</Project>

Any idea what could be different in our setups?

ClearScriptLib avatar Feb 08 '22 16:02 ClearScriptLib

I testing this application on the x64 version of operating system. Unfortunately, I don't have the opportunity to test on ARM64.

Taritsyn avatar Feb 08 '22 16:02 Taritsyn

I testing this application on the x64 version of operating system

We can't reproduce the OOM issue in Rosetta. In fact, in Rosetta we can't reproduce either issue 🙄

ClearScriptLib avatar Feb 08 '22 17:02 ClearScriptLib

Please reopen this issue if you have additional information or observations related to this topic. Thank you!

ClearScriptLib avatar Oct 15 '22 14:10 ClearScriptLib

I just ran into this problem with a .NET 7 app. dotnet --info gave me this:

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.29 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.31 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.29 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.31 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

After installing the .NET 5.0.13 Runtime it started working, very strange. Thank you @Taritsyn !

neorth avatar Dec 09 '22 14:12 neorth