Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARM32] illegal instruction when run dotnet to create a console project #33344

Closed
oldzhu opened this issue Mar 8, 2020 · 7 comments
Closed
Assignees
Labels
arch-arm32 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Milestone

Comments

@oldzhu
Copy link
Contributor

oldzhu commented Mar 8, 2020

dotnet --info

.NET Core SDK (reflecting any global.json):
Version: 5.0.100-preview.2.20155.8
Commit: 12b7ebfb89

Runtime Environment:
OS Name: buildroot
OS Version: 2020.02-rc3
OS Platform: Linux
RID: linux-arm
Base Path: /root/dotnet/sdk/5.0.100-preview.2.20155.8/

Host (useful for support):
Version: 5.0.0-preview.2.20155.1
Commit: e2881ae

.NET Core SDKs installed:
5.0.100-preview.2.20155.8 [/root/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 5.0.0-preview.2.20155.1 [/root/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0-preview.2.20155.1 [/root/dotnet/shared/Microsoft.NETCore.App]
...

The gdb debugging log:
..
(gdb) r
Starting program: /root/dotnet/dotnet new console --output sample1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x763cd440 (LWP 232)]
[New Thread 0x75bcc440 (LWP 233)]
...
[New Thread 0x6b9ef440 (LWP 244)]
[Thread 0x6b9ef440 (LWP 244) exited]

Thread 1 "dotnet" received signal SIGILL, Illegal instruction.
0x6fad85e6 in ?? ()
(gdb) disas /rs $pc-10,+20
Dump of assembler code from 0x6fad85dc to 0x6fad85f0:
0x6fad85dc: 04 2b cmp r3, #4
0x6fad85de: 51 f8 04 2b ldr.w r2, [r1], #4
0x6fad85e2: 40 f8 04 2b str.w r2, [r0], #4
=> 0x6fad85e6: bd e8 00 40 ldmia.w sp!, {lr}
0x6fad85ea: 03 b0 add sp, #12
0x6fad85ec: 70 47 bx lr
bt 0x6fad85ee: 00 00 movs r0, r0
End of assembler dump.

(gdb) si
Fatal error. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
[Thread 0x6ec31440 (LWP 240) exited]
at System.Memory1[[System.Byte, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].op_Implicit(System.Memory1)
at System.Security.Cryptography.Asn1.AsnWriter.WriteEncodedValue(System.ReadOnlySpan`1)
at Internal.Cryptography.Pal.X500NameEncoder.X500DistinguishedNameEncode(System.String, System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags)
at Internal.Cryptography.Pal.OpenSslX509Encoder.X500DistinguishedNameEncode(System.String, System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags)
at System.Security.Cryptography.X509Certificates.X500DistinguishedName.Encode(System.String, System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags)
at System.Security.Cryptography.X509Certificates.X500DistinguishedName..ctor(System.String)
at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.CreateAspNetCoreHttpsDevelopmentCertificate(System.DateTimeOffset, System.DateTimeOffset, System.String, DiagnosticInformation)
at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.EnsureValidCertificateExists(System.DateTimeOffset, System.DateTimeOffset, Microsoft.AspNetCore.Certificates.Generation.CertificatePurpose, System.String, Boolean, Boolean, System.String, System.String)
at Microsoft.AspNetCore.DeveloperCertificates.XPlat.CertificateGenerator.GenerateAspNetHttpsCertificate()
at Microsoft.DotNet.Cli.AspNetCoreCertificateGenerator.GenerateAspNetCoreDevelopmentCertificate()
at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(Microsoft.DotNet.Configurer.IFirstTimeUseNoticeSentinel, Microsoft.DotNet.Configurer.IAspNetCertificateSentinel, Microsoft.DotNet.Configurer.IFileSentinel, Boolean, Microsoft.DotNet.Configurer.DotnetFirstRunConfiguration, Microsoft.DotNet.Cli.Utils.IEnvironmentProvider)
at Microsoft.DotNet.Cli.Program.ProcessArgs(System.String[], Microsoft.DotNet.Cli.Telemetry.ITelemetry)
at Microsoft.DotNet.Cli.Program.Main(System.String[])

Thread 1 "dotnet" received signal SIGABRT, Aborted.
0x76ca539c in raise () from /lib/libc.so.6

(gdb) bt
#0 0x76ca539c in raise () from /lib/libc.so.6
#1 0x76c8f3c4 in abort () from /lib/libc.so.6
#2 0x7683c704 in PROCAbort ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#3 0x7683c620 in PROCEndProcess(void*, unsigned int, int) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#4 0x7661e6a2 in SafeExitProcess(unsigned int, int, ShutdownCompleteAction) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#5 0x7661f3a0 in EEPolicy::HandleFatalError(unsigned int, unsigned int, char16_t const*, _EXCEPTION_POINTERS*, char16_t const*, char16_t const*) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#6 0x7668cd3c in ProcessCLRException ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#7 0x7669046e in UnwindManagedExceptionPass1(PAL_SEHException&, _CONTEXT*) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#8 0x76690620 in DispatchManagedException(PAL_SEHException&, bool) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcor--Type for more, q to quit, c to continue without paging--
eclr.so
#9 0x7668c110 in HandleHardwareException(PAL_SEHException*) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#10 0x76818578 in SEHProcessException(PAL_SEHException*) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#11 0x76819702 in common_signal_handler(int, siginfo_t*, void*, int, ...) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#12 0x76818f8a in sigill_handler(int, siginfo_t*, void*) ()
from /root/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20155.1/libcoreclr.so
#13
#14 0x6fad85e6 in ?? ()
#15 0x6fad85d6 in ?? ()

category:correctness
theme:emitter
skill-level:beginner
cost:small

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't add an area label to this Issue.

Checkout this page to find out which area owner to ping, or please add exactly one area label to help train me in the future.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Mar 8, 2020
@jkotas jkotas added arch-arm32 os-linux Linux OS (any supported distro) labels Mar 8, 2020
@jeffschwMSFT jeffschwMSFT added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 26, 2020
@jeffschwMSFT
Copy link
Member

@BruceForstall

@BruceForstall
Copy link
Member

I don't believe running dotnet, or dotnet generated apps, in qemu, is a supported scenario. This could easily be an issue with qemu itself. It looks like the code being run above is correct, and not illegal.

@janvorli @jkotas

@jkotas
Copy link
Member

jkotas commented Mar 27, 2020

You are right that we do not test nor support qemu.

It looks like the code being run above is correct, and not illegal.

The ARM manual in the LDMIA section says:

Encoding T2 does not support a list containing only one register. If an LDMIA instruction with just
one register <Rt> in the list is assembled to Thumb and encoding T1 is not available, it is assembled
to the equivalent LDR{<c>}{<q>} <Rt>, [<Rn>]{, #4} instruction.

If I am reading this right, the instruction that we are emitting here has undefined behavior. We should fix this regardless.

@jkotas jkotas added bug and removed os-linux Linux OS (any supported distro) labels Mar 27, 2020
@jkotas jkotas changed the title illegal instruction when run dotnet to create a console project on qemu arm-vexpress vm [ARM32] illegal instruction when run dotnet to create a console project Mar 27, 2020
@jkotas jkotas added this to the 5.0 milestone Mar 27, 2020
@janvorli
Copy link
Member

The issue with using undefined / deprecated instructions was also reported here where valgrind was complaining about the LDMIA with single register and also about sub.w sp, r8, #80 where the doc says that when the destination register of sub/add is SP, the source should also be SP.
See #33727

@BruceForstall BruceForstall self-assigned this Mar 27, 2020
@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label Mar 27, 2020
@BruceForstall
Copy link
Member

Agreed we should fix the illegal single-register LDM. We can use this issue to track that.

@BruceForstall
Copy link
Member

I'm going to close this since the same issue is tracked in #33727

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm32 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Projects
None yet
Development

No branches or pull requests

6 participants