Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
I'm not sure that something is changed to make it incompatible. The apache modules compiled on windows are only crashing if multiple requests are coming at the same time, and they are crushing at function/procedure returns (Yes, on Linux it is even worse, since no module gets even loaded by apache. That might be some C API translation problem). Even if reduced to this small code it crushes (but only if multiple calls are inside this code) on windows: === Function TCustomApacheApplication.ProcessRequest(P: PRequest_Rec) : Integer; Var Req : TApacheRequest; Resp : TApacheResponse; i:integer; begin Req:=TApacheRequest.CreateReq(Self,P); Try Resp:=TApacheResponse.CreateApache(Req); Try for i := 0 to maxint do ;//Time wasting for multiple requests at the same time to run this code // HandleRequest(Req,Resp); // If Not Resp.ContentSent then //Resp.SendContent; Finally Result:=OK; Resp.Free;//= crashes after here randomly for 2nd simultaneous caller end; Finally Req.Free; end; end; == Sometimes when removing all the try/finally pairs from the function it works. But then adding more code, even as simple as DateTimeToStr(Now), makes it crash. Sometimes more code can be added but then it will crash inside that code somewhere at function/procedure returns. AB Felipe Monteiro de Carvalho wrote: Try installing an older Apache. I installed here with XAMMP, Apache 2.2.9 and it just quits without any error message when loading my Pascal module. But when using the standard Apache 2.2.6 in Mandriva 2008 it works. Actually I can't get it to show the page (some config problem?), but it loads without problems, apache keeps working. I think something changed in an incompatible way. This is pretty unexpected, as I hoped that they would keep compatibility between all 2.2.x series. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On 24 Sep 2008, at 10:58, ABorka wrote: I'm not sure that something is changed to make it incompatible. The apache modules compiled on windows are only crashing if multiple requests are coming at the same time, and they are crushing at function/procedure returns (Yes, on Linux it is even worse, since no module gets even loaded by apache. That might be some C API translation problem). Maybe you have to initialise the threading system so all the necessary locks in the system unit get activated. Something like {$ifdef unix} uses cthreads; {$endif} ... function dummythread(p: pointer): ptrint; begin end; initialisation WaitForThreadTerminate(BeginThread(@dummythread)); end. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On Wed, 24 Sep 2008, ABorka wrote: I'm not sure that something is changed to make it incompatible. The apache modules compiled on windows are only crashing if multiple requests are coming at the same time, and they are crushing at function/procedure returns (Yes, on Linux it is even worse, since no module gets even loaded by apache. That might be some C API translation problem). Even if reduced to this small code it crushes (but only if multiple calls are inside this code) on windows: === Function TCustomApacheApplication.ProcessRequest(P: PRequest_Rec) : Integer; Var Req : TApacheRequest; Resp : TApacheResponse; i:integer; begin Req:=TApacheRequest.CreateReq(Self,P); Try Resp:=TApacheResponse.CreateApache(Req); Try for i := 0 to maxint do ;//Time wasting for multiple requests at the same time to run this code // HandleRequest(Req,Resp); // If Not Resp.ContentSent then //Resp.SendContent; Finally Result:=OK; Resp.Free;//= crashes after here randomly for 2nd simultaneous caller end; Finally Req.Free; end; end; == Sometimes when removing all the try/finally pairs from the function it works. But then adding more code, even as simple as DateTimeToStr(Now), makes it crash. Sometimes more code can be added but then it will crash inside that code somewhere at function/procedure returns. This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. Changing the heap manager to the C heap manager (just add 'uses cmem' as the first line in the project) may solve the problem, but it is not guaranteed; there was another bug in the memory manager which prevented that from working correctly. Maybe it has been fixed meanwhile. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On 24 Sep 2008, at 12:35, Michael Van Canneyt wrote: This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. The heap manager is simply not thread safe until the FPC threading system has been initialised (by starting a thread). Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On Wed, 24 Sep 2008, Jonas Maebe wrote: On 24 Sep 2008, at 12:35, Michael Van Canneyt wrote: This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. The heap manager is simply not thread safe until the FPC threading system has been initialised (by starting a thread). It is not that simple. The heap manager cannot handle situations where threads have been started by code that is not aware of the FPC threading mechanisms - such as apache. I have done some changes for this, but they are not sufficient. PThreads has no mechanisms for dealing with this situation. Windows does (using the DLL_THREAD_ATTACH message). Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On 24 Sep 2008, at 13:02, Michael Van Canneyt wrote: On Wed, 24 Sep 2008, Jonas Maebe wrote: On 24 Sep 2008, at 12:35, Michael Van Canneyt wrote: This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. The heap manager is simply not thread safe until the FPC threading system has been initialised (by starting a thread). It is not that simple. The heap manager cannot handle situations where threads have been started by code that is not aware of the FPC threading mechanisms - such as apache. Ah yes, that's indeed a problem with the new 2.3.x heap manager. I don't think the 2.2.x heap manager cares though, since it uses a regular critical section/mutex. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
Could it be then related to the Apache method of working? Apache has a non-threaded version and several threaded versions. In my Mandriva where it didn't crash I installed the non-threaded version. (not sure if it won't create threads anyway for something else, even if it works in a non-threaded principle). I cannot find in the XAMMP website if they use the threaded or non-threaded version. -- Felipe Monteiro de Carvalho ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
On Wed, 24 Sep 2008, Jonas Maebe wrote: On 24 Sep 2008, at 13:02, Michael Van Canneyt wrote: On Wed, 24 Sep 2008, Jonas Maebe wrote: On 24 Sep 2008, at 12:35, Michael Van Canneyt wrote: This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. The heap manager is simply not thread safe until the FPC threading system has been initialised (by starting a thread). It is not that simple. The heap manager cannot handle situations where threads have been started by code that is not aware of the FPC threading mechanisms - such as apache. Ah yes, that's indeed a problem with the new 2.3.x heap manager. I don't think the 2.2.x heap manager cares though, since it uses a regular critical section/mutex. 2.2.2 has/had other problems for Apache :-) Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Variant streaming patches
Dear All, can anybody say a word about variant properties streaming implementation. See the latest note on http://bugs.freepascal.org/view.php?id=10482 With best regards, Anton ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] libgdb: preferred version and whence?
Mark Morgan Lloyd wrote: The Debian source package appears to basically be gdb which builds libgdb as a side-effect. It compiles OK on an ARM but there are errors when I try to use it as part of the fpc build with GDB_V607=1 (which seemed like a good starting position). I'll look around for 6.7 and try building it on i386 and SPARC before having another attempt on ARM. Best practice appears to be to make sure the gdb binary is installed, to get the corresponding gdb source package (e.g. from http://ftp.gnu.org/gnu/gdb/) to build that and then copy across libgdb.a etc. to the fpc source tree. The wrong version of gdb might not build properly, for example Debian Sarge and Etch on i386 support 6.3 but to work on ARM requires 6.4. Debian Lenny includes gdb 6.8, I haven't been able to build fpc on an older system using this version and haven't yet tried on Lenny. I've now got fpc 2.2.2 (optimised, including the fp IDE) running on Debian ARM (little-endian) including debugger operation inside fp. I'd like to try getting a big-endian ARM system running but don't know how quickly I can manage that. i386 on NT and Debian Sarge is OK, SPARC remains a problem. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] libgdb: preferred version and whence?
On 24 Sep 2008, at 14:07, Mark Morgan Lloyd wrote: I've now got fpc 2.2.2 (optimised, including the fp IDE) running on Debian ARM (little-endian) including debugger operation inside fp. I'd like to try getting a big-endian ARM system running but don't know how quickly I can manage that. i386 on NT and Debian Sarge is OK, SPARC remains a problem. This indeed suggests a SPARC-specific problem, as ARM is also quite alignment-sensitive. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] libgdb: preferred version and whence?
Jonas Maebe wrote: This indeed suggests a SPARC-specific problem, as ARM is also quite alignment-sensitive. I'm currently setting up an outward-facing SPARC-Linux system. Please email me if you want an account. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
Well, it seems we have some progress now. The WaitForThreadTerminate(BeginThread(@__dummythread), 300); seems to fix it on Windows. At least for 2 concurrent requests. For some reason Apache cannot seem to want to run more than 2 requests at a time. If more comes in at a time, the first 2 starts running and the rest have to wait till at least 1 current request is handled. Even when MaxConnectionsPerServer is set to higher than 2 in the registry. uses cmem; did not fix the crash on Windows. I will try to make apache modules load in Linux next so some tests can be done there too. AB Jonas Maebe wrote: On 24 Sep 2008, at 13:02, Michael Van Canneyt wrote: On Wed, 24 Sep 2008, Jonas Maebe wrote: On 24 Sep 2008, at 12:35, Michael Van Canneyt wrote: This is a known problem; the heap manager does not function correctly in a DLL when an external program (apache, in this case) creates new threads. The heap manager is simply not thread safe until the FPC threading system has been initialised (by starting a thread). It is not that simple. The heap manager cannot handle situations where threads have been started by code that is not aware of the FPC threading mechanisms - such as apache. Ah yes, that's indeed a problem with the new 2.3.x heap manager. I don't think the 2.2.x heap manager cares though, since it uses a regular critical section/mutex. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Lazarus Apache module crashes during concurrent requests
For me in Windows XP 32bit/ FPC (apache modules load properly): sizeof(request_rec)=416 sizeof(module_struct)=56 For me in Ubuntu 8.04 32bit/ FPC (apache modules don't load): sizeof(request_rec)=412 sizeof(module_struct)=56 Used exactly the same files to compile a project on Ubuntu but for some reason it is 4 bytes shorter there for request_rec. This shouldn't effect the module loading at apache2 startup, right? Only module_struct incompatibility should give the ...Can't locate API module structure `mod_apache1' in file ... error. Michael Van Canneyt wrote: Yes: please print the size of the Request_rec (or TRequest_Rec) and the same record in C. Compare if they are equal. Same for the module record. If they are not equal, then we know it is a problem with the pascal definition of this record. I've had to do this exercise about 30 times myself on various platforms to get it right. Maybe they changed the size again. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel