[mono-vb] VBNC crasch when using marshalAs on arrays in struct
Lars Lindholm
lars.lindholm at vtab.se
Thu Aug 11 08:56:03 UTC 2016
Hi,
I have a structure I need to apply to an byte array. To do this I have a
VB Structure with marshaling commands to enforce proper packing and
ensure correct interpretation.
This have worked in a vs environment before and now I'm trying to move
over to a monodevelop environment. I have tried with the latest
mono-basic compiler from the github repo(Mono 4.6 - master/c93133d).
When trying to compile I get: vbnc : Command line : error VBNC99999:
Unexpected error: Specified cast is not valid.
This might be related to this bug:
https://bugzilla.xamarin.com/show_bug.cgi?id=2867
I'm attaching a complete output and source for a minimal example where
commenting away the marshal command makes it compile and leaving it in
makes it crasch.
Best regards
Lars Lindholm
-------------- next part --------------
Building Solution: Mono-Basic-Crasch (Debug|x86)
Building: Mono-Basic-Crasch (Debug|x86)
Build started 7/28/2016 3:38:32 PM.
__________________________________________________
Project "/home/larlin/Projects/Mono-Basic-Crasch/Mono-Basic-Crasch/Mono-Basic-Crasch.vbproj" (Build target(s)):
Target PrepareForBuild:
Configuration: Debug Platform: x86
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Target CoreCompile:
Tool /usr/lib/mono/4.5/vbnc.exe execution started with arguments: /noconfig /debug+ /out:obj/x86/Debug/Mono-Basic-Crasch.exe Application.vb AssemblyInfo.vb /target:exe /define:"CONFIG=\"Debug\",PLATFORM=\"x86\"" /reference:/usr/lib/mono/4.0-api/System.dll /reference:/usr/lib/mono/4.0-api/System.Core.dll /rootnamespace:MonoBasicCrasch
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.6 - master/c93133d)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.
vbnc : Command line : error VBNC99999: Unexpected error: Specified cast is not valid.
at Mono.Cecil.SignatureWriter.WriteMarshalInfo (Mono.Cecil.MarshalInfo marshal_info) <0x40da50d0 + 0x0016e> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.GetMarshalInfoSignature (IMarshalInfoProvider owner) <0x40da4fe0 + 0x00043> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddMarshalInfo (IMarshalInfoProvider owner) <0x40da4eb0 + 0x0004b> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddField (Mono.Cecil.FieldDefinition field) <0x40da4680 + 0x00153> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddFields (Mono.Cecil.TypeDefinition type) <0x40da4600 + 0x0004b> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) <0x40d9c5f0 + 0x00193> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddNestedTypes (Mono.Cecil.TypeDefinition type) <0x40da4030 + 0x00077> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) <0x40d9c5f0 + 0x0023b> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddTypeDefs () <0x40d9c570 + 0x0004b> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildTypes () <0x40d9b550 + 0x00033> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildModule () <0x40d98bd0 + 0x000e3> in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildMetadata () <0x40d98b80 + 0x0000f> in <filename unknown>:0
at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) <0x40d98aa0 + 0x0002b> in <filename unknown>:0
at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) <0x40d93930 + 0x001b3> in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) <0x40d93840 + 0x00067> in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) <0x40d937b0 + 0x0004b> in <filename unknown>:0
at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) <0x40d93770 + 0x0002f> in <filename unknown>:0
at vbnc.Compiler.Compile () <0x40c75df0 + 0x01057> in <filename unknown>:0
Compilation took 00:00:00.6815140
/usr/lib/mono/4.5/Microsoft.VisualBasic.targets: error : Compiler crashed with code: 255.
Task "Vbc" execution -- FAILED
Done building target "CoreCompile" in project "/home/larlin/Projects/Mono-Basic-Crasch/Mono-Basic-Crasch/Mono-Basic-Crasch.vbproj".-- FAILED
Done building project "/home/larlin/Projects/Mono-Basic-Crasch/Mono-Basic-Crasch/Mono-Basic-Crasch.vbproj".-- FAILED
Build FAILED.
Errors:
---------------------- Done ----------------------
Build: 1 error, 0 warnings
-------------- next part --------------
Imports System.Runtime.InteropServices
Public Class Application
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Ansi)> _
Public Structure CONFIG
Public Position As Byte
' Comment the line below to make the example compile
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> _
Public Name() As Byte
End Structure
Public Shared Sub Main()
System.Console.WriteLine("Hello world!")
End Sub
End Class
More information about the Mono-vb
mailing list