fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

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

fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Søren Ager
Hi,

I have the following snippet of code (which works under Windows):

PROGRAM XMLTest;

USES Dom, XMLRead;

PROCEDURE ProcessItem(Node: TDOMNode);
VAR
   i: Integer;
   attr: TDOMNode;
   Title,Desc,Link,pubDate : String;
BEGIN
   Title:=''; Desc:=''; Link:=''; pubDate:='';
   WHILE Node<>Nil DO
   BEGIN
     IF (Node.NodeName='title') AND (Node.FirstChild<>Nil) THEN
       Title:=Node.FirstChild.NodeValue;   // <--- Dies here???
     IF (Node.NodeName='description') AND (Node.FirstChild<>Nil) THEN
       Desc:=Node.FirstChild.NodeValue;
     IF (Node.NodeName='link') AND (Node.FirstChild<>Nil) THEN
       Link:=Node.FirstChild.NodeValue;
     IF (Node.NodeName='pubDate') AND (Node.FirstChild<>Nil) THEN
       pubDate:=Node.FirstChild.NodeValue;
     Node:=Node.NextSibling;
   END;
END;

PROCEDURE ProcessNode(Node: TDOMNode);
BEGIN
   IF (Node.NodeName='item') AND (Node.FirstChild<>nil) THEN
     ProcessItem(Node.FirstChild)
   ELSE
   BEGIN
     IF Node.FirstChild<>nil then
       ProcessNode(Node.FirstChild);
   END;
   IF Node.NextSibling<>nil then
     ProcessNode(node.NextSibling);
END;

PROCEDURE ProcessXML(FileName: String);
VAR
   xml: TXMLDocument;
BEGIN
   ReadXMLFile(xml,FileName);
   ProcessNode(xml);
   xml.Free;
END;

BEGIN
   ProcessXML('ts2.xml');
END.


When run with this xml file it crashes in ProcessItem (when it tries to
get the Title):

<?xml version="1.0" ?>
<rss version="2.0">

<channel>
<title>Test XML</title>
<ttl>60</ttl>

<item>
   <title>This is a test</title>
   <link>http://www.somewhere.com</link>
   <pubDate>Fri, 19 Aug 2005 03:58:37 -0800</pubDate>
</item>
</channel>
</rss>

Any ideas why?

--

Hilsen
   Søren

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Søren Ager
On 21-08-05 15.49, Søren Ager wrote:

> Any ideas why?

If it's any help here is teh contents of popuplog.os2:


08-21-2005  15:44:56  SYS3175  PID 01d0  TID 0001  Slot 006f
D:\SOURCE\ABRG\XMLTEST.EXE
c0000005
00000000
P1=00000001  P2=00000000  P3=XXXXXXXX  P4=XXXXXXXX
EAX=200602f4  EBX=00000000  ECX=0000000e  EDX=0009fd44
ESI=2000888c  EDI=00063bfc
DS=0053  DSACC=f0f3  DSLIM=ffffffff
ES=0053  ESACC=f0f3  ESLIM=ffffffff
FS=150b  FSACC=00f3  FSLIM=00000030
GS=0000  GSACC=****  GSLIM=********
CS:EIP=005b:00000000  CSACC=f0df  CSLIM=ffffffff
SS:ESP=0053:0009fd38  SSACC=f0f3  SSLIM=ffffffff
EBP=0009fd4c  FLG=00012202


--

Hilsen
   Søren

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Søren Ager
On 21-08-05 15.49, Søren Ager wrote:

> Any ideas why?

Changing:

   DOMString = WideString;
   DOMPChar = PWideChar;

to:

   DOMString = String;
   DOMPChar = PChar;

in dom.pp fixed the problem. So I guess the WideString is broken in fpc
for OS/2. Is there anyway to disable it so I don't run into this problem
in the future?

--

Hilsen
   Søren

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Tomas Hajny
Date sent:       Mon, 22 Aug 2005 20:01:38 +0200
From:           Sřren Ager <[hidden email]>
To:             FPC-Pascal users discussions <[hidden email]>
Subject:         Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me "Process
        terminated by SIGSEGV"
Send reply to:   FPC-Pascal users discussions <[hidden email]>
        <mailto:[hidden email]?subject=unsubscribe>
        <mailto:[hidden email]?subject=subscribe>


Hi Soren

> On 21-08-05 15.49, Sřren Ager wrote:
>
> > Any ideas why?
>
> Changing:
>
>    DOMString = WideString;
>    DOMPChar = PWideChar;
>
> to:
>
>    DOMString = String;
>    DOMPChar = PChar;
>
> in dom.pp fixed the problem. So I guess the WideString is broken in
> fpc for OS/2. Is there anyway to disable it so I don't run into this
> problem in the future?

Sorry, I had your e-mails (together with many other :-( ) in backlog
from the time of my holiday...

For the first question - the best way to find exact place of SIGSEGV
etc. in FPC programs under OS/2 is to compile everything with debug
information (including RTL, FCL etc.) and either run them under
(PM)GDB, or to open the generated core file in (PM)GDB afterwards and
let it show you the exact location.

For the second one - I believe that it's a bug in common part of FPC
RTL, in fact, that it crashes when WideString manager is not
initialized. I didn't find time for implementing the OS/2 specific
support for WideString, but it shouldn't crash nevertheless. I'd
suggest to create a simplified test case and add it to our bug
repository so it doesn't get forgotten.

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Tomas Hajny
In reply to this post by Søren Ager
From:           Tomas Hajny <[hidden email]>
To:             FPC-Pascal users discussions <[hidden email]>
Subject:         Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"
Send reply to:   [hidden email]
Date sent:       Fri, 9 Sep 2005 23:32:37 +0200

> > On 21-08-05 15.49, Sřren Ager wrote:
 .
 .

> > in dom.pp fixed the problem. So I guess the WideString is broken in
> > fpc for OS/2. Is there anyway to disable it so I don't run into this
> > problem in the future?
>
> Sorry, I had your e-mails (together with many other :-( ) in backlog
> from the time of my holiday...
>
> For the first question - the best way to find exact place of SIGSEGV
> etc. in FPC programs under OS/2 is to compile everything with debug
> information (including RTL, FCL etc.) and either run them under
> (PM)GDB, or to open the generated core file in (PM)GDB afterwards and
> let it show you the exact location.
>
> For the second one - I believe that it's a bug in common part of FPC
> RTL, in fact, that it crashes when WideString manager is not
> initialized. I didn't find time for implementing the OS/2 specific
> support for WideString, but it shouldn't crash nevertheless. I'd
> suggest to create a simplified test case and add it to our bug
> repository so it doesn't get forgotten.

...which you already did (at least for the OS/2-specific part), as
I've found in the meantime... ;-)

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Florian Klämpfl
Tomas Hajny wrote:

> From:           Tomas Hajny <[hidden email]>
> To:             FPC-Pascal users discussions <[hidden email]>
> Subject:         Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"
> Send reply to:   [hidden email]
> Date sent:       Fri, 9 Sep 2005 23:32:37 +0200
>
>
>>>On 21-08-05 15.49, Sřren Ager wrote:
>
>  .
>  .
>
>>>in dom.pp fixed the problem. So I guess the WideString is broken in
>>>fpc for OS/2. Is there anyway to disable it so I don't run into this
>>>problem in the future?
>>
>>Sorry, I had your e-mails (together with many other :-( ) in backlog
>>from the time of my holiday...
>>
>>For the first question - the best way to find exact place of SIGSEGV
>>etc. in FPC programs under OS/2 is to compile everything with debug
>>information (including RTL, FCL etc.) and either run them under
>>(PM)GDB, or to open the generated core file in (PM)GDB afterwards and
>>let it show you the exact location.
>>
>>For the second one - I believe that it's a bug in common part of FPC
>>RTL, in fact, that it crashes when WideString manager is not
>>initialized. I didn't find time for implementing the OS/2 specific
>>support for WideString, but it shouldn't crash nevertheless. I'd
>>suggest to create a simplified test case and add it to our bug
>>repository so it doesn't get forgotten.
>
>
> ...which you already did (at least for the OS/2-specific part), as
> I've found in the meantime... ;-)

Fixing this is easy: add a call to initwidestringmanager; in the init
code of the os2 system unit. It's from rtl/inc/wstrings.inc. This pulls
in some generic widestring code.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Tomas Hajny


Date sent:       Sat, 10 Sep 2005 11:24:16 +0200
From:           Florian Klaempfl <[hidden email]>
To:             [hidden email],
        FPC-Pascal users discussions <[hidden email]>
Subject:         Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me "Process
        terminated by SIGSEGV"

> Tomas Hajny wrote:
>
> > From:           Tomas Hajny <[hidden email]>
> > To:             FPC-Pascal users discussions
> > <[hidden email]> Subject:         Re: [fpc-pascal]
> > fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by
> > SIGSEGV" Send reply to:   [hidden email] Date sent:       Fri, 9 Sep
> > 2005 23:32:37 +0200
> >
> >
> >>>On 21-08-05 15.49, Sřren Ager wrote:
> >
> >  .
> >  .
> >
> >>>in dom.pp fixed the problem. So I guess the WideString is broken in
> >>>fpc for OS/2. Is there anyway to disable it so I don't run into
> >>>this problem in the future?
> >>
> >>Sorry, I had your e-mails (together with many other :-( ) in backlog
> >>from the time of my holiday...
> >>
> >>For the first question - the best way to find exact place of SIGSEGV
> >>etc. in FPC programs under OS/2 is to compile everything with debug
> >>information (including RTL, FCL etc.) and either run them under
> >>(PM)GDB, or to open the generated core file in (PM)GDB afterwards
> >>and let it show you the exact location.
> >>
> >>For the second one - I believe that it's a bug in common part of FPC
> >>RTL, in fact, that it crashes when WideString manager is not
> >>initialized. I didn't find time for implementing the OS/2 specific
> >>support for WideString, but it shouldn't crash nevertheless. I'd
> >>suggest to create a simplified test case and add it to our bug
> >>repository so it doesn't get forgotten.
> >
> >
> > ...which you already did (at least for the OS/2-specific part), as
> > I've found in the meantime... ;-)
>
> Fixing this is easy: add a call to initwidestringmanager; in the init
> code of the os2 system unit. It's from rtl/inc/wstrings.inc. This
> pulls in some generic widestring code.

Easy one, indeed, fixed now (at least for this part - there's still
no platform-specific support added for OS/2, though). It shouldn't
crash any more.

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV"

Søren Ager
In reply to this post by Tomas Hajny
On 09-09-05 23.35, Tomas Hajny wrote:

> Sorry, I had your e-mails (together with many other :-( ) in backlog
> from the time of my holiday...

No problem - hope you had a great holiday.

> For the first question - the best way to find exact place of SIGSEGV
> etc. in FPC programs under OS/2 is to compile everything with debug
> information (including RTL, FCL etc.)

This needs a little more explaining. I have tried pointing fpc to the
rtl/fcl source when compiling - but I always ends up with a compile
error somewhere in the rtl (can't remember where right now). Is there a
description of how to take the compiler add the source and then be able
build your programs with full debug information.

> either run them under (PM)GDB, or to open the generated core file in (PM)GDB

After being used to vp I am still struggeling with gdb :-( But I hope I
will master it eventualy.

> For the second one - I believe that it's a bug in common part of FPC
> RTL, in fact, that it crashes when WideString manager is not
> initialized.

I can see this has been fixed - thanks.

--

Hilsen
   Søren
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Processterminated by SIGSEGV"

Tomas Hajny
Søren Ager napsal(a):
> On 09-09-05 23.35, Tomas Hajny wrote:
>
>> Sorry, I had your e-mails (together with many other :-( ) in backlog
>> from the time of my holiday...
>
> No problem - hope you had a great holiday.

Yes, it was a good one, although somewhat rainy. ;-)


>> For the first question - the best way to find exact place of SIGSEGV
>> etc. in FPC programs under OS/2 is to compile everything with debug
>> information (including RTL, FCL etc.)
>
> This needs a little more explaining. I have tried pointing fpc to the
> rtl/fcl source when compiling - but I always ends up with a compile
> error somewhere in the rtl (can't remember where right now). Is there a
> description of how to take the compiler add the source and then be able
> build your programs with full debug information.

Well, there are several ways how to do it. Just RTL compilation with debug
information is done by running "make debug" in the /rtl/os2 source
directory. The same could be done for /packages/base and /fcl.
Alternatively, it would be possible to build the whole thing (e.g.
including the compiler as well) in usual ZIP files using "make os2zip
SNAPSHOT=1 DEBUG=1" in the root directory, but you need to have checkout
of the "fpcbuild" SVN repository (just the "fpc" repository is not
enough). See the "Build FAQ" (http://www.stack.nl/~marcov/buildfaq.pdf)
for other options and additional information. If you find any
difficulties, just ask here.


>> either run them under (PM)GDB, or to open the generated core file in
>> (PM)GDB
>
> After being used to vp I am still struggeling with gdb :-( But I hope I
> will master it eventualy.

To be honest, I understand this completely... :-( The support which is
available for other FPC platforms is much better (IDE with debugger
support), but this is fairly difficult to achieve for OS/2 due to problems
with OS/2 gdb version (spawned from GDB version 4.16 ten years ago and
never brought up to date - the current GDB version is something like
6.30). Implementation of native debugger emulating the GDB interface would
be probably possible, but is a lot of work. I asked Allan about the
possibility to get access to VP/2 debugger sources after he announced end
of VP life, but he didn't respond to that e-mail, unfortunately. :-(

Nevertheless, if you have particular questions regarding (PM)GDB, just ask.

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Processterminated by SIGSEGV"

Søren Ager
On 14-09-05 13.47, Tomas Hajny wrote:

> Well, there are several ways how to do it. Just RTL compilation with debug
> information is done by running "make debug" in the /rtl/os2 source
> directory.

Thanks - I have done that so now I have a rtl with debug info. There is
one error though:

sysutils.pp(571,22) Error: range check error while evaluating constants

> Alternatively, it would be possible to build the whole thing (e.g.
> including the compiler as well) in usual ZIP files using "make os2zip

I might play around with that some day...

> Implementation of native debugger emulating the GDB interface would
> be probably possible, but is a lot of work.

It would be nice with a decent debugger - I might have to make one
myself ;-)

> I asked Allan about the
> possibility to get access to VP/2 debugger sources after he announced end
> of VP life, but he didn't respond to that e-mail, unfortunately. :-(

That would have been awsome


--

Hilsen
   Søren
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc 2.0 and DOM/xml under OS/2 gives me "Processterminated by SIGSEGV"

Tomas Hajny
Date sent:       Thu, 15 Sep 2005 18:53:51 +0200
From:           Søren Ager <[hidden email]>
To:             FPC-Pascal users discussions <[hidden email]>
Subject:         Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me
        "Processterminated by SIGSEGV"
Send reply to:   FPC-Pascal users discussions <[hidden email]>
        <mailto:[hidden email]?subject=unsubscribe>
        <mailto:[hidden email]?subject=subscribe>

> On 14-09-05 13.47, Tomas Hajny wrote:
>
> > Well, there are several ways how to do it. Just RTL compilation with
> > debug information is done by running "make debug" in the /rtl/os2
> > source directory.
>
> Thanks - I have done that so now I have a rtl with debug info. There
> is one error though:
>
> sysutils.pp(571,22) Error: range check error while evaluating
> constants

Ah, right. Makefile target "debug" turns compile time range checking
on; FindFirst was correct in unit Dos, but not here. Fixed in SVN
now.


> > Alternatively, it would be possible to build the whole thing
(e.g.
> > including the compiler as well) in usual ZIP files using "make
> > os2zip
>
> I might play around with that some day...

I can send you the OS/2 .cmd files I use (starting with selection of
the right compiler version up to complete snapshot building process)
if you want. Nothing spectacular, just to save some time.


> > Implementation of native debugger emulating the GDB interface would
> > be probably possible, but is a lot of work.
>
> It would be nice with a decent debugger - I might have to make one
> myself ;-)

You're certainly more than welcome. ;-) I know at least two OS/2
debuggers with full source code available (OpenWatcom and IBM's
SD386), but these aren't written in Pascal, of course (i.e. they
could be possibly used for reference, but nothing more).

Regards (or "Hilsen" - I guess it means the same, right? ;-) )

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Recompiling with debug (was: fpc 2.0 and DOM/xml under OS/2 gives me "Processterminated by SIGSEGV")

Søren Ager
On 15-09-05 23.08, Tomas Hajny wrote:

>>>Alternatively, it would be possible to build the whole thing

Well I actually ended up recompiling the compiler as well. But is will
not build the fcl with debug info now (works without debug info):

Free Pascal Compiler version 2.1.1 [2005/09/15] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: OS/2
Compiling xmlstreaming.pp
Assembling xmlstreaming
238 Lines compiled, 0.2 sec

Process terminated by SIGSEGV
core dumped
make.exe[2]: *** [xmlstreaming.ppu] Segmentation fault


> I can send you the OS/2 .cmd files I use (starting with selection of
> the right compiler version up to complete snapshot building process)
> if you want. Nothing spectacular, just to save some time.

Thanks - I would like that.

> Regards (or "Hilsen" - I guess it means the same, right? ;-) )

Yes, that is right.

--

Hilsen
   Søren
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal