[Lazarus] Error 500

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Error 500

silvioprog
Hi.

In a simple CGI app, I try to use TFreeTypeFont class, but without success.
The error returned is "Error 500"(see log in [1]).

In attached I send a small sample to reproduce the error.

*Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3!
on Windows Seven 64.*

Thx.

[1]:
---------------------------
Date: Tue, 05 Apr 2011 14:54:11 GMT
Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l
mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4
Perl/v5.10.1
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Connection: close
Content-Type: text/html; charset=iso-8859-1
Content-Language: pt-br
---------------------------

500 Internal Server Error

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

FreeTypeFontError.zip (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

silvioprog
2011/4/5 silvioprog <[hidden email]>:

> Hi.
>
> In a simple CGI app, I try to use TFreeTypeFont class, but without success.
> The error returned is "Error 500"(see log in [1]).
>
> In attached I send a small sample to reproduce the error.
>
> *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3!
> on Windows Seven 64.*
>
> Thx.
>
> [1]:
> ---------------------------
> Date: Tue, 05 Apr 2011 14:54:11 GMT
> Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l
> mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4
> Perl/v5.10.1
> Vary: accept-language,accept-charset
> Accept-Ranges: bytes
> Connection: close
> Content-Type: text/html; charset=iso-8859-1
> Content-Language: pt-br
> ---------------------------
>
> 500 Internal Server Error

I'm trying to write a text in an image and show in the browser. This
code[1] not works (returns error 500).

[1] (http://www.mail-archive.com/lazarus@.../msg18488/t.pp):
uses
  FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG;

var
  img: TFPMemoryImage;
  c: TFPImageCanvas;
  f: TFreeTypeFont;
begin
  img := TFPMemoryImage.Create(500, 100);
  c := TFPImageCanvas.Create(img);
  f := TFreeTypeFont.Create;
  c.Clear;
  c.Pen.FPColor := colRed;
  f.Name := 'Times';
  f.Size := 14;
  f.FPColor := colRed;
  c.Font := f;
  c.TextOut(10, 20, 'sample text 12345');
  img.SaveToFile('test.png');
  f.Free;
  c.Free;
  img.Free;
end.

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Mattias Gaertner
On Tue, 5 Apr 2011 12:14:58 -0300
silvioprog <[hidden email]> wrote:

> 2011/4/5 silvioprog <[hidden email]>:
> > Hi.
> >
> > In a simple CGI app, I try to use TFreeTypeFont class, but without success.
> > The error returned is "Error 500"(see log in [1]).
> >
> > In attached I send a small sample to reproduce the error.
> >
> > *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3!
> > on Windows Seven 64.*
> >
> > Thx.
> >
> > [1]:
> > ---------------------------
> > Date: Tue, 05 Apr 2011 14:54:11 GMT
> > Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l
> > mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4
> > Perl/v5.10.1
> > Vary: accept-language,accept-charset
> > Accept-Ranges: bytes
> > Connection: close
> > Content-Type: text/html; charset=iso-8859-1
> > Content-Language: pt-br
> > ---------------------------
> >
> > 500 Internal Server Error
>
> I'm trying to write a text in an image and show in the browser. This
> code[1] not works (returns error 500).

Look into your apache logs for more details.

 

> [1] (http://www.mail-archive.com/lazarus@.../msg18488/t.pp):
> uses
>   FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG;
>
> var
>   img: TFPMemoryImage;
>   c: TFPImageCanvas;
>   f: TFreeTypeFont;
> begin
>   img := TFPMemoryImage.Create(500, 100);
>   c := TFPImageCanvas.Create(img);
>   f := TFreeTypeFont.Create;
>   c.Clear;
>   c.Pen.FPColor := colRed;
>   f.Name := 'Times';
>   f.Size := 14;
>   f.FPColor := colRed;
>   c.Font := f;
>   c.TextOut(10, 20, 'sample text 12345');
>   img.SaveToFile('test.png');

Has the cgi script write permissions when running as apache user?


>   f.Free;
>   c.Free;
>   img.Free;
> end.


Mattias
 

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Michael Van Canneyt


On Tue, 5 Apr 2011, Mattias Gaertner wrote:

> On Tue, 5 Apr 2011 12:14:58 -0300
> silvioprog <[hidden email]> wrote:
>
>> 2011/4/5 silvioprog <[hidden email]>:
>>> Hi.
>>>
>>> In a simple CGI app, I try to use TFreeTypeFont class, but without success.
>>> The error returned is "Error 500"(see log in [1]).
>>>
>>> In attached I send a small sample to reproduce the error.
>>>
>>> *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3!
>>> on Windows Seven 64.*
>>>
>>> Thx.
>>>
>>> [1]:
>>> ---------------------------
>>> Date: Tue, 05 Apr 2011 14:54:11 GMT
>>> Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l
>>> mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4
>>> Perl/v5.10.1
>>> Vary: accept-language,accept-charset
>>> Accept-Ranges: bytes
>>> Connection: close
>>> Content-Type: text/html; charset=iso-8859-1
>>> Content-Language: pt-br
>>> ---------------------------
>>>
>>> 500 Internal Server Error
>>
>> I'm trying to write a text in an image and show in the browser. This
>> code[1] not works (returns error 500).
>
> Look into your apache logs for more details.
>
>
>> [1] (http://www.mail-archive.com/lazarus@.../msg18488/t.pp):
>> uses
>>   FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG;
>>
>> var
>>   img: TFPMemoryImage;
>>   c: TFPImageCanvas;
>>   f: TFreeTypeFont;
>> begin
>>   img := TFPMemoryImage.Create(500, 100);
>>   c := TFPImageCanvas.Create(img);
>>   f := TFreeTypeFont.Create;
>>   c.Clear;
>>   c.Pen.FPColor := colRed;
>>   f.Name := 'Times';

Where do you load the font path ?
I miss things like

   ftFont.InitEngine;
   FontMgr.SearchPath:='/usr/lib/X11/fonts/truetype';

or on windows

   FontMgr.SearchPath:='c\windows\fonts';


>>   f.Size := 14;
>>   f.FPColor := colRed;
>>   c.Font := f;
>>   c.TextOut(10, 20, 'sample text 12345');
>>   img.SaveToFile('test.png');
>
> Has the cgi script write permissions when running as apache user?

It is on windows, so it should be OK.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Alexander Klenin
On Wed, Apr 6, 2011 at 09:11, Michael Van Canneyt
<[hidden email]> wrote:
>
> or on windows
>
>  FontMgr.SearchPath:='c\windows\fonts';

On Windows this is done in the initializtion section of FTFont unit.

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

silvioprog
In reply to this post by Mattias Gaertner
2011/4/5 Mattias Gaertner <[hidden email]>:
> Look into your apache logs for more details.

The logs:

In C:\xampp\apache\logs\access.log:
----------------------------------
::1 - - [05/Apr/2011:20:48:45 -0300] "GET /cgi-bin/bug.cgi HTTP/1.1"
500 1319 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0)
Gecko/20100101 Firefox/4.0"
----------------------------------

In C:\xampp\apache\logs\error.log:
----------------------------------
(...)
[Tue Apr 05 20:47:33 2011] [notice] Child 5472: Starting thread to
listen on port 80.
[Tue Apr 05 20:47:33 2011] [notice] Child 5472: Starting thread to
listen on port 80.
[Tue Apr 05 20:48:45 2011] [error] [client ::1] Premature end of
script headers: bug.cgi
----------------------------------

> Has the cgi script write permissions when running as apache user?
>
> Mattias

Yes. My UAC is totaly disabled on Windows.

To tests, I downloaded this DLL[1], and I put in
"C:\xampp\cgi-bin\freetype-6.dll" and
"C:\Windows\system32\freetype-6.dll".

[1] http://www.dlldump.com/download-dll-files_new.php/dllfiles/F/freetype6.dll/2.1.7.1505r/download.html

I changed my code to:

procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
begin
  Handled := True;
  InitEngine; // If I comment this line, the error disappears. :o
end;

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

silvioprog
In reply to this post by Michael Van Canneyt
2011/4/5 Michael Van Canneyt <[hidden email]>:
> Where do you load the font path ?
> I miss things like
>
>  ftFont.InitEngine;
>  FontMgr.SearchPath:='/usr/lib/X11/fonts/truetype';
>
> or on windows
>
>  FontMgr.SearchPath:='c\windows\fonts';

In fonts of Windows:

procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
begin
  Handled := True;
  ftFont.InitEngine; // <<-- Error is here. :(
  FontMgr.SearchPath := 'C:\WINDOWS\Fonts\';
end;

>
> Michael.

How I get a "full log" with CGIs erros?

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Graeme Geldenhuys
On 06/04/2011 03:20, silvioprog wrote:
>
> How I get a "full log" with CGIs erros?

I log all things, and exceptions to a log file in a temp directory (just
while developing the cgi app). Alternatively you can log to a
debugserver too - see the dbugintf unit in FCL.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Lukasz Sokol
In reply to this post by silvioprog
On 06/04/2011 01:59, silvioprog wrote:

> procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest;
>   AResponse: TResponse; var Handled: Boolean);
> begin
>   Handled := True;
>   InitEngine; // If I comment this line, the error disappears. :o
> end;
>

Just a thought:

On 5/04/2011 23:39, Alexander Klenin wrote:
> On Wed, Apr 6, 2011 at 09:11, Michael Van Canneyt
> <[hidden email]> wrote:
> > >
> > > or on windows
> > >
> > >  FontMgr.SearchPath:='c\windows\fonts';
> On Windows this is done in the initializtion section of FTFont unit.
>
> -- Alexander S. Klenin

Maybe the initialization is already done somewhere i.e. you don't need to
run it twice ?

L.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

silvioprog
In reply to this post by Graeme Geldenhuys
2011/4/6 Graeme Geldenhuys <[hidden email]>:
> I log all things, and exceptions to a log file in a temp directory (just
> while developing the cgi app). Alternatively you can log to a
> debugserver too - see the dbugintf unit in FCL.
>
> Regards,
>  - Graeme -
> --
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://fpgui.sourceforge.net/

I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.

ps. Hm... my CGI app is still with error 500. :(

Thx.

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Graeme Geldenhuys
On 07/04/2011 00:06, silvioprog wrote:
>
> I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.

WARNING:
Be careful with debugserver under Windows - you can't always trust the
results.  If you have a process that runs fast, and generates a lot of
debug  messages  (many  per  second), debugserver looses many of those
messages. I reported this bug, but can't find it in Mantis now (Mantis
searching sucks).


> ps. Hm... my CGI app is still with error 500. :(

I  would  suggest  you  look  at  Apache  log  files,  and maybe place
SendDebug()  calls  inside  your  application  to see what it executes
before  the  error - narrowing down it's location. I feel your pain...
debugging  CGI  apps  are  a  nightmare! Yet another reason I hate web
applications. :)


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

Michael Van Canneyt


On Thu, 7 Apr 2011, Graeme Geldenhuys wrote:

> On 07/04/2011 00:06, silvioprog wrote:
>>
>> I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.
>
> WARNING:
> Be careful with debugserver under Windows - you can't always trust the
> results.  If you have a process that runs fast, and generates a lot of
> debug  messages  (many  per  second), debugserver looses many of those
> messages. I reported this bug, but can't find it in Mantis now (Mantis
> searching sucks).
>
>
>> ps. Hm... my CGI app is still with error 500. :(
>
> I  would  suggest  you  look  at  Apache  log  files,  and maybe place
> SendDebug()  calls  inside  your  application  to see what it executes
> before  the  error - narrowing down it's location. I feel your pain...
> debugging  CGI  apps  are  a  nightmare! Yet another reason I hate web
> applications. :)

There are 2 solutions:
- FastCGI
- Embedded webserver
Both can easily be debugged, and the final result can still be a CGI app.
With some extra work you can have 1 binary that functions as the 3 types of app.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Error 500

silvioprog
In reply to this post by Graeme Geldenhuys
2011/4/7 Graeme Geldenhuys <[hidden email]>:

> On 07/04/2011 00:06, silvioprog wrote:
>>
>> I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.
>
> WARNING:
> Be careful with debugserver under Windows - you can't always trust the
> results.  If you have a process that runs fast, and generates a lot of
> debug  messages  (many  per  second), debugserver looses many of those
> messages. I reported this bug, but can't find it in Mantis now (Mantis
> searching sucks).
>
>> ps. Hm... my CGI app is still with error 500. :(
>
> I  would  suggest  you  look  at  Apache  log  files,  and maybe place
> SendDebug()  calls  inside  your  application  to see what it executes
> before  the  error - narrowing down it's location. I feel your pain...
> debugging  CGI  apps  are  a  nightmare! Yet another reason I hate web
> applications. :)
>
>
> Regards,
>  - Graeme -
>
> --
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://fpgui.sourceforge.net/

Case I solves the problem, I'll post here. ;)

Thanks. :)

--
Silvio Clécio
=============================================
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR
=============================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus