[Mono-list] MCS warning message
Hello, While trying a clean build of mono, I noticed the following warning, but the make goes through fine.Make profile-do--default--all profile-do--net_2_0--all make[4]: Entering directory `/home/swork/mono-1.1.9.1/mcs' make PROFILE="" all make[5]: Entering directory `/home/swork/mono-1.1.9.1/mcs' *** The compiler 'mcs' doesn't appear to be usable. *** Falling back to using pre-compiled binaries. Be warned, this may not work. I tried compiling c# programs and it went through fine. But I have not seen this warning in previous b uilds. Any clues as to why this might be happening ?Thanks for the time. Yahoo! Music Unlimited - Access over 1 million songs. Try it free.___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Fault isolation : IL code
Hello all, I am restating my problem. My problem : isolating faults caused by unmanaged code. To achieve this I am not allowing the unmanaged code to "modify managed memory". I am doing this in two stages.1) ensuring that the unmanaged C code does not modify any managegd memory. This I am doing by modifying the ASSEMBLY code of the unmanaged program and sandboxing it so that all the "write " instructions dont write to managed memory. 2) If an argument is passed by reference, I have make a copy of the object in unmanaged memory and pass this reference to the unmanaged code. So the program will get a reference to the unmanaged memory and not managed memory. By these two stages, I am ensuring that the managed memory is not at any time being corrupted by unmanaged code. (the results, the final updated unmanaged meory object will be passed back by another mechanism, have to yet work on this ) I am tryingto do the second part described above as follows: 1) I figured that marshal.c is the place where IL code is being emitted to push the arguments before the call. 2) so, if an argument is passed by reference, am emitting IL code to make a copy of the object in unmanaged memory and pass this. I wrote code to emit IL code to achieve this and it errors out ** (pinvref.exe:15147): WARNING **: implement me 0x77 ** ERROR **: file class.c: line 2812 (mono_class_from_mono_type): should not be reachedaborting...Aborted I am sending the code that I wrote. Can anyone tell me what I am doing wrong?? Here is the C code to emit IL code : ( for testing purposes, I directly did a g_malloc,to allocate unmanaged memory, instead of emitting a call to "AllocCoTaskMem", which I have commented out . The emit_managed_call does work when I inspected the trace of execution ) MonoType *t = sig-params[argnum];MonoClass *pclasee = mono_class_from_mono_type(t);inst_size = pclass-instance_size; / * not sure if i should use this or mono_class_value_size (klass, NULL) , have tried both!! */ um_mem = (MonoType *)g_malloc(inst_size); /* EMITTING MEMORY ALLOC CALL : */ /* pushing the alloc_size on stack for use by AllocCoTaskMem */ /* mono_mb_emit_byte (mb, CEE_LDC_I4_S); mono_mb_emit_byte (mb, inst_size); klassAllocCoTaskMem= mono_class_from_name(mono_defaults.corlib,"System.Runtime.InteropServices", "Marshal"); methodAllocCoTaskMem = mono_class_get_method_from_name(klassAllocCoTaskMem,"AllocCoTaskMem", -1); mono_mb_emit_managed_call(mb,methodAllocCoTaskMem,NULL); */ /* dest */ mono_mb_emit_icon(mb,um_mem); /* src*/ mono_mb_emit_ldarg(mb, argnum); mono_mb_emit_byte(mb, CEE_LDIND_REF); mono_mb_emit_byte(mb, CEE_STIND_REF); /* emit the call to push the NEW REFERENCE */ emit_marshal (m, argnum, um_mem, spec, conv_arg, NULL, MARSHAL_ACTION_PUSH); ALSO tried the followng way/* destination addr on stack */ mono_mb_emit_icon(mb,um_mem);/* source address */ mono_mb_emit_ldarg(mb, argnum); mono_mb_emit_icon (mb, inst_size); mono_mb_emit_byte (mb, CEE_PREFIX1); mono_mb_emit_byte (mb, CEE_CPBLK); Thanks a lot for your time, S Yahoo! FareChase - Search multiple travel sites in one click. ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] IL code question
Hello, I am trying to emit IL code to pass a pointer to a function call : for example : dest_ptr = mono_mb_add_local (mb, mono_defaults.int_class-byval_arg); dest_ptr finally points to an object created by me. How can I pass the value to emit a function call to achieve something like emit_marshal( sig, dest_ptr...) ? Thanks, $ __ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] ( ping lupus) IL code doubts
Hi, I am trying to get the base of unmanaged stack, the reason I want this is because i am sandboxing my C code so that it doesnt write to managed heap and stack. I got the value of the esp at the beginning of the C program (via assembly instructions) but (as jonp said) at this point the local variables are already on the unmanaged stack. Is there any way to get to the beginning of the unmanaged stack? ( I tried inserting extra marker arguments in (emit_wrapper) so that I can get to it in C code, butI totally broke mono compilation !! ) Also, to insert an ARGUMENT of type say at runtime, valuetype PlatformInvokeTest/DataObj* V_4. (Need to generate Il code to declare a pointer to the user defined structure) should i use: um_ptr = mono_mb_add_local (mb, mono_defaults.int_class-byval_arg); or um_ptr = mono_mb_add_local (mb, (pclass-byval_arg)); Thank you very much, shankari Yahoo! FareChase - Search multiple travel sites in one click. ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Unmanaged Stack bound to prevent corruption
Hello, I am trying to locate the bounds for the unmanaged or managedstack. The purpose is to sandbox my unmanaged code. I looked into metadata/threads.c and there is "stack_ptr" defined for each managed thread. But how can I know the size of it , so that I can arrive at managed stack extent. If I can get thebounds of the unmanaged stack, that would be fine too. The issue here is , i tried passing a value by reference to the unmanaged code and printed out its address in both C# and C, they look pretty close together. I am not sure why this happens. Any way of finding this info out? Thanks, Shankari Yahoo! FareChase - Search multiple travel sites in one click. ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-dev] PInvoke ques
Hello again!! I think I misunderstood marshal.c as ACTUALLY pushing the arguments on stack. I think it generates IL code to push the argument on stack. In the case of reference, it generated IL code to push the address on stack. AM I correct ??? If so, can I do this : My aim is to prevent an update to a pass-by-ref value(this is a part of my work in fault isolation). My idea is to make a copy of the managed type , so this copy will be updated rather than the original one. I think this can only be achieved by generating appropriate IL code. (??) In order to do this , I need the size of the managed object. Does the instance_size denote the size of the managed object ?? Thanks, $ __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-list] PInvoke ques
Hello again!! I think I misunderstood marshal.c as ACTUALLY pushing the arguments on stack. I think it generates IL code to push the argument on stack. In the case of reference, it generated IL code to push the address on stack. AM I correct ??? If so, can I do this : My aim is to prevent an update to a pass-by-ref value(this is a part of my work in fault isolation). My idea is to make a copy of the managed type , so this copy will be updated rather than the original one. I think this can only be achieved by generating appropriate IL code. (??) In order to do this , I need the size of the managed object. Does the instance_size denote the size of the managed object ?? Thanks, $ __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-dev] PInvoke : argument passing by ref
Hello, I am trying to isolate the updates by unmanaged code if the arguments are passed by reference in Pinvoke. I looked up marshal.c and at mono_marshal_emit_native_wrapper , the by-ref argumments are being marshalled back to managed memory. I am trying to do this by the foll : After the C code has made the updates : when the results are being marshalled back to the managed object, I can copy this to a diff location and return this address and thus prevent the original argument from being updated. I could do this at call time , by copying the managed structure to another location and passing this addr...and this can get updated..but in this case I have to change the final byref argument to point to this new address. Everything leads to mono_mb_emit_byte( where some copy actually seems to be happening..) but it emits IL code and it *seems* to be pushing similar stuff if I pass by value or by reference. Any pointers on how to achieve my objective ?? Thanks, __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] PInvoke : argument passing by ref
I want to know : After unmanaged code manipulates the ref object...it copies it BACK to managed memory. Where does this happen. Is it in marshal.c:mono_marshal_emit_native_wrapper ??? lines 6022 ?? /* convert the result */ if (!sig-ret-byref) { MonoMarshalSpec *spec = mspecs [0]; type = sig-ret-type; if (spec spec-native == MONO_NATIVE_CUSTOM) { emit_marshal (m, 0, sig-ret, spec, 0, NULL, MARSHAL_ACTION_CONV_RESULT); } else { handle_enum: switch (type) { case MONO_TYPE_VOID: break; case MONO_TYPE_I1: case MONO_TYPE_U1: Thanks --- Zoltan Varga [EMAIL PROTECTED] wrote: Hi, The way mono marshalls data from/to native code is described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/netcfmarshallingtypes.asp If things don't work that way in mono, than it is a bug and we will fix it. If you pass structures to native code using 'ref', then you can use the [In, Out] attributes to specify whenever changes made in native code are visible to managed code, ie. void foo ([In] ref AStruct s). This doesn't work in 1.1.9, but it works in the SVN version, see this bug: http://bugzilla.ximian.com/show_bug.cgi?id=76502 Zoltan On 10/23/05, Shankari [EMAIL PROTECTED] wrote: Hello, I am trying to isolate the updates by unmanaged code if the arguments are passed by reference in Pinvoke. I looked up marshal.c and at mono_marshal_emit_native_wrapper , the by-ref argumments are being marshalled back to managed memory. I am trying to do this by the foll : After the C code has made the updates : when the results are being marshalled back to the managed object, I can copy this to a diff location and return this address and thus prevent the original argument from being updated. I could do this at call time , by copying the managed structure to another location and passing this addr...and this can get updated..but in this case I have to change the final byref argument to point to this new address. Everything leads to mono_mb_emit_byte( where some copy actually seems to be happening..) but it emits IL code and it *seems* to be pushing similar stuff if I pass by value or by reference. Any pointers on how to achieve my objective ?? Thanks, __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-list] PInvoke : argument passing by ref
Hello, I am trying to isolate the updates by unmanaged code if the arguments are passed by reference in Pinvoke. I looked up marshal.c and at mono_marshal_emit_native_wrapper , the by-ref argumments are being marshalled back to managed memory. I am trying to do this by the foll : After the C code has made the updates : when the results are being marshalled back to the managed object, I can copy this to a diff location and return this address and thus prevent the original argument from being updated. I could do this at call time , by copying the managed structure to another location and passing this addr...and this can get updated..but in this case I have to change the final byref argument to point to this new address. Everything leads to mono_mb_emit_byte( where some copy actually seems to be happening..) but it emits IL code and it *seems* to be pushing similar stuff if I pass by value or by reference. Any pointers on how to achieve my objective ?? Thanks, __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Deep Marshaling
Hello, While marshalling class and structure members, Mono doesnt do a deep marshal. If the structure has a string member, a default of charset.auto is set. But if the structure has an array of integers, what would be done in that case? In general, if an array of simple types is a member of the structure , how would it be marshalled(if at all)? For array of user defined structures, I assume no marshalling will be done. (Am I correct?) or is it the case that arrays(except for strings) and pointers are not marshalled. Thanks, $ __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Parameter passing using PInvoke
Hello, I had the following question regarding parameter passing in PInvoke: If I pass a reference to a structure VIA PINVOKE how do I know the size of the struct in Mono (at emit_native_wrapper ). Mono pushes the address on to the stack but is there a way to retrieve the size of the struct pointed to by the address. mono_marshal_type_size doesnt seem to be the right function..( I am not sure). I dereferenced the pointer at the emit_native_wrapper level as *(sig-params[i])-data.klass and the instance size is shown as 24. where as my structre is just has 4 integer values i.e 16 (obtained using sizeof() in C# code) If I need to copy this structure by value ...what size should I be using = 16 or instance size of 24?? If it is 16 : How can we get this in *mono* (not at the C# program level). Also, If I pass a structure or class by reference through Pinvoke, it would be visible as such to the unmanaged code (without any marshalling). So, if at all Pinvoke does padding , the unmanaged code would access the datamembers as such. Is this correct? Thanks, __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Jon's reply : Parameter passing using PInvoke
here is Jon's answer to my queries. Any more insights or clarifications are welcome. : I have a structure in my C# code. If in my invocation, I pass a reference to this structure. I want to know the size of the struct in mono. I guess it pushes the address on to the stack. But I want the size of the struct pointed to by the address. Is there any way to get this. System.Runtime.InteropServices.Marshal.SizeOf(). :-) Though there's an important question: is this through P/Invoke or through an icall interface? And is it a C# struct or a C# class? For P/Invoke it doesn't matter, but for icalls the class will have the standard object header, which is 8 bytes in size IIRC. mono_marshal_type_size doesnt seem to be the right function.. Why not? I dereferenced the pointer at the emit_native_wrapper level as *(sig-params[i])-data.klass and the instance size is shown as 24. where as my structre is just has 4 in values i.e 16. Either your structure has padding issues, or you're within an icall interface passing a reference type, thus you'd have the object header to contend with. If I need to copy this structure by value ...what size should I be using = 16 or instance size of 24?? If it is 16 : How can we get this in *mono* (not at the C# program level). I lack the knowledge to answer this. - Jon __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Re: Method signature modification
Hello, Thanks for your inputs. I dont want to modify the C# code, because that way for every unmanaged code call a wrapper has to be written. The aim is for the user to somehow indicate that the function call is in a partcular mode (say safe/unsafe). one way I thought of is to pass it as a function parameter, so that mono can strip it off before pushing it to stack. So, the function that gets called still has the right parameters. Then based on the flag I am doing some assembly code modifications in the unmanaged(C code). I tried changing the number of paramters at emit_native_wrapper level but the compilation breaks with unverified IL code. Any directions on how to fix that error?? or any otehr suggestions will be very much appreciated. Thanks __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Method signature modification
I am trying to invoke unmanaged call with a flag as the first parameter of the call. (Since C doesnt do parameter matching, I can get away with this). So, i call f( flag, param1) The corresponding call that is invoked in the shared library is f(param1). So, the first parameter is like a flag to mono, I dont want to push it on stack/marshal it. mono_marshal_get_native_wrapper() calls mono_marshal_emit_native_wrapper() which sets up the stack and handles the marshalling. The method signature sig that gets passed to mono_marshal_emit_native_wrapper( marshal.c) should be changed to emit the correct wrapper. Modifying mono code at emit_wrapper seems dangerous. Any ideas/directions on how to achive this? Thanks, --- Jonathan Pryor [EMAIL PROTECTED] wrote: On Fri, 2005-10-14 at 20:50 -0700, Shankari wrote: I have some questions in unmanaged call internals. From what I understood, an unmanaged code is a function call. pedantic Unmanaged code can be anything (including Perl code), and can be an unmanaged *function*. A function call would invoke the function. /pedantic To figure out where exactly the switch from managed to unmanaged code is happening, I set a breakpoint in my C program and tried a backtrace from it. Here is the info I got. (gdb) backtrace #0 printmsg () at cprog.c:13 #1 0x0045b6ac in ?? () #2 0x0001 in ?? () #3 0x00e65710 in ?? () #4 0x00450ad7 in ?? () #5 0x093458e0 in ?? () #6 0x093458c8 in ?? () #7 0x09389398 in ?? () #8 0x0002be60 in ?? () #9 0x in ?? () (gdb) n 0x0045b6ac in ?? () (gdb) Translation of all that: Mono created a new thread which contains JITed code, so no debug symbols exist (that GDB knows about). Consequently, you need the managed callstack, which you can get using mono_print_method_from_ip, which takes a stack pointer as an argument, e.g.: (gdb) p mono_print_method_from_ip (0x0045b6ac) I am not able to single step through the code from the point where unmanaged code is ending. That's because no source code exists for those functions, at least as far as GDB is concerned. Since the backtrace addr are not resolved, it looks like an unmanaged call is spawned in a new thread. Correct. Mono creates several threads during startup for myriad reasons (such as for the garbage collector, finalizer thread, etc.). - Jon __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Question on Unmanaged code Invocation
Hello, I have some questions in unmanaged call internals. From what I understood, an unmanaged code is a function call. To figure out where exactly the switch from managed to unmanaged code is happening, I set a breakpoint in my C program and tried a backtrace from it. Here is the info I got. (gdb) backtrace #0 printmsg () at cprog.c:13 #1 0x0045b6ac in ?? () #2 0x0001 in ?? () #3 0x00e65710 in ?? () #4 0x00450ad7 in ?? () #5 0x093458e0 in ?? () #6 0x093458c8 in ?? () #7 0x09389398 in ?? () #8 0x0002be60 in ?? () #9 0x in ?? () (gdb) n 0x0045b6ac in ?? () (gdb) I am not able to single step through the code from the point where unmanaged code is ending. Since the backtrace addr are not resolved, it looks like an unmanaged call is spawned in a new thread. Is this true? Any clarifications or information will be greatly appreciated. Thanks, __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Managed memory boundary
Hi, Is there a way to determine the managed memory boundary at Runtime? I tried digging into the GC code but couldnt pull up much info. Thanks, __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Question in Interop
Hello, Sebastian had replied to my earlier query for safety from unmanaged code by sandboxing it in a separate app domain. I read the links : http://pages.infinit.net/ctech/20050520-0735.html http://pages.infinit.net/ctech/20050623-0432.html Is the sandboxing based on providing code based and role based security of the modules ? ie. ensuring that the managed code trusts the Unamanged code? If for instance we give the unmanaged code permit to execute and it (unmanaged code) maligns some raw address, this sandboxing might not be able to protect it ? i.e the faults will not be sandboxed to the unmanaged app domain only. Kindly correct me if I am wrong. Thanks, Shankari __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Process Address space map
Thanks a lot for all the replies! Marcus, I would like the details about Mono layout(being similar to IBM's JVM) .If you could provide them, it will be great. Also, I was trying to get the address space map of Mono and did export MONO_PRINT_ADDRESS_MAP =1 It dumps the same info. in /proc/pid/maps. I am interested in knowing which memory addr range is in managed heap, where the code resides and so on. Am I looking in the right direction? Thanks again for your inputs. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Re: Questions in Interop
Hello, I want to know information like Details of CLR data structures, Domain information like System Domain: 793e9d58, LowFrequencyHeap: 793e9dbc, HighFrequencyHeap: 793e9e14, StubHeap: 793e9e6c, Assembly: 0015aa68 [mscorlib], ClassLoader: 0015ab40 and class related information like Name: SimpleClass MethodTable 0x00955124 EEClass 0x02ca33b0 Size 36(0x24) bytes FieldDesc*: 00955064 MTField Offset Type AttrValue Name 00955124 40a4 System.Int64 instance 31 l1 00955124 40bcCLASS instance 00a819a0 str some fields omitted from the display for brevity 00955124 403 1e System.Byte instance3 b3 00955124 404 1f System.Byte instance4 b4 I have pasted the output of SOS debugger for windows. I want to know how to obtain such information for linux. Also, can I assume that the runtime object layout would be similar to windows as described in the msdn document http://msdn.microsoft.com/msdnmag/issues/05/05/JITCompiler/default.aspx. Thanks a LOT ! __ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/ ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Questions in Interop
Hello All, I am a novice at mono and have some questions about how the interop really works in mono. Apologies if my questions strike as too crude ! Any pointers would be very welcome. 1) Does a unmanaged call from managed process means that it still lies in the same address space as the managed process that called it? 2) If so, manipulating (mauling) a raw address(not trying to access managed data in the legal ways) in the unmanaged code is potentially suicide??!!! 3) what protection does Mono provide in such scenarios. 4) Also, are there *ANY* tools similar to Son of strike to look into the object layout/process details. Thanks a lot!! Shiva __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list