Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-08

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

12 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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 NodeNil DO
   BEGIN
     IF (Node.NodeName='title') AND (Node.FirstChildNil) THEN
       Title:=Node.FirstChild.NodeValue;   // <--- Dies here???
     IF (Node.NodeName='description') AND (Node.FirstChildNil) THEN
       Desc:=Node.FirstChild.NodeValue;
     IF (Node.NodeName='link') AND (Node.FirstChildNil) THEN
       Link:=Node.FirstChild.NodeValue;
     IF (Node.NodeName='pubDate') AND (Node.FirstChildNil) THEN
       pubDate:=Node.FirstChild.NodeValue;
     Node:=Node.NextSibling;
   END;
END;
PROCEDURE ProcessNode(Node: TDOMNode);
BEGIN
   IF (Node.NodeName='item') AND (Node.FirstChildnil) THEN
     ProcessItem(Node.FirstChild)
   ELSE
   BEGIN
     IF Node.FirstChildnil then
       ProcessNode(Node.FirstChild);
   END;
   IF Node.NextSiblingnil 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
Søren Ager
to Søren Ager
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
Søren Ager
to Søren Ager
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
Tomas Hajny
to Søren Ager

Date sent: Mon, 22 Aug 2005 20:01:38 +0200
From: Sřren Ager
To: FPC-Pascal users discussions
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

Hi Soren

Show quoted text 17 lines
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

Tomas Hajny

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

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

.
.

Show quoted text 19 lines
> 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

Florian Klaempfl
to Tomas Hajny
Tomas Hajny wrote 35 lines
From: Tomas Hajny To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by SIGSEGV" Send reply to: 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.

Tomas Hajny
to Florian Klaempfl

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

Show quoted text 42 lines
Tomas Hajny wrote: > From: Tomas Hajny > To: FPC-Pascal users discussions > Subject: Re: [fpc-pascal] > fpc 2.0 and DOM/xml under OS/2 gives me "Process terminated by > SIGSEGV" Send reply to: 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

Søren Ager
to Tomas Hajny: Date sent: Mon, 22 Aug 2005 20:01:38 +0200 From: Sřren Ager To: …
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
Tomas Hajny
to Søren Ager

Søren Ager napsal(a):

Show quoted text 6 lines
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. ;-)

Show quoted text 9 lines
> 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.

Show quoted text 5 lines
> 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

Søren Ager
to Tomas Hajny
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
Tomas Hajny
to Søren Ager

Date sent: Thu, 15 Sep 2005 18:53:51 +0200
From: Søren Ager
To: FPC-Pascal users discussions
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

Show quoted text 11 lines
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.

Show quoted text 5 lines
> 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

Søren Ager
to Tomas Hajny
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