[Mono-dev] Allocating unmanaged memory
Hi, I need to allocate unmanaged memory AND make sure it is filled with 0's. Is there some clever/fast way to do this? So far, I found only Marshal.WriteByte, which sets one byte at a time. Regard, skolima ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Allocating unmanaged memory
Leszek Ciesielski wrote: Hi, I need to allocate unmanaged memory AND make sure it is filled with 0's. Is there some clever/fast way to do this? So far, I found only Marshal.WriteByte, which sets one byte at a time. untested: public static IntPtr Alloc (int bytes) { int p = (int) Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) { // unix return calloc (bytes, 1); } else { return GlobalAlloc (GMEM_ZEROINIT, bytes); } } [DllImport(libc)] static extern IntPtr calloc (int nmemb, int size); const int GMEM_ZEROINIT = 0x40; [DllImport(kernel32)] static extern IntPtr GlobalAlloc (int flags, int bytes); On both platforms the memory can be released with Marshal.FreeHGlobal. Robert ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Allocating unmanaged memory
Just a minor note, only recently has mono started using GlobalAlloc and GlobalFree for the Marshal.*HGlobal routines on Windows. It was previously using g_free on all platforms. I think only the svn version currently has this change, so I am not sure what will happen if you try to free the memory on Windows using Marshal.FreeHGlobal with released versions of mono. You may need to pinvoke GlobalFree yourself on windows to release the memory until the next release of mono. - Jonathan On 1/4/07, Robert Jordan [EMAIL PROTECTED] wrote: Leszek Ciesielski wrote: Hi, I need to allocate unmanaged memory AND make sure it is filled with 0's. Is there some clever/fast way to do this? So far, I found only Marshal.WriteByte, which sets one byte at a time. untested: public static IntPtr Alloc (int bytes) { int p = (int) Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) { // unix return calloc (bytes, 1); } else { return GlobalAlloc (GMEM_ZEROINIT, bytes); } } [DllImport(libc)] static extern IntPtr calloc (int nmemb, int size); const int GMEM_ZEROINIT = 0x40; [DllImport(kernel32)] static extern IntPtr GlobalAlloc (int flags, int bytes); On both platforms the memory can be released with Marshal.FreeHGlobal. Robert ___ 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
Re: [Mono-dev] Allocating unmanaged memory
On Thu, 2007-01-04 at 12:19 +0100, Leszek Ciesielski wrote: I need to allocate unmanaged memory AND make sure it is filled with 0's. Is there some clever/fast way to do this? So far, I found only Marshal.WriteByte, which sets one byte at a time. Mono.Unix.Native.Stdlib.calloc() in Mono.Posix.dll will do this. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Memleak in Array.CreateInstanceImpl?
I'm investigating an apparent memory leak occurring in my Mono application. I still haven't concluded the investigation, but I wanted to share one suspicious entry in Valgrind's output: ==27640== 116,000 (115,164 direct, 836 indirect) bytes in 14,004 blocks are definitely lost in loss record 17 of 19 ==27640==at 0x4005932: calloc (vg_replace_malloc.c:279) ==27640==by 0x5BABDF: g_malloc0 (in /usr/lib/libglib-2.0.so.0.400.7) ==27640==by 0x40BC74E: mono_class_bind_generic_parameters (reflection.c:8917) ==27640==by 0x4136C3F: mono_bounded_array_class_get (class.c:3564) ==27640==by 0x40CAE6A: ves_icall_System_Array_CreateInstanceImpl (icall.c:512) ==27640==by 0x5D1D357: ??? ==27640==by 0x47755BE: ??? ==27640==by 0x4775513: ??? ==27640==by 0x5F8E9C5: ??? ==27640==by 0x5F8FBBD: ??? ==27640==by 0x5F8EB4A: ??? ==27640==by 0x5F8E798: ??? Independent from what's going on in my code, this doesn't look good. Does it ring any bells? Some background details: Mono 1.2.2.1, Linux, ix86, the process was actively running for about 20 minutes, then stopped with SIGTERM. No native or pinvoked code is involved. I never experienced the aforementioned leak running the same code under mono 1.1.13.6. -- MINDBREEZE® KNOWLEDGE IS A MATTER OF SECONDS. __ mgr inż. PAWEŁ SAKOWSKI, Product Development [EMAIL PROTECTED] Mindbreeze Software GmbH | Honauerstr. 4 | 4020 Linz | Austria T +43. 732. 606162 - 0 F +43. 732. 606162 - 609 www.mindbreeze.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Unable to compile mono from svn...
Please check your patch before comitting... MONO_PATH=../../class/lib/default: $MONO_PATH /home/fiducial/applications/mono/mono/runtime/mono-wrapper ../../class/lib/default/mcs.exe /codepage:65001 -d:NET_1_1 -d:ONLY_1_1 -debug /noconfig -unsafe -nowarn:612,618,649 -r:mscorlib.dll -r:System.dll -r:System.Drawing.dll -r:System.Data.dll -r:System.Xml.dll -r:System.EnterpriseServices.dll /resource:resources/WebUIValidation.js -target:library -out:../../class/lib/default/System.Web.dll @System.Web.dll.sources System.Web.Configuration/HandlerFactoryConfiguration.cs(111,23): warning CS0168: The variable `e' is declared but never used System.Web/HttpApplication.cs(617,36): warning CS0168: The variable `ee' is declared but never used System.Web/HttpRuntime.cs(100,4): error CS0103: The name `WebConfigurationManager' does not exist in the context of `System.Web.HttpRuntime' Compilation failed: 1 error(s), 2 warnings ___ Ce message et les éventuels documents joints peuvent contenir des informations confidentielles. Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite. Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Allocating unmanaged memory
On 1/4/07, Jonathan Pryor [EMAIL PROTECTED] wrote: On Thu, 2007-01-04 at 12:19 +0100, Leszek Ciesielski wrote: I need to allocate unmanaged memory AND make sure it is filled with 0's. Is there some clever/fast way to do this? So far, I found only Marshal.WriteByte, which sets one byte at a time. Mono.Unix.Native.Stdlib.calloc() in Mono.Posix.dll will do this. - Jon Uhm. Quite a lot solutions for a simple task :P I asked the question, because I found a bug in OracleClient, where memory was allocated but not zeroed (and OCI expected it to be padded with 0's). So a simple AllocHGlobal was not enough. I am working with the current repository version - is there a _preferred_ way? For now I am going to run a benchmark and choose the fastest method :-) ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Exception catching in C...
Gonzalo Paniagua Javier wrote: On Wed, 2007-01-03 at 10:38 +0100, Robert Jordan wrote: It's not possible to catch a managed exception in unmanaged code when running on Unix. Darn. It'd be nice to be able to register a catch all in C on Unix. Oh well. You can still register your own function to deal with unhandled exceptions by attaching a delegate to AppDomain.UnhandledException handler (afair, for the root appdomain). -Gonzalo That's a great idea, I'll try that. On a related note, in my example project if I throw an exception that isn't handled (on purpose), the program prints the Unhandled Exception information but doesn't exit as expected. It just sits there. I've attached the example project. Sorry for the size, I tried to pare it down as much as possible. I also tried rewriting it in a more basic form, but then it didn't seem to have this problem. I've tried this on 1.1.13.8 (sled) and 1.2.2.1 (vmware image). Is this a bug, or am I doing something wrong? Thanks for your help guys, Thomas unhandled_exception_problem.tgz Description: application/compressed-tar ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Exception catching in C...
Thomas Wiest wrote: On a related note, in my example project if I throw an exception that isn't handled (on purpose), the program prints the Unhandled Exception information but doesn't exit as expected. It just sits there. I've attached the example project. Sorry for the size, I tried to pare it down as much as possible. I also tried rewriting it in a more basic form, but then it didn't seem to have this problem. I've tried this on 1.1.13.8 (sled) and 1.2.2.1 (vmware image). Is this a bug, or am I doing something wrong? The link in your previous mail was about p/invoke, where exceptions can't be caught, but since you're embedding Mono, there is an easy and documented way to handle exceptions: mono_runtime_invoke's last argument is actually a MonoException**: void call_person_ThrowException(person_class *person) { MonoObject *exception; mono_runtime_invoke(person-methods-ThrowException, person-object, NULL, exception); if (exception) do_something (); } I didn't look why your sample hangs, though. Robert ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Exception catching in C...
Robert Jordan wrote: The link in your previous mail was about p/invoke, where exceptions can't be caught, but since you're embedding Mono, there is an easy and documented way to handle exceptions: Oh, sorry about the confusion. The mono embedding documentation is somewhat sparse, so I've been trying to learn stuff from the marshaling doc before asking questions on the list. mono_runtime_invoke's last argument is actually a MonoException**: Wow, this is perfect. That's exactly what I needed. Thanks, Thomas ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Test case for the ViewState bug
here it is marek resources.tar.bz2 Description: application/bzip signature.asc Description: PGP signature ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Bug System.Web.HttpRequest.IsLocal
On Thu, 2007-01-04 at 06:49 -0800, Vladimir Krasnov wrote: Hello, There is a bug in IsLocal method, it should check all host's ip addresses, not only 127.0.0.1 Please review attached patch. I'm not sure this is a bug. I remember testing that looong time ago and that was MS behavior. -Gonzalo ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] xsp2 Exception because of System.webServer in web.config
I am trying to write an web application using ASP.NET 2.0 using Visual Web Developer Express Edition, it runs fine in IIS in Windows but when I try to run it with xsp2 it gives an exception mentioned below. Please Advice. Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.HttpRuntime Server stack trace: at 0x0 unknown method at System.Web.Hosting.SimpleWorkerRequest..ctor (System.String page, System.String query, System.IO.TextWriter output) [0x0] at Mono.WebServer.MonoWorkerRequest..ctor (IApplicationHost appHost) [0x0] at Mono.WebServer.XSPWorkerRequest..ctor (Int32 requestId, Mono.WebServer.XSPRequestBroker requestBroker, IApplicationHost appHost, System.Net.EndPoint localEP, System.Net.EndPoint remoteEP, System.String verb, System.String path, System.String queryString, System.String protocol, System.Byte[] inputBuffer, IntPtr socket, Boolean secure) [0x0] at Mono.WebServer.XSPApplicationHost.ProcessRequest (Int32 reqId, Int64 localEPAddr, Int32 localEPPort, Int64 remoteEPAdds, Int32 remoteEPPort, System.String verb, System.String path, System.String queryString, System.String protocol, System.Byte[] inputBuffer, System.String redirect, IntPtr socket, Mono.WebServer.SslInformations ssl) [0x0] at (wrapper remoting-invoke-with-check) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at (wrapper xdomain-dispatch) Mono.WebServer.XSPApplicationHost:ProcessRequest (object,byte[],byte[],int,long,int,long,int,string,string,string,string,byte[],string) Exception rethrown at [0]: --- System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.webServer () (/home/sandic/Work/bhaskar/CodeCritic/Web.Config line 80) at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlTextReader reader) [0x0] at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlTextReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x0] at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlTextReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x0] at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlTextReader reader, System.String fileName) [0x0] at System.Configuration.Configuration.Load () [0x0] at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0] at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0] at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0] at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password) [0x0] at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path) [0x0] at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName) [0x0] at System.Web.QueueManager..ctor () [0x0] at System.Web.HttpRuntime..cctor () [0x0] --- End of inner exception stack trace --- at (wrapper xdomain-invoke) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at (wrapper remoting-invoke-with-check) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at Mono.WebServer.XSPWorker.RunInternal (System.Object state) [0x0] My Web.Config contains this offending section: system.webServer validation validateIntegratedModeConfiguration=false/ modules add name=ScriptModule preCondition=integratedMode type=System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/ /modules handlers remove name=WebServiceHandlerFactory-ISAPI-2.0/ add name=ScriptHandlerFactory verb=* path=*.asmx preCondition=integratedMode type=System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/ add name=ScriptResource verb=GET path=ScriptResource.axd type=System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/ /handlers /system.webServer Regards, Sandi -- There are three kinds of people: men, women, and unix. signature.asc Description:
Re: [Mono-dev] xsp2 Exception because of System.webServer in web.config
Hi, I suggest you to raise a bug in http://bugzilla.ximian.com/enter_bug.cgi?product=Mono%3A%20Tools under 'XSP' component. Also with a test-case to reproduce the issue. Mention the exact version of Mono that you are currently using. Thanks Nagappan Sandipan Charkavarty wrote: I am trying to write an web application using ASP.NET 2.0 using Visual Web Developer Express Edition, it runs fine in IIS in Windows but when I try to run it with xsp2 it gives an exception mentioned below. Please Advice. Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.HttpRuntime Server stack trace: at 0x0 unknown method at System.Web.Hosting.SimpleWorkerRequest..ctor (System.String page, System.String query, System.IO.TextWriter output) [0x0] at Mono.WebServer.MonoWorkerRequest..ctor (IApplicationHost appHost) [0x0] at Mono.WebServer.XSPWorkerRequest..ctor (Int32 requestId, Mono.WebServer.XSPRequestBroker requestBroker, IApplicationHost appHost, System.Net.EndPoint localEP, System.Net.EndPoint remoteEP, System.String verb, System.String path, System.String queryString, System.String protocol, System.Byte[] inputBuffer, IntPtr socket, Boolean secure) [0x0] at Mono.WebServer.XSPApplicationHost.ProcessRequest (Int32 reqId, Int64 localEPAddr, Int32 localEPPort, Int64 remoteEPAdds, Int32 remoteEPPort, System.String verb, System.String path, System.String queryString, System.String protocol, System.Byte[] inputBuffer, System.String redirect, IntPtr socket, Mono.WebServer.SslInformations ssl) [0x0] at (wrapper remoting-invoke-with-check) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at (wrapper xdomain-dispatch) Mono.WebServer.XSPApplicationHost:ProcessRequest (object,byte[],byte[],int,long,int,long,int,string,string,string,string,byte[],string) Exception rethrown at [0]: --- System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.webServer () (/home/sandic/Work/bhaskar/CodeCritic/Web.Config line 80) at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlTextReader reader) [0x0] at System.Configuration.SectionGroupInfo.ReadContent (System.Xml.XmlTextReader reader, System.Configuration.Configuration config, Boolean overrideAllowed, Boolean root) [0x0] at System.Configuration.SectionGroupInfo.ReadRootData (System.Xml.XmlTextReader reader, System.Configuration.Configuration config, Boolean overrideAllowed) [0x0] at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlTextReader reader, System.String fileName) [0x0] at System.Configuration.Configuration.Load () [0x0] at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x0] at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x0] at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x0] at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password) [0x0] at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path) [0x0] at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName) [0x0] at System.Web.QueueManager..ctor () [0x0] at System.Web.HttpRuntime..cctor () [0x0] --- End of inner exception stack trace --- at (wrapper xdomain-invoke) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at (wrapper remoting-invoke-with-check) Mono.WebServer.XSPApplicationHost:ProcessRequest (int,long,int,long,int,string,string,string,string,byte[],string,intptr,Mono.WebServer.SslInformations) at Mono.WebServer.XSPWorker.RunInternal (System.Object state) [0x0] My Web.Config contains this offending section: system.webServer validation validateIntegratedModeConfiguration=false/ modules add name=ScriptModule preCondition=integratedMode type=System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/ /modules handlers remove name=WebServiceHandlerFactory-ISAPI-2.0/ add name=ScriptHandlerFactory verb=* path=*.asmx preCondition=integratedMode type=System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,