[Mono-dev] InterOp problems with 1.2.6pre2
Hi, mono 1.2.6pre1 and pre2 on Linux x86_64 can't run some C# bindings to a C library (an ac3 encoder), which works perfectly with vs2008beta2 and .net2.0 target on x86. You can get the sources at http://sourceforge.net/projects/aften/ in svn (revision 659). Compile it using cmake. To build C# bindings, pass -DBINDINGS_CS=1 to cmake. It worked with mono with the floating point samples case before I switched the bindings to using generics to have other types of samples supported (revision 651; though there were bugs in my code at that time ;). The testing code is this (remember the bindings are the troublemaker, not this code): using System; using System.IO; using System.Runtime.InteropServices; using Aften; namespace AftenTest { class MainClass { public static int Main(string[] args) { Console.WriteLine("Aften AC3 Encoding Demo"); if (args.Length != 2) { Console.WriteLine("Usage: "+Path.GetFileNameWithoutExtension(Environment.CommandLine)+" "); return -1; } EncodingContext context = FrameEncoder.GetDefaultsContext(); context.Channels = 2; context.AudioCodingMode = AudioCodingMode.Stereo; context.SampleRate = 48000; context.HasLfe = false; context.SystemParameters.ThreadsCount = 1; FrameEncoderInt16 encoder = new FrameEncoderInt16(ref context); using (FileStream inputStream = new FileStream(args[0], FileMode.Open)) using (FileStream outputStream = new FileStream(args[1], FileMode.CreateNew)) { inputStream.Seek(44, SeekOrigin.Begin); //Skip WAVE header... encoder.Encode(inputStream, outputStream); } Console.WriteLine("Done"); Console.ReadLine(); return 0; } } } The error I get with mono: mono AftenTest.exe ~/Projects/bill.wav encoded.ac3 Aften AC3 Encoding Demo ** ERROR **: Structure field of type Single[] can't be marshalled as LPArray aborting... Stacktrace: at AftenTest.MainClass.Main (string[]) <0x> at AftenTest.MainClass.Main (string[]) <0x000b8> at (wrapper runtime-invoke) AftenTest.MainClass.runtime_invoke_int_string[] (object,intptr,intptr,intptr) <0x> Native stacktrace: mono [0x51fe5d] /lib/libpthread.so.0 [0x2b86da225880] /lib/libc.so.6(gsignal+0x35) [0x2b86da6e4fa5] /lib/libc.so.6(abort+0x110) [0x2b86da6e6a00] /usr/lib/libglib-2.0.so.0 [0x2b86d9d80dec] /usr/lib/libglib-2.0.so.0(g_log+0x83) [0x2b86d9d80e73] mono [0x48ba04] mono [0x48e297] mono [0x48f449] mono [0x493642] mono [0x4942db] mono [0x500646] mono [0x50bc76] mono [0x50d3da] mono [0x43df62] [0x415b] Debug info from gdb: Using host libthread_db library "/lib/libthread_db.so.1". [Thread debugging using libthread_db enabled] [New Thread 0x2b86dac1bb40 (LWP 19911)] [New Thread 0x40224950 (LWP 19913)] [New Thread 0x40023950 (LWP 19912)] 0x2b86da22465b in read () from /lib/libpthread.so.0 3 Thread 0x40023950 (LWP 19912) 0x2b86da224f11 in nanosleep () from /lib/libpthread.so.0 2 Thread 0x40224950 (LWP 19913) 0x2b86da221c39 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 1 Thread 0x2b86dac1bb40 (LWP 19911) 0x2b86da22465b in read () from /lib/libpthread.so.0 Thread 3 (Thread 0x40023950 (LWP 19912)): #0 0x2b86da224f11 in nanosleep () from /lib/libpthread.so.0 #1 0x004d283f in collection_thread (unused=) at collection.c:34 #2 0x2b86da21d477 in start_thread () from /lib/libpthread.so.0 #3 0x2b86da78b3ad in clone () from /lib/libc.so.6 Thread 2 (Thread 0x40224950 (LWP 19913)): #0 0x2b86da221c39 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #1 0x004ce015 in timedwait_signal_poll_cond (cond=0x2b6be268, mutex=0x2b6be240, timeout=0x1, alertable=-1) at handles.c:1443 #2 0x004d05eb in _wapi_handle_timedwait_signal_handle ( handle=, timeout=0x0, alertable=0) at handles.c:1523 #3 0x004c06af in WaitForSingleObjectEx (handle=0x404, timeout=4294967295, alertable=0) at wait.c:200 #4 0x00498db1 in finalizer_thread (unused=) at gc.c:843 #5 0x00480b53 in start_wrapper (data=) at threads.c:550 #6 0x004c2677 in thread_start_routine (args=0x2b72a0d0) at threads.c:264 #7 0x004db4f2 in GC_start_routine () #8 0x2b86da21d477 in start_thread (
Re: [Mono-dev] InterOp problems with 1.2.6pre2
Hi I am wondering whether this problem is not interesting anyone? In the meanwhile I could pinpoint the troublemaker. Basically it is a float[] field I declared in the struct Encoding context: public struct EncodingContext { public EncodingParameters EncodingParameters; public Metadata Metadata; public Status Status; public SystemParameters SystemParameters; public int Verbosity; public int Channels; public AudioCodingMode AudioCodingMode; public bool HasLfe; public int SampleRate; internal A52SampleFormat SampleFormat; public float[] InitialSamples; // the trouble maker private IntPtr m_Context; } and I have and InterOp like this: public abstract class FrameEncoder { [DllImport( "aften.dll" )] private static extern void aften_set_defaults( ref EncodingContext context ); public static EncodingContext GetDefaultsContext() { EncodingContext context = new EncodingContext(); aften_set_defaults( ref context ); return context; } } This causes the crash/exception in mono (see quoted mail). So it doesn't have anything to do with generics as I suspected at first. If I change the float[] to IntPtr mono seems to work. As I said VS2008beta2 doesn't have any problems. Cheers, Prakash On the day of Saturday 24 November 2007 Prakash Punnoor hast written: > Hi, > > mono 1.2.6pre1 and pre2 on Linux x86_64 can't run some C# bindings to a C > library (an ac3 encoder), which works perfectly with vs2008beta2 and > .net2.0 target on x86. > > You can get the sources at http://sourceforge.net/projects/aften/ in svn > (revision 659). Compile it using cmake. To build C# bindings, > pass -DBINDINGS_CS=1 to cmake. It worked with mono with the floating point > samples case before I switched the bindings to using generics to have other > types of samples supported (revision 651; though there were bugs in my code > at that time ;). > > The testing code is this (remember the bindings are the troublemaker, not > this code): > > using System; > using System.IO; > using System.Runtime.InteropServices; > > using Aften; > > > namespace AftenTest > { > class MainClass > { > public static int Main(string[] args) > { > Console.WriteLine("Aften AC3 Encoding Demo"); > if (args.Length != 2) > { > > Console.WriteLine("Usage: > "+Path.GetFileNameWithoutExtension(Environment.CommandLine)+" > "); > return -1; > } > EncodingContext context = > FrameEncoder.GetDefaultsContext(); > context.Channels = 2; > context.AudioCodingMode = AudioCodingMode.Stereo; > context.SampleRate = 48000; > context.HasLfe = false; > context.SystemParameters.ThreadsCount = 1; > > FrameEncoderInt16 encoder = new FrameEncoderInt16(ref > context); > > using (FileStream inputStream = new FileStream(args[0], > FileMode.Open)) > using (FileStream outputStream = new FileStream(args[1], > FileMode.CreateNew)) > { > inputStream.Seek(44, SeekOrigin.Begin); //Skip > WAVE header... > encoder.Encode(inputStream, outputStream); > } > > Console.WriteLine("Done"); > Console.ReadLine(); > return 0; > } > } > } > > The error I get with mono: > mono AftenTest.exe ~/Projects/bill.wav encoded.ac3 > Aften AC3 Encoding Demo > > ** ERROR **: Structure field of type Single[] can't be marshalled as > LPArray aborting... > Stacktrace: > > at AftenTest.MainClass.Main (string[]) <0x> > at AftenTest.MainClass.Main (string[]) <0x000b8> > at (wrapper runtime-invoke) > AftenTest.MainClass.runtime_invoke_int_string[] > (object,intptr,intptr,intptr) <0x> > > Native stacktrace: > > mono [0x51fe5d] > /lib/libpthread.so.0 [0x2b86da225880] > /lib/libc.so.6(gsignal+0x35) [0x2b86da6e4fa5] > /lib/libc.so.6(abort+0x110) [0x2b86da6e6a00] > /usr/lib/libglib-2.0.so.0 [0x2b86d9d80dec] > /usr/lib/libglib-2.0.so.0(g_log+0x83) [0x2b86d9d80e73] > mono [0x48ba04] > mono [0x48e297] > mono [0x48f449] > mono [0x493642] > mono [0x4942db] > mono [0x500646] > mono [0x50bc76] > mono [0x50d3da] > mono [0x43df62] > [0x415b] > > Debug info fro
Re: [Mono-dev] InterOp problems with 1.2.6pre2
On the day of Friday 30 November 2007 Robert Jordan hast written: > Hi, > > Prakash Punnoor wrote: > > Hi > > > > I am wondering whether this problem is not interesting anyone? In the > > meanwhile I could pinpoint the troublemaker. > > well, we'd be interested but you did not post a reproducible > test case. Yes, I did, if you'd cared to fetch the sources and run the test code I mailed. Have you actually read the complete mail? > > Basically it is a float[] field I declared in the struct Encoding > > context: > > This doesn't look like a valid struct for p/invoke. Is this > the real code? Take a look at the sources... But yes, except that I omitted the inner structs and comments. > > Aften's context does not declare a float array at this position. But it has a void* and to my understanding float[] can be marshalled to void*. It works with the methods, as well, which have void* as parameters. -- (°= =°) //\ Prakash Punnoor /\\ V_/ \_V signature.asc Description: This is a digitally signed message part. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] InterOp problems with 1.2.6pre2
Hi, Prakash Punnoor wrote: > Hi > > I am wondering whether this problem is not interesting anyone? In the > meanwhile I could pinpoint the troublemaker. well, we'd be interested but you did not post a reproducible test case. > > Basically it is a float[] field I declared in the struct Encoding context: > This doesn't look like a valid struct for p/invoke. Is this the real code? Aften's context does not declare a float array at this position. Robert > public struct EncodingContext > { > public EncodingParameters EncodingParameters; > public Metadata Metadata; > public Status Status; > public SystemParameters SystemParameters; > public int Verbosity; > public int Channels; > public AudioCodingMode AudioCodingMode; > public bool HasLfe; > public int SampleRate; > internal A52SampleFormat SampleFormat; > > public float[] InitialSamples; // the trouble maker > > private IntPtr m_Context; > } > > and I have and InterOp like this: > > public abstract class FrameEncoder > { > [DllImport( "aften.dll" )] > private static extern void aften_set_defaults( ref > EncodingContext > context ); > > public static EncodingContext GetDefaultsContext() > { > EncodingContext context = new EncodingContext(); > aften_set_defaults( ref context ); > > return context; > } > } > > This causes the crash/exception in mono (see quoted mail). So it doesn't have > anything to do with generics as I suspected at first. If I change the float[] > to IntPtr mono seems to work. As I said VS2008beta2 doesn't have any > problems. > > Cheers, > > Prakash > > On the day of Saturday 24 November 2007 Prakash Punnoor hast written: >> Hi, >> >> mono 1.2.6pre1 and pre2 on Linux x86_64 can't run some C# bindings to a C >> library (an ac3 encoder), which works perfectly with vs2008beta2 and >> .net2.0 target on x86. >> >> You can get the sources at http://sourceforge.net/projects/aften/ in svn >> (revision 659). Compile it using cmake. To build C# bindings, >> pass -DBINDINGS_CS=1 to cmake. It worked with mono with the floating point >> samples case before I switched the bindings to using generics to have other >> types of samples supported (revision 651; though there were bugs in my code >> at that time ;). >> >> The testing code is this (remember the bindings are the troublemaker, not >> this code): >> >> using System; >> using System.IO; >> using System.Runtime.InteropServices; >> >> using Aften; >> >> >> namespace AftenTest >> { >> class MainClass >> { >> public static int Main(string[] args) >> { >> Console.WriteLine("Aften AC3 Encoding Demo"); >> if (args.Length != 2) >> { >> >> Console.WriteLine("Usage: >> "+Path.GetFileNameWithoutExtension(Environment.CommandLine)+" >> "); >> return -1; >> } >> EncodingContext context = >> FrameEncoder.GetDefaultsContext(); >> context.Channels = 2; >> context.AudioCodingMode = AudioCodingMode.Stereo; >> context.SampleRate = 48000; >> context.HasLfe = false; >> context.SystemParameters.ThreadsCount = 1; >> >> FrameEncoderInt16 encoder = new FrameEncoderInt16(ref >> context); >> >> using (FileStream inputStream = new FileStream(args[0], >> FileMode.Open)) >> using (FileStream outputStream = new FileStream(args[1], >> FileMode.CreateNew)) >> { >> inputStream.Seek(44, SeekOrigin.Begin); //Skip >> WAVE header... >> encoder.Encode(inputStream, outputStream); >> } >> >> Console.WriteLine("Done"); >> Console.ReadLine(); >> return 0; >> } >> } >> } >> >> The error I get with mono: >> mono AftenTest.exe ~/Projects/bill.wav encoded.ac3 >> Aften AC3 Encoding Demo >> >> ** ERROR **: Structure field of type Single[] can't be marshalled as >> LPArray aborting... >> Stacktrace: >> >> at AftenTest.MainClass.Main (string[]) <0x> >> at AftenTest.MainClass.Main (string[]) <0x000b8> >> at (wrapper runtime-invoke) >> AftenTest.MainClass.runtime_invoke_int_string[] >> (object,intptr,intptr,intptr) <0x> >> >> Native stacktrace: >> >> mono [0x51fe5d] >> /lib/libpthread.so.0 [0x2b86da225880] >> /lib/libc.so.6(gsignal+0x35) [0x2b86da6e4fa5] >> /lib/libc.so.6(abort+0x110) [0x2b86da6e6a00] >> /usr/lib/libgli
Re: [Mono-dev] InterOp problems with 1.2.6pre2
Am 30.11.2007 um 22:10 schrieb Prakash Punnoor: > On the day of Friday 30 November 2007 Robert Jordan hast written: >> The layouts don't match, since declaring a field "private" won't >> magically subtract it from struct layout. > > It would help if you'd look at the svn version as I wrote in my > mail. Reading > helps, really Careful there: You are writing to the development list of Mono and you seem to want help for a problem you are encountering with some third party library. So first of all, this is actually off-topic for this list in two aspects. To get help non-the-less, file a proper bug report with a self-contained test case, best place would be in Novell's Bugzilla with a link here. Pointing people to some SVN code they have to checkout and configure etc. is definitely not a self- contained test-case. And when you do provide code then it's your responsibility to make sure it's the correct code you're talking of, not Robert's. See: http://www.mono-project.com/Bugs Andreas ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] InterOp problems with 1.2.6pre2
Prakash Punnoor wrote: >> Aften's context does not declare a float array at this position. > > But it has a void* and to my understanding float[] can be marshalled to > void*. > It works with the methods, as well, which have void* as parameters. Here is the end of your C# struct declaration: public int SampleRate; internal A52SampleFormat SampleFormat; public float[] InitialSamples; // the trouble maker private IntPtr m_Context; And this is the C declaration: /** * Audio sample rate in Hz */ int samplerate; /** * Audio sample format * default: A52_SAMPLE_FMT_S16 */ A52SampleFormat sample_format; /** * Used internally by the encoder. The user should leave this alone. * It is allocated in aften_encode_init and free'd in aften_encode_close. */ void *private_context; The layouts don't match, since declaring a field "private" won't magically subtract it from struct layout. Robert ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] InterOp problems with 1.2.6pre2
On the day of Friday 30 November 2007 Robert Jordan hast written: > Prakash Punnoor wrote: > >> Aften's context does not declare a float array at this position. > > > > But it has a void* and to my understanding float[] can be marshalled to > > void*. It works with the methods, as well, which have void* as > > parameters. > > Here is the end of your C# struct declaration: > > public int SampleRate; > internal A52SampleFormat SampleFormat; > public float[] InitialSamples; // the trouble maker > private IntPtr m_Context; > > > And this is the C declaration: > > > /** > * Audio sample rate in Hz > */ > int samplerate; > > /** > * Audio sample format > * default: A52_SAMPLE_FMT_S16 > */ > A52SampleFormat sample_format; > > /** > * Used internally by the encoder. The user should leave this alone. > * It is allocated in aften_encode_init and free'd in > aften_encode_close. > */ > void *private_context; > > > The layouts don't match, since declaring a field "private" won't > magically subtract it from struct layout. It would help if you'd look at the svn version as I wrote in my mail. Reading helps, really -- (°= =°) //\ Prakash Punnoor /\\ V_/ \_V signature.asc Description: This is a digitally signed message part. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] InterOp problems with 1.2.6pre2
On the day of Friday 30 November 2007 Andreas Färber hast written: > Am 30.11.2007 um 22:10 schrieb Prakash Punnoor: > > On the day of Friday 30 November 2007 Robert Jordan hast written: > >> The layouts don't match, since declaring a field "private" won't > >> magically subtract it from struct layout. > > > > It would help if you'd look at the svn version as I wrote in my > > mail. Reading > > helps, really > > Careful there: You are writing to the development list of Mono and you > seem to want help for a problem you are encountering with some third > party library. So first of all, this is actually off-topic for this > list in two aspects. To get help non-the-less, file a proper bug > report with a self-contained test case, best place would be in > Novell's Bugzilla with a link here. Pointing people to some SVN code > they have to checkout and configure etc. is definitely not a self- > contained test-case. And when you do provide code then it's your > responsibility to make sure it's the correct code you're talking of, > not Robert's. > > See: http://www.mono-project.com/Bugs My time is limited. I could also simply ignore the bugs I encounter and try to find work-arounds. It is not my duty to give you test-cases. You the mono devs should see it as a courtesy that I report anything. It wouldn't take too much time to simply reproduce it and with the knowledge mono devs have they could pinpoint it faster then I have done it by wildly guessing. And in fact my report was pretty concise. I wrote down everything you need to know to reproduce that bug. I don't need your help. I report a bug in mono, so I help you to make your product better! I compare it with Linux kernel mailing list: There the devs respect the users and at least react to mails. The least I expected was a reaction and perhaps a hint what the posted error means so I could perhaps provide a small testcase within 5 minutes. In another post, I tried to contibute a small optimizing patch for UInt32.Parse. Did I get any reaction whatsoever? Did I? So moral of the story: I won't waste my time anymore on the mono mailing list. If you want people contributing - be it with code or bug reports - no matter whether the way of postig fits your taste or not - learn to respect that the contributers actually sacrifices some time for mono. Good luck! -- (°= =°) //\ Prakash Punnoor /\\ V_/ \_V signature.asc Description: This is a digitally signed message part. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] InterOp problems with 1.2.6pre2
If you find a bug that affects you that you need fixed, it's up to you to show that there is a bug. If you paste code in an email, of course people are going to look at it. If that code is wrong, well, that's not our fault. You shouldn't paste code which supposedly shows an issue when in fact that code has nothing to do with the actual issue because the code is incorrect. Of course no-one would bother looking at SVN because they'd think they already found the bug. Your time may be limited, but suppose *everyone* who reported a bug expected the mono team to go download sources, compile sources, get god knows how many dependencies so the sources will actually compile, then try and track down a bug in that code. That'd take forever and nothing would get accomplished. http://www.mono-project.com/Bugs#How_to_make_a_good_bug_report If you want something done and want it fast, make it easy for the bug fixers. Alan. On Dec 1, 2007 8:01 AM, Prakash Punnoor <[EMAIL PROTECTED]> wrote: > On the day of Friday 30 November 2007 Andreas Färber hast written: > > Am 30.11.2007 um 22:10 schrieb Prakash Punnoor: > > > On the day of Friday 30 November 2007 Robert Jordan hast written: > > >> The layouts don't match, since declaring a field "private" won't > > >> magically subtract it from struct layout. > > > > > > It would help if you'd look at the svn version as I wrote in my > > > mail. Reading > > > helps, really > > > > Careful there: You are writing to the development list of Mono and you > > seem to want help for a problem you are encountering with some third > > party library. So first of all, this is actually off-topic for this > > list in two aspects. To get help non-the-less, file a proper bug > > report with a self-contained test case, best place would be in > > Novell's Bugzilla with a link here. Pointing people to some SVN code > > they have to checkout and configure etc. is definitely not a self- > > contained test-case. And when you do provide code then it's your > > responsibility to make sure it's the correct code you're talking of, > > not Robert's. > > > > See: http://www.mono-project.com/Bugs > > My time is limited. I could also simply ignore the bugs I encounter and > try to > find work-arounds. It is not my duty to give you test-cases. You the mono > devs should see it as a courtesy that I report anything. It wouldn't take > too > much time to simply reproduce it and with the knowledge mono devs have > they > could pinpoint it faster then I have done it by wildly guessing. And in > fact > my report was pretty concise. I wrote down everything you need to know to > reproduce that bug. > > I don't need your help. I report a bug in mono, so I help you to make your > product better! > > I compare it with Linux kernel mailing list: There the devs respect the > users > and at least react to mails. The least I expected was a reaction and > perhaps > a hint what the posted error means so I could perhaps provide a small > testcase within 5 minutes. > > In another post, I tried to contibute a small optimizing patch for > UInt32.Parse. Did I get any reaction whatsoever? Did I? > > So moral of the story: I won't waste my time anymore on the mono mailing > list. > If you want people contributing - be it with code or bug reports - no > matter > whether the way of postig fits your taste or not - learn to respect that > the > contributers actually sacrifices some time for mono. > > Good luck! > -- > (°= =°) > //\ Prakash Punnoor /\\ > V_/ \_V > > ___ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list