cosmosos / il2cpu Goto Github PK
View Code? Open in Web Editor NEWIL2CPU is a compiler for .NET IL code to compile to assembly language for direct booting.
License: BSD 3-Clause "New" or "Revised" License
IL2CPU is a compiler for .NET IL code to compile to assembly language for direct booting.
License: BSD 3-Clause "New" or "Revised" License
From @mterwoord on July 30, 2015 19:1
Right now, the only way to get control over struct layout, is to use LayoutKind.Explicit and the FieldOffsetAttribute, but this isn't portable between bitnesses.. See for example, the DataLookupEntry and related structs.
Copied from original issue: CosmosOS/Cosmos#173
SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString redefined when nasm compiles. I try to compile Aura_OS from this branch: https://github.com/aura-systems/Aura-Operating-System/tree/impl-net5
After more investigation, it appears to be related to the FTP Server.
1>IL2CPU task took 00:02:26.0802791
1>bin\Debug\net5.0\Aura_OS.asm:988207: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988217: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0000' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988225: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0001' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988234: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0001.End' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988236: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0003' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988240: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0008' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988248: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0009' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988252: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000A' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988260: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000B' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988264: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000D' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988272: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000E' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988279: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000F' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988294: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_000F.NoExceptionAfterCall' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988296: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0014' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988303: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0015' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988308: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0016' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988312: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_001B' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988319: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_001C' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988327: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_001D' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988334: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_001E' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988338: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_001F' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988343: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0020' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988351: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0021' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988358: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0022' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988366: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0023' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988383: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0023.NoExceptionAfterCall' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988385: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_0028' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988392: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_002A' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988396: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_002C' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988403: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.IL_002D' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988408: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.END__OF__METHOD_NORMAL' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988415: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.END__OF__METHOD_EXCEPTION' redefined
1>bin\Debug\net5.0\Aura_OS.asm:988418: error: symbol `SystemUInt32PrivateImplementationDetailsComputeStringHashSystemString.END__OF__METHOD_EXCEPTION__2' redefined
1>C:\Users\valentinbreiz\.nuget\packages\cosmos.build\0.1.0-localbuild20211021045217\build\Cosmos.Build.targets(206,9): error MSB6006: "nasm.exe" exited with code 1.
1>Nasm task took 00:00:07.6073003
1>Done building project "Aura_OS.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Clone Aura_OS, try to compile using .net 5.
Devkit
The endfinally/endfilter op declares a data member to store the leave address and the leave op stores the current address in the data member, but the address should be stored in the stack.
For example, if a method calls itself from a finally block (which comes from a leave address X), and the finally block in the called method comes from a leave address Y, then Y is stored in the data member and, after returning, endfinally/endfilter will jump address Y, but it should jump to X.
Related to #16
Currently IL2CPU is targeting netcoreapp2.0 and win7-x86, so it can only be run on Windows and it uses the .NET Core 2.0 assemblies that ship as part of the compiler, which are built for 32-bit systems. We should pass all references to IL2CPU, and the assemblies should be loaded in a separate context.
netcoreapp2.0
), and it would be too much work to support all frameworks, so we can either document what is the recommended framework or, as plugs are part of Cosmos, we can prevent the compilation for unsupported frameworks (maybe using an MSBuild Implement sub.ovf, for:
From @mterwoord on July 27, 2015 13:28
See ECMA 335, partition 3.
Chapter 1.5
Copied from original issue: CosmosOS/Cosmos#166
Sometimes during TestRunner "routine" I get this error that make kernel fails.
This is the complete exception:
08:14:10.687024 Msg: Warning: Exists
08:14:25.043802 Msg: Detecting fields for type 'Cosmos.Debug.Symbols.FIELD_INFO'
08:14:25.336979 Msg: Detecting fields for type 'Cosmos.Debug.Symbols.FIELD_MAPPING'
08:15:12.638903 Msg: Detecting fields for type 'Cosmos.Debug.Symbols.AssemblyFile'
08:15:12.706129 Msg: Error: Exception: System.InvalidOperationException: SqliteConnection does not support nested transactions.
08:15:12.706562 Msg: at Microsoft.Data.Sqlite.SqliteConnection.BeginTransaction(IsolationLevel isolationLevel)
08:15:12.714657 Msg: at Microsoft.Data.Sqlite.SqliteConnection.BeginTransaction()
08:15:12.717210 Msg: at Cosmos.Debug.Symbols.SqliteBulkCopy.WriteToServer(IDataReader reader) in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\SqliteBulkCopy.cs:line 36
08:15:12.737130 Msg: at Cosmos.Debug.Symbols.DebugInfo.BulkInsertT in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\DebugInfo.cs:line 520
08:15:12.753046 Msg: at Cosmos.Debug.Symbols.DebugInfo.AddAssemblies(List`1 aAssemblies, Boolean aFlush) in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\DebugInfo.cs:line 395
08:15:12.759681 Msg: at Cosmos.Debug.Symbols.DebugInfo.Dispose() in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\DebugInfo.cs:line 545
08:15:12.797378 Msg: at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 246
08:15:12.846716 Error: Error invoking 'dotnet'.
After adding some code (CommandEDIT class), I started getting this error.
1>------ Erstellen gestartet: Projekt: EtorumOS, Konfiguration: Debug Any CPU ------
1>Analysetools werden übersprungen, um den Build zu beschleunigen. Sie können den Befehl „Build“ oder „Rebuild“ ausführen, um Analyzer auszuführen.
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\ETOScript\Commands\CommandCD.cs(2,7,2,18): warning CS0105: Die using-Direktive für "EtorumOS.IO" ist bereits vorher in diesem Namespace aufgetreten.
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\ETOScript\Commands\CommandHELP.cs(2,7,2,18): warning CS0105: Die using-Direktive für "EtorumOS.IO" ist bereits vorher in diesem Namespace aufgetreten.
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\ETOScript\Commands\Command.cs(150,17,150,34): warning CS0472: Das Ergebnis des Ausdrucks ist immer "false", da ein Wert vom Typ "int" niemals NULL vom Typ "int?" ist.
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\Resources\ResourceManager.cs(20,30,20,41): warning CS0649: Dem Feld "ResourceManager.ZapLightPSF" wird nie etwas zugewiesen, und es hat immer seinen Standardwert von "null".
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\ETOScript\Commands\CommandEDIT.cs(15,63,15,73): warning CS0414: Dem Feld "CommandEDIT.prevScollY" wurde ein Wert zugewiesen, der aber nie verwendet wird.
1>C:\Users\user\source\repos\EtorumOS\EtorumOS\ETOScript\Commands\CommandEDIT.cs(15,46,15,57): warning CS0414: Dem Feld "CommandEDIT.prevScrollX" wurde ein Wert zugewiesen, der aber nie verwendet wird.
1>EtorumOS -> C:\Users\user\source\repos\EtorumOS\EtorumOS\bin\Debug\net6.0\EtorumOS.dll
1>Executing IL2CPU on assembly
1>Kernel Base: Cosmos.System.Kernel
1>Checking target assembly: C:\Users\user\source\repos\EtorumOS\EtorumOS\bin\Debug\net6.0\EtorumOS.dll
1>IL2CPU : warning : Loading plugs from assembly: EtorumOS.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Debug.Kernel.Plugs.Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.System2_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_INFO'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_MAPPING'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.MethodIlOp'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.Document'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.AssemblyFile'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.Method'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.LOCAL_ARGUMENT_INFO'
1>IL2CPU : error : Exception: System.InvalidOperationException: Value must be set.
1> at Microsoft.Data.Sqlite.SqliteParameter.Bind(sqlite3_stmt stmt)
1> at Microsoft.Data.Sqlite.SqliteParameterCollection.Bind(sqlite3_stmt stmt)
1> at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
1> at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
1> at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
1> at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
1> at IL2CPU.Debug.Symbols.SqliteBulkCopy.WriteToServer(IDataReader reader) in C:\Users\user\source\repos\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\SqliteBulkCopy.cs:line 63
1> at IL2CPU.Debug.Symbols.DebugInfo.BulkInsert[T](String aTableName, IList`1 aList, Int32 aFlushSize, Boolean aFlush) in C:\Users\user\source\repos\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\DebugInfo.cs:line 512
1> at IL2CPU.Debug.Symbols.DebugInfo.WriteAllLocalsArgumentsInfos(IList`1 aInfos) in C:\Users\user\source\repos\Cosmos\IL2CPU\source\IL2CPU.Debug.Symbols\DebugInfo.cs:line 487
1> at Cosmos.IL2CPU.AppAssembler.FinalizeDebugInfo() in C:\Users\user\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 414
1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\user\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 197
1>IL2CPU task took 00:00:23.6525567
1>Die Erstellung des Projekts "EtorumOS.csproj" ist abgeschlossen -- FEHLER.
========== Build: 0 erfolgreich, 1 Fehler, 2 aktuell, 0 übersprungen ==========
========== Erstellen wurde am 2:35 PM gestartet und dauerte 24,750 Sekunden ==========
Can be, most likely, reproduced with this repo:
https://github.com/GoldenretriverYT/EtorumOS/tree/4b9d38be586a8833b6e609e2514b0e5d197d5180
During the plugging of DirectoryInfo class I've found a bug of IL2CPU, an internal method of the Path class is calling this unsafe code:
private static unsafe bool StartsWithOrdinal(char* source, uint sourceLength, string value)
{
if (sourceLength < (uint)value.Length) return false;
for (int i = 0; i < value.Length; i++)
{
if (value[i] != source[i]) return false;
}
return true;
}
one can - for example - call it in this way (similar of what is done in CoreFx):
String pathAsString = @"0:\DiTest";
int pathLength = pathAsString.Length;
bool val1;
fixed (char* path = pathAsString)
{
val1 = StartsWithOrdinal(path, (uint)pathLength, "\\\\?\\");
}
while nothing has value "null" you will get NRE on Ldind_U2.
The hypothesis is that - in reality - the null pointer is wrongly put onto the stack by previous opcodes and
Ldind_U2 is not really wrong.
Trying to do this code on a char when the value interpreted as number (the codepoint) is > SHORT_MAX this tests fails:
private byte GetByte(char ch)
{
/* ch is in reality an ASCII character? */
//if (ch >= 0 && ch < 127)
if (ch < 127)
{
//mDebugger.SendInternal($"ch {(ushort)ch} is ASCII");
return (byte)ch;
}
return 42;
}
For the same cause Char.IsSurrugate(ch) returns false.
This the IL that this code generates:
GetByte:
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.s 7F
IL_0004: clt
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0010
IL_000A: nop
IL_000B: ldarg.1
IL_000C: conv.u1
IL_000D: stloc.1
IL_000E: br.s IL_0015
IL_0010: ldc.i4.s 2A
IL_0012: stloc.1
IL_0013: br.s IL_0015
IL_0015: ldloc.1
IL_0016: ret
The stack corruption detection fails when there are complex conditions, because there are branches which implicitly assume that some IL instructions will only be executed on certain conditions (specific stack differences).
A sample, in C#: SharpLab
... truncated ... -> stack difference = base
ΔSD -> Δ Stack Difference
[ΔSD]
[ +4]IL_0007: ldloc.0
[ -4]IL_0008: brfalse.s IL_000f // stack difference = base
[ +4]IL_000a: ldloc.1
[ +4]IL_000b: ldloc.2
[ -4]IL_000c: or
[ 0]IL_000d: br.s IL_0010 // stack difference = base + 4
[ +4]IL_000f: ldc.i4.0 // came from IL_0008 -> stack difference before op = base
[ -4]IL_0010: stloc.3 // came from IL_000d -> stack difference before op = base + 4
[ +4]IL_0011: ldloc.3
[ -4]IL_0012: brfalse.s IL_0023 // stack difference = base
// calculated stack difference: base + 4
// stack corruption on IL_0014
[ 0]IL_0014: nop
[ +8]IL_0015: ldstr "True condition"
[ -8]IL_001a: call void [mscorlib]System.Console::WriteLine(string)
[ 0]IL_001f: nop
[ 0]IL_0020: nop
[ 0]IL_0021: br.s IL_0030 // stack difference -> base
[ 0]IL_0023: nop // came from IL_0012 -> stack difference before op = base
[ +8]IL_0024: ldstr "False condition"
[ -8]IL_0029: call void [mscorlib]System.Console::WriteLine(string)
[ 0]IL_002e: nop
[ 0]IL_002f: nop
[ 0]IL_0030: ret
there is no document to compile by il2cpu and how to enter the args.
I think it would be interesting to call X# methods from IL (C#) using ldftn
/calli
. The assembler plug would be replaced with managed code, which means better portability.
public static void SendNumber(int number)
{
ldarg.0
ldftn
calli
}
[XSharpMethod("DebugStub_SendSimpleNumber")]
private static void DoSendNumber(int number);
We just need to handle the attribute in ldftn
, where we just emit push label
.
ifdef
the calls, because the debug stub may be disabled (i.e. it's not emitted), so we need to handle that somehow.Hey guys, I have a really weird issue, I have this code (https://pastebin.com/JQiqN3py) and it's giving me this exception (https://pastebin.com/TQbFKTCW ). I have also tried commenting out the code and it still had the same exception (potentially a problem with the build system?). How can I fix this?
Cheers!
IL2CPU
The program should build successfully
The code for part of the Kernel
string textEditor() { bool inTextEditor = true; int x = 1; string[] textToSave = {"/",}; string savedText = "No text"; while (inTextEditor == true) { textToSave[x] = input; x++; if (input == "t-exit") { inTextEditor = false; } } savedText = string.Join("", textToSave); return savedText; }
Build error in IL2CPU line 1
Paste this code into your kernel:
string textEditor() { bool inTextEditor = true; int x = 1; string[] textToSave = {"/",}; string savedText = "No text"; while (inTextEditor == true) { textToSave[x] = input; x++; if (input == "t-exit") { inTextEditor = false; } } savedText = string.Join("", textToSave); return savedText; }
User Kit 20200708
Currently, we use the real types to interpret the stack types and implement the ops.
We should use the "basic CLI types" (III.1.1):
- A subset of the full numeric types (int32, int64, native int, and F).
- Object references (O) without distinction between the type of object referenced.
- Pointer types (native unsigned int and &) without distinction as to the type pointed to.
The operand type tables (III.1.5) are based on these types, so we should use them to check the stack types and implement the ops.
There are 2 options to implement this:
StackType
), which holds the real type and the "basic CLI type", which would be evaluated in the constructor of StackType
.TypeOnStackIsInt32
and TypeOnStackIsObjectRef
).This happened when i tried to render some text with figgle (Console.WriteLine(FiggleFonts.Alligator.Render("some text"));
. logs:
1>Message: Executing IL2CPU on assembly
1>Message: Kernel Base: Cosmos.System.Kernel
1>Message: Checking target assembly: C:\Users\waver\source\repos\kocmoc\kocmoc\bin\Debug\netcoreapp2.0\cosmos\kocmoc.dll
1>IL2CPU : error : Exception: System.ArgumentException: Interface maps for generic interfaces on arrays cannot be retrieved.
1> at System.RuntimeType.GetInterfaceMap(Type ifaceType)
1> at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 559
1> at Cosmos.IL2CPU.ILScanner.ScanQueue() in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 770
1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 264
1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Development\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 200
1>IL2CPU task took 00:00:03.2715992
There are many cases on .NET Core where there are internal types with the same full name as public types, and it can cause unexpected errors, as assembly names are currently ignored.
One example is System.Environment
, which is a public type in the System.Runtime.Extensions
assembly: Environment.cs, but there's also an internal version, in the System.Private.CoreLib
assembly: Environment.cs.
The current debug symbols implementation has some weak points:
The following changes should be done on the debug symbols implementation (probably both at the same time):
We can replace SQLite with LiteDB, which is fully managed, and has good performance.
The debug symbols should contain debug info that allows the debug engine to retrieve debug data from the pdb. The following data is important:
So sequence points and source documents would no longer be present in the debug symbols, and would be loaded by the debug engine. It would be possible to debug any assembly, including the runtime ones.
From @fanoI on August 14, 2016 16:53
I were trying to port BigInteger to Cosmos the .NET version is too complex and will need to plug 99% of .NET so I've found this implementation that is really more simple:
http://www.codeproject.com/Articles/2728/C-BigInteger-Class
SingleImpl.cs is now using BigInteger as the range of float overcome that of ulong but now the code does not compile anymore this is the error:
6:44:13.265590 Msg: Detecting fields for type 'Cosmos.Debug.Common.Method'
06:44:13.281600 Msg: Error: Exception: System.Exception: Error compiling method 'SystemBooleanSystemSingleEqualsSystemObject': System.Exception: Error interpreting stacktypes for IL_0006: Brtrue ---> System.Exception: Invalid type in PopTypes! (Type = 'System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
06:44:13.283602 Msg: in Cosmos.IL2CPU.ILOpCodes.OpBranch.DoInterpretStackTypes(Boolean& aSituationChanged) in C:\Users\fano\Documents\GitHub\Cosmos\source\Cosmos.IL2CPU\ILOpCodes\OpBranch.cs:riga 115
06:44:13.284603 Msg: in Cosmos.IL2CPU.ILOpCode.InterpretStackTypes(IDictionary2 aOpCodes, Stack1 aStack, Boolean& aSituationChanged, Int32 aMaxRecursionDepth) in C:\Users\fano\Documents\GitHub\Cosmos\source\Cosmos.IL2CPU\ILOpCode.cs:riga 413
06:44:13.285604 Msg: --- Fine della traccia dello stack dell'eccezione interna ---
I suppose it is something done in BigInteger.cs as removing the variable declaration it compiles again.
Copied from original issue: CosmosOS/Cosmos#436
Actually IL2CPU is opening the file and creating an hexdup of it and then uses the X# instruction 'db' to include it in the assembler file, sadly this does work when the file becomes too much big (for example 200 KB) as NASM doesn't compile anymore.
A possible solution to this is to use the NASM directive incbin instead for these cases.
See here for one example: http://forum.codecall.net/topic/65317-assembly-file-io-and-incbin-win32-nasm/
When I try to use this code return new List<uint>(H);
inside a List<uint>
function I have this error:
1>IL2CPU : error : Exception: System.ArgumentException: Interface maps for generic interfaces on arrays cannot be retrieved.
1> at System.RuntimeType.GetInterfaceMap(Type ifaceType)
1>Message: C:\Users\valentinbreiz\Documents\GitHub\Aura-Operating-System\Aura Operating System\Aura OS\bin\Debug\netstandard2.0\Aura_OS.dll
1>Message: C:\Users\valentinbreiz\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.Core_Asm.dll
1>Message: C:\Users\valentinbreiz\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.Core_Plugs.dll
1>Message: C:\Users\valentinbreiz\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.Plugs.Asm.dll
1>Message: C:\Users\valentinbreiz\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.System2_Plugs.dll
1> at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in C:\Users\valentinbreiz\Documents\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 561
1> at Cosmos.IL2CPU.ILScanner.ScanQueue() in C:\Users\valentinbreiz\Documents\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 775
1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in C:\Users\valentinbreiz\Documents\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 253
1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\valentinbreiz\Documents\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 168
Got this cryptic error with the most recent devkit build even on a stock, out of box C# kernel. Modified the IL2CPU solution to give the internal error in the debug log.
Modified Stack Trace:
1>------ Build started: Project: CosmosKernel1, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(157,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
1>CosmosKernel1 -> C:\Users\MYUSERNAME\Desktop\CosmosKernel1\CosmosKernel1\bin\Debug\netcoreapp2.0\cosmos\CosmosKernel1.dll
1>Message: Executing IL2CPU on assembly
1>Message: Kernel Base: Cosmos.System.Kernel
1>Message: Checking target assembly: C:\Users\MYUSERNAME\Desktop\CosmosKernel1\CosmosKernel1\bin\Debug\netcoreapp2.0\cosmos\CosmosKernel1.dll
1>IL2CPU : error : Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
1> at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1> at System.Reflection.RuntimeModule.GetTypes()
1> at System.Reflection.Assembly.GetTypes()
1> at Cosmos.IL2CPU.PlugManager.FindPlugImpls(IEnumerable`1 assemblies) in D:\Users\MYUSERNAME\Source\Repos\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\PlugManager.cs:line 79
1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in D:\Users\MYUSERNAME\Source\Repos\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 218
1> at Cosmos.IL2CPU.CompilerEngine.Execute() in D:\Users\MYUSERNAME\Source\Repos\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 200
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU : error : Exception: System.TypeLoadException: Could not load type 'XSharp.Assembler.AssemblerMethod' from assembly 'XSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b94a93fbb8fa3f4f'.
1>IL2CPU task took 00:00:05.0005391
1>Done building project "CosmosKernel1.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have a logging implementation that use two interfaces and implement all the methods, building is done correctly but at runtime i get a kernel panic indicating that an interface method is not found. Quite strange behavior.
Type
0x0000028D
TypeName: Zaphyros.Core.Logging.MultiTargetLogger, Zaphyros.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
InterfaceMethodId
0x0000033A
Not FOUND!
Implementation can be found on Zaphyros's logging feacture branch
hello, my OS is not booting, i asked that in the Cosmos Discord server, and Quajak told me that the error is in IL2CPU, and told me to open an issue here, ill post the logs and the code of BeforeRun() (where is the error in, according to the logs) below.
LOGS (its in portuguese, and i removed the \Users<user>\ from the path):
Compilação iniciada...
1>------ Compilação iniciada: Projeto: PlatinumOS, Configuração: Debug Any CPU ------
1>Ignorando analisadores para acelerar a construção. Você pode executar o comando 'Build' ou 'Rebuild' para executar os analisadores.
1>PlatinumOS -> C:\Users\source\repos\PlatinumOS\bin\Debug\net6.0\PlatinumOS.dll
1>Message: Executing IL2CPU on assembly
1>Message: Kernel Base: Cosmos.System.Kernel
1>Message: Checking target assembly: C:\Users\source\repos\PlatinumOS\bin\Debug\net6.0\PlatinumOS.dll
1>Message : warning : Loading plugs from assembly: Cosmos.Core_Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>Message : warning : Loading plugs from assembly: Cosmos.Core_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>Message : warning : Loading plugs from assembly: Cosmos.Debug.Kernel.Plugs.Asm, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>Message : warning : Loading plugs from assembly: Cosmos.System2_Plugs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_INFO'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_MAPPING'
1>IL2CPU : error : Exception: System.Exception: Error compiling method 'SystemVoidPlatinumOSKernelBeforeRun': System.ArgumentNullException: Value cannot be null. (Parameter 'aType')
1> at Cosmos.IL2CPU.ILOp.SizeOfType(Type aType) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOp.cs:line 619
1> at Cosmos.IL2CPU.ILOpCode.DoStackAnalysis(Stack1 aStack, UInt32& aStackOffset) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOpCode.cs:line 356 1> at Cosmos.IL2CPU.MethodAnalysis.ILMethod.Analyse() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\MethodAnalysis\ILMethod.cs:line 48 1> at Cosmos.IL2CPU.AppAssembler.AnalyseMethodOpCodes(Il2cpuMethodInfo aMethod, List
1 aOpCodes) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 493
1> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List1 aOpCodes) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 475 1> ---> System.ArgumentNullException: Value cannot be null. (Parameter 'aType') 1> at Cosmos.IL2CPU.ILOp.SizeOfType(Type aType) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOp.cs:line 619 1> at Cosmos.IL2CPU.ILOpCode.DoStackAnalysis(Stack
1 aStack, UInt32& aStackOffset) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILOpCode.cs:line 356
1> at Cosmos.IL2CPU.MethodAnalysis.ILMethod.Analyse() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\MethodAnalysis\ILMethod.cs:line 48
1> at Cosmos.IL2CPU.AppAssembler.AnalyseMethodOpCodes(Il2cpuMethodInfo aMethod, List1 aOpCodes) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 493 1> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List
1 aOpCodes) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 475
1> --- End of inner exception stack trace ---
1> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List1 aOpCodes) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 483 1> at Cosmos.IL2CPU.ILScanner.Assemble() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 1044 1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable
1 plugsAssemblies) in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 278
1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Development\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 223
1>IL2CPU task took 00:00:12.7880164
1>Projeto de compilação pronto "PlatinumOS.csproj" -- FALHA.
========== Compilação: 0 bem-sucedida, 1 com falha, 0 atualizada, 0 ignorada ==========
=========== Decorrido 00:13,445 =========
CODE BeforeRun():
protected override void BeforeRun()
{
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
var fstype = fs.GetFileSystemType;
Console.ForegroundColor = ConsoleColor.Green;
Console.Beep(300, 100);
Console.WriteLine($"[OK] Initialized File System: {fstype}");
Thread.Sleep(2000);
Console.ResetColor();
if (!Directory.Exists("0:\\System\\"))
{
Console.ForegroundColor = ConsoleColor.Green;
fs.CreateDirectory("0:\\System\\");
File.Create("0:\\System\\SystemConfig.cfg");
File.WriteAllText("0:\\System\\SystemConfig.cfg", "SystemFilesCreated");
fs.CreateDirectory("0:\\Users\\");
Console.Beep(300, 100);
Console.WriteLine($"[OK] Created System Configs");
Console.ResetColor();
}
else
{
}
if (!Directory.Exists("0:\\Users\\"))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[NO] User Found");
Console.ResetColor();
Console.Write("New User: ");
var userName = Console.ReadLine();
Console.Write("New Password: ");
var passWord = Console.ReadLine();
Console.WriteLine($"User {userName} Created");
File.WriteAllText($"0:\\Users\\passwords.db", passWord);
File.WriteAllText($"0:\\Users\\users.db", userName);
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Beep(300, 100);
Console.Write("[OK] User Found");
Console.ResetColor();
var username = File.ReadAllText($"0:\\Users\\users.db");
Console.WriteLine($"Logging in {username}...");
Thread.Sleep(1500);
Console.Beep(50, 200);
Console.Beep(250, 200);
Console.Beep(500, 200);
Console.Beep(750, 200);
Console.Beep(1000, 200);
Console.WriteLine("Logged in.");
Console.WriteLine($"Welcome to PlatinumOS, {username}.");
Console.Clear();
}
}
Having this simply IEnumerable function:
static IEnumerable<Command> RegisterAllCommands()
{
yield return new Echo();
yield return new Help();
}
If I simply call it:
RegisterAllCommands();
I get Stack Overflow exception, a normal Net Core application does little better simply blocks as the IEnumerable is not evalutated.
Doing instead a simple empty foreach (I know I cannot call .ToList() / .ToArray() as that will be a call to a Linq method):
foreach (var c in RegisterAllCommands()) { }
I get this error from IL2CPU itself that make the compilation fail:
Error Exception: System.ArgumentException: 'this' type cannot be an interface itself
IL2CPU
Should compile fine
Compilation fails
2>Detecting fields for type 'IL2CPU.Debug.Symbols.Method'
2>IL2CPU : error : Exception: System.Exception: Error compiling method 'SystemInt32cs_ttfTTFstbtt__run_charstringcs_ttfstbtt_fontinfopointerSystemInt32cs_ttfTTFstbtt__csctxpointer': System.NotSupportedException: Specified method is not supported.
2> at Cosmos.IL2CPU.X86.IL.Conv_R4.Execute(Il2cpuMethodInfo aMethod, ILOpCode aOpCode) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\IL\Conv_R4.cs:line 37
2> at Cosmos.IL2CPU.AppAssembler.EmitInstructions(Il2cpuMethodInfo aMethod, List`1 aCurrentGroup, Boolean& emitINT3) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 632
2> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 476
2> ---> System.NotSupportedException: Specified method is not supported.
2> at Cosmos.IL2CPU.X86.IL.Conv_R4.Execute(Il2cpuMethodInfo aMethod, ILOpCode aOpCode) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\IL\Conv_R4.cs:line 37
2> at Cosmos.IL2CPU.AppAssembler.EmitInstructions(Il2cpuMethodInfo aMethod, List`1 aCurrentGroup, Boolean& emitINT3) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 632
2> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 476
2> --- End of inner exception stack trace ---
2> at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 482
2> at Cosmos.IL2CPU.ILScanner.Assemble() in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 1044
2> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 278
2> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 222
Clone this repository: https://github.com/GoldenretriverYT/CosmosTTF/tree/implement-new-ttf
Then try to add it to your Cosmos OS. The method causing this error is stbtt__run_charstring in NewTTFLib.cs
Latest DevKit
From @lukaandjelkovic on November 2, 2015 12:39
From Gitter
int[,] map = new int[120, 25];
When i use multidimensional arrays, it shows this error:
SystemVoidSystemInt32arraySetSystemInt32SystemInt32SystemInt32' undefined C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets
ThontOS\TriangleOS\bin\tt\TriangleBoot.asm:370905: error: symbol `SystemVoidSystemInt32arrayctorSystemInt32SystemInt32' undefined
Copied from original issue: CosmosOS/Cosmos#231
https://gist.github.com/valentinbreiz/8b099c7acd93783e90d71e644f070519
Builds fine until it goes to YASM part
Edit: After a deeper investigation this method seems to be the problem:
private static int Str_Dump( ILuaState lua )
{
lua.L_CheckType( 1, LuaType.LUA_TFUNCTION );
lua.SetTop( 1 );
var bsb = new ByteStringBuilder();
LuaWriter writeFunc =
delegate(byte[] bytes, int start, int length)
{
bsb.Append(bytes, start, length);
return DumpStatus.OK;
};
if( lua.Dump( writeFunc ) != DumpStatus.OK )
return lua.L_Error( "unable to dump given function" );
lua.PushString( bsb.ToString() );
return 1;
}
Specially LuaWriter writeFunc = delegate(byte[] bytes, int start, int length)
From @jp2masa on February 21, 2017 19:19
Currently we don't handle generic methods on arrays.
Example:
IEnumerable<string> xEnumerable;
string[] xArray = new string[] { "a", "b", "c" };
xEnumerable = xArray;
xEnumerable.GetEnumerator();
This code won't work, because Array doesn't have an implementation for this method. Array can be used as ICollection<T>, IEnumerable<T> and IList<T>
The implementations for these interfaces are in System.SZArrayHelper, but the compiler needs an implementation that replaces calls to the generic method on arrays with calls to the methods in SZArrayHelper.
Copied from original issue: CosmosOS/Cosmos#583
The virtual machine shuts down when reading from a null item from an array.
Example code:
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosWeirdError
{
public class Kernel : Sys.Kernel
{
MyClass[] SomeArray = new MyClass[2];
protected override void BeforeRun()
{
try
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
//This should cause a null refrence expection, but instead the VM shuts down or shows a random value
Console.WriteLine(SomeArray[1].SomeValue);
}
catch(Exception x)
{
Console.WriteLine(x.Message);
}
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
}
}
public class MyClass
{
public byte SomeValue;
}
}
If I go to the link in the README, I see a lot of text, but nothing seems to be about this project.
compiler/il2cpu
it should compile normally
l2cpu crashes and fails to compile
use vs2022 branch and attempt to compile prism
devkit, vs2022 branch
this issue can be fixeed by using an olt il2cpu repo version from at least march, so something changed recently
Same new project...
If I use the IF or SELECT CASE statement I receve a "Exception: System.NotImplementedException: OpCode 'Endfilter' not implemented! SAM D:\Sviluppo vb.Net\Sistemi Operativi\SAM\SAM\IL2CPU" error. I try to move this code to other Class with the same error.
Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)? I download all new three days ago on my Lattepanda alpha.
I try compiling the solution here, using the precompiled versione...
When there is the need to access a field of a class you have to add a ref variable to one of its plug method and use the attribute "FieldAccess" this could be easily become ugly when you need to access a lot of fields:
public static void Ctor(StreamWriter aThis, string path, bool append, Encoding encoding, int bufferSize,
[FieldAccess(Name = "System.IO.Stream System.IO.StreamWriter._stream")] ref Stream _stream,
[FieldAccess(Name = "System.Int32 System.IO.StreamWriter._charPos")] ref int _charPos,
[FieldAccess(Name = "System.Char[] System.IO.StreamWriter._charBuffer")] ref int _charLen,
[FieldAccess(Name = "System.Char[] System.IO.StreamWriter._charBuffer")] ref char[] _charBuffer,
[FieldAccess(Name = "System.Byte[] System.IO.StreamWriter._byteBuffer")] ref byte[] _byteBuffer,
[FieldAccess(Name = "System.Char[] System.IO.TextWriter.CoreNewLine")] ref char[] CoreNewLine
)
I've had two constructors to plug (one that take a String representing a File Path and an other in which you pass a Stream already created) and so the ideal solution would have been to use an utility function to initialize all the field but I will have to pass all the ref variables and their value to it that well defeat the purpose of it a lot!
My idea is leaving the attribute version for the old code (or replace it if we are so brave) and to use ref locals introduced in C# 7 to resolve this problem so the Init() would become:
private static void Init(Stream stream, bool append, CosmosEncoding encoding, int bufferSize, bool shouldLeaveOpen)
{
ref Stream _stream = ref GetFieldAccess("System.IO.Stream System.IO.StreamWriter._stream");
ref int _charPos = ref GetFieldAccess("System.Int32 System.IO.StreamWriter._charPos");
ref char[] _charBuffer = ref GetFieldAccess("System.Char[] System.IO.StreamWriter._charBuffer");
ref byte[] _byteBuffer = ref GetFieldAccess("System.Byte[] System.IO.StreamWriter._byteBuffer");
ref char[] CoreNewLine = ref GetFieldAccess("System.Char[] System.IO.TextWriter.CoreNewLine");
_stream = stream;
[...]
}
GetFieldAccess should have these prototypes:
ref object GetFieldAccess(String FieldName);
ref object[] GetFieldAccess(String FieldName);
unsafe ref void *GetFieldAccess(String FieldName); // Not working in C# 7.0 should be added in future releases
The convertion between a struct member to an object in IL2CPU might be not working for some reasons.
System.Exception: OpCode IL_007D: Ldflda tries to pop item at stack position 0 with type Aura_OS.Core.VBE+ModeInfo&, but actual type is System.IntPtr
public struct ModeInfo
{
public byte bpp;
}
Console.WriteLine("BPP: " + ModeInfo.bpp);
Have you checked Github Issues for similar errors?
I have checked for other issues, but the only one that came up was unrelated to the issue whence this has arisen.
Exception
Post the exception returned by Visual Studio
"Exception: System.Exception: Error compiling method 'SystemVoidSystemCProcessingProcMGRKStartSystemCProcessingCriProc': System.Exception: After interpreting stack types, nothing changed! (First instruction needing types = IL_0020: Ldvirtftn)"
** VS Output Logs **
Post the entire output log given by Visual Studio for the build
https://pastebin.com/KuyrsEjX
To Reproduce
Describe any changes done to a clean kernel for this error to occur.
Inserting a PITTimer with a possibly-defined abstract void will cause this error in IL2CPU
Screenshots
If applicable, add screenshots to help explain your problem.
Context
Before posting please confirm that the following are in order
[Yes] Both Cosmos VS Extensions are installed
[Yes] The Cosmos nuget packages are installed
Add any other context about the problem which might be helpful.
I am running the latest devkit.
dotnet gives this error: C:\Program Files\dotnet\sdk\7.0.302\NuGet.targets(398,5): error MSB3202: The project file "C:\Users\user\Downloads\IL2CPU-master\Common\source\Cosm
os.Build.Common\Cosmos.Build.Common.csproj" was not found. [C:\Users\user\Downloads\IL2CPU-master\IL2CPU-master\IL2CPU.sln]
C:\Program Files\dotnet\sdk\7.0.302\NuGet.targets(398,5): error MSB3202: The project file "C:\Users\user\Downloads\IL2CPU-master\Cosmos\source\Cosm
os.Debug.Kernel\Cosmos.Debug.Kernel.csproj" was not found. [C:\Users\user\Downloads\IL2CPU-master\IL2CPU-master\IL2CPU.sln]
Build FAILED.
C:\Program Files\dotnet\sdk\7.0.302\NuGet.targets(398,5): error MSB3202: The project file "C:\Users\user\Downloads\IL2CPU-master\Common\source\Cosm
os.Build.Common\Cosmos.Build.Common.csproj" was not found. [C:\Users\Eetu\Downloads\IL2CPU-master\IL2CPU-master\IL2CPU.sln]
C:\Program Files\dotnet\sdk\7.0.302\NuGet.targets(398,5): error MSB3202: The project file "C:\Users\user\Downloads\IL2CPU-master\Cosmos\source\Cosm
os.Debug.Kernel\Cosmos.Debug.Kernel.csproj" was not found. [C:\Users\user\Downloads\IL2CPU-master\IL2CPU-master\IL2CPU.sln]
0 Warning(s)
2 Error(s)
Implement sub.ovf.un, for:
As the tittle says, i was trying to use a variable of type BigInteger
:
var bi = new BigInteger(0);
Console.WriteLine($"BigInt: {bi}");
but got the next output on build:
buildOut.txt
From @charsleysa on January 4, 2016 8:39
Exception filtering is not yet supported.
For an example of Exception filtering in C# see http://pastebin.com/URkYjsiE
Copied from original issue: CosmosOS/Cosmos#320
From @Hetal728 on January 2, 2015 20:52
x64 instructions would be a great enhancement, I could give it a shot if I figure out where/what I have to do.
Copied from original issue: CosmosOS/Cosmos#44
I'm trying to make a shell in cosmos.
to split command and arguments this is the code i use:
public static IDictionary<string, Action<string[]>> commands = new Dictionary<string, Action<string[]>>(StringComparer.InvariantCultureIgnoreCase)
{
{"help", Help.Run}
};
protected override void Run()
{
string input = string.Empty;
Console.Write($"{Color.LtGreen}$ {Color.White}");
input = Console.ReadLine();
string command = Regex.Replace(input.Split()[0], @"[^0-9a-zA-Z\]+", "");
string[] args = input.Split(" ").Skip(1).ToArray();
args = args.Where(x => !String.IsNullOrWhiteSpace(x)).ToArray();
if (commands.Keys.Contains(command))
{
commands[command](args);
}
else
{
Console.WriteLine($"{Color.Red}Command Not Found!{Color.White}");
}
}
but when i compile error shows up.
sorry for bad grammar.
Hello,
Looks like the LoadBootEntries
method performs invalid ordering.
private void LoadBootEntries()
{
....
mBootEntries = mBootEntries.OrderBy(e => e.Value)
.OrderByDescending(e => e.Value.HasValue)
.ToDictionary(e => e.Key, e => e.Value);
....
}
Most likely, there should be the ThenByDescending
invocation instead of OrderByDescending
.
Here is the link.
we should implement ForceIncludeAttribute https://github.com/CosmosOS/IL2CPU/blob/master/source/IL2CPU.API/Attribs/ForceIncludeAttribute.cs
i dont know if it was at one point but it is not right now
Can you please publish a binary release so that I can download an .exe file rather than having to compile.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.