[fpc-pascal] Apache module with fpc 2.4.x on Apache 2.2.x (64bit)

Takashi Ishikawa ishikawa at simple-way.co.jp
Thu May 26 22:36:57 CEST 2011


Hello, all

I'm writing apache module with fpc.

When I compile my program on fpc 2.4.4, Apache terminate immediately. But  
on fpc 2.2.4, Apache and my module will work fine.

Code is compiled with no problem. Apache can load module. But the running  
has problem.

Is there anyone who running a module compiled with fpc 2.4.x on Apache?


I tested some envirment:
- OS: CentOS 5.5 / Fedora 12
- Apache: 2.2.3 / 2.2.17
- Arch: x86_64
- FPC: 2.2.4 / 2.4.2 / 2.4.4


Test code:
-----
library lib_mod_simple;

{$ifdef fpc}
   {$mode objfpc}{$H+}
{$endif}

uses SysUtils, httpd, apr;

var
  mod_simple: module; public name 'mod_simple';

exports
   mod_simple name 'mod_simple';

function DefaultHandler(r: Prequest_rec): Integer; cdecl;
begin
   Result := DECLINED;
end;

procedure RegisterHooks(p: Papr_pool_t); cdecl;
begin
   ap_hook_handler(@DefaultHandler, nil, nil, APR_HOOK_MIDDLE);
end;

begin
   FillChar(mod_simple, SizeOf(mod_simple), 0);
   STANDARD20_MODULE_STUFF(mod_simple);
   with mod_simple do
   begin
     name := 'mod_simple.so';
     register_hooks := @RegisterHooks;
   end;
end.
-----


Compilation options:
-----
fpc -Xs -XX -fPIC -dFPCAPACHE_2_2 -omod_simple.so mod_simple.pas
-----


LoadModule in httpd.conf:
-----
LoadModule mod_simple modules/mod_simple.so
-----


Test#1 with CentOS 5.5, Apache 2.2.3, FPC 2.2.4
-----
# gdb httpd
(gdb) r -X

Starting program: /usr/sbin/httpd -X
[Thread debugging using libthread_db enabled]
Detaching after fork from child process 28066.
Detaching after fork from child process 28080.

-----


Test#2 with CentOS 5.5, Apache 2.2.3, FPC 2.4.4
-----
# gdb httpd
(gdb) r -X

Starting program: /usr/sbin/httpd -X
[Thread debugging using libthread_db enabled]
Detaching after fork from child process 28119.

Program exited normally.

(gdb)
-----

Test with CentOS 5.5, Apache 2.2.3, FPC 2.4.2
Test with CentOS 5.5, Apache 2.2.3, FPC 2.4.4
Test with Fedora 12, Apache 2.2.17, FPC 2.4.4
   same as Test#2


In test#1, it seemed to be success. When I access the webserver with  
browser, apache respond normal page.

In test#2, apache shows no error. But process terminate. And when I  
accessed the webserver, apache didn't respond.


It is possible to develop by using FPC 2.2.4. However, the future, I want  
to compile with a newer version of FPC. Is there any idea to running  
module with FPC 2.4.x?



Thanks,
   Takashi


-- 
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

   Takashi Ishikawa
     ishikawa at simple-way.co.jp
   SimpleWay Corporation



More information about the fpc-pascal mailing list