[Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-29 Thread Luca Olivetti via Lazarus

Hello,

I'm playing with lazarus 1.6 (a bit late, I know) with fpc 2.6.4, win32, 
 and I have a strange problem with the ide:
the object inspector information box shows nothing and, eventually, when 
I click on fields in the object inspector, lazarus becomes unresponsive 
and then crashes.
If try to begug the ide under lazarus (tried both with the old 1.4.4 and 
the new 1.6), I see that it crashes in the heap manager (heap.inc) when 
it tries to allocate 1117978624 bytes (!)

This is the call stack:

#0 HANDLEERRORADDRFRAME(-1, 0x7c9201e0, 0x7c91e920) at 
D:\fpc-2.6.4\rtl\inc\system.inc:962

#1 HANDLEERRORFRAME(203, 0x10f6f92c) at D:\fpc-2.6.4\rtl\inc\system.inc:992
#2 HANDLEERROR(203) at D:\fpc-2.6.4\rtl\inc\system.inc:1002
#3 ALLOC_OSCHUNK(0x17619c4, 0, 1117978624) at 
D:\fpc-2.6.4\rtl\inc\heap.inc:833

#4 SYSGETMEM_VAR(1117973760) at D:\fpc-2.6.4\rtl\inc\heap.inc:1006
#5 SYSGETMEM(1117973760) at D:\fpc-2.6.4\rtl\inc\heap.inc:1050
#6 GETMEM(0x1b, 1117973745) at D:\fpc-2.6.4\rtl\inc\heap.inc:251
#7 NEWANSISTRING(1117973736) at D:\fpc-2.6.4\rtl\inc\astrings.inc:64
#8 FPC_TRUELY_ANSISTR_UNIQUE(0xfda683) at 
D:\fpc-2.6.4\rtl\inc\astrings.inc:659

#9 fpc_ansistr_unique at D:\fpc-2.6.4\rtl\i386\i386.inc:1585
#10 UPPERCASE(0xfda683 #255#139'E'#152#137'E'#248#198'E'#224, 0xfda683 
#255#139'E'#152#137'E'#248#198'E'#224) at 
D:\fpc-2.6.4\rtl\objpas\sysutils\sysstr.inc:97

#11 TIPHTML__NEXTTOKEN() at iphtml.pas:5132
#12 TIPHTML__PARSEHEAD(0x154e04c0, ) at 
iphtml.pas:5451

#13 TIPHTML__PARSEHTML() at iphtml.pas:7474
#14 TIPHTML__PARSE() at iphtml.pas:7538
#15 TIPHTML__LOADFROMSTREAM(0x131e14c0, ) at 
iphtml.pas:4725
#16 TLAZIPHTMLCONTROL__SETHTMLCONTENT(0x131e14c0, 0x0, variable>) at ipidehtmlcontrol.pas:368
#17 TMAINIDE__OICHANGEDTIMERTIMER(0x1324fc48, ) 
at main.pp:11811

#18 TCUSTOMTIMER__DOONTIMER() at customtimer.pas:175
#19 TCUSTOMTIMER__TIMER() at customtimer.pas:150
#20 TIMERCALLBACKPROC(0, 275, 20158, 489829657) at 
.\win32\win32callback.inc:2773

#21 USER32!GetDC at :0
#22 ?? at :0

The strange things is the transition between #10 and #11, line 5132 of 
iphtml.pas *doesn't* call uppercase, it is


   ParmName := ParmString

and ParmString is

  function ParmString: string;
  begin
if PBW = 0 then
  Result := ''
else begin
  ParmBuf[PBW] := #0;
  Result := StrPas(ParmBuf);
  PBW := 0;
end;
  end;

Maybe there's a stray pointer somewhere that messes up the stack?
If I uninstall turbopower_ipro I get the plain text information box in 
the object inspector and no crashes.


If I run lazarus directly under gdb, I get a different backtrace (but 
still crashes in TIpHtml.ParseHead):


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3692.0x340]
fpc_ansistr_decr_ref (S=0xfda682) at D:/fpc-2.6.4/rtl/i386/i386.inc:1542
1542decl(%edx)
(gdb) bt
#0  fpc_ansistr_decr_ref (S=0xfda682) at D:/fpc-2.6.4/rtl/i386/i386.inc:1542
#1  0x10f6f810 in ?? ()
#2  0x00fdb714 in TIPHTML__PARSEHEAD (PARENT=0x13821af0,
this=) at iphtml.pas:5451
#3  0x00fe2865 in TIPHTML__PARSEHTML (this=)
at iphtml.pas:7474
#4  0x00fe2b96 in TIPHTML__PARSE (this=)
at iphtml.pas:7538
#5  0x00fd99fa in TIPHTML__LOADFROMSTREAM (S=0x1388c0c8,
this=) at iphtml.pas:4725
#6  0x01032007 in TLAZIPHTMLCONTROL__SETHTMLCONTENT (STREAM=0x1388c0c8,
NEWURL=0x0, this=) at ipidehtmlcontrol.pas:368
#7  0x00793a62 in DOHTML (parentfp=0x10f6fa84) at idehelpintf.pas:345
#8  0x00793913 in THINTWINDOWMANAGER__SHOWHINT (SCREENPOS=...,
THEHINT=0x14ad8838 'href="lazdoc://lazarus/lazdoc.css" type="text/css">'#13#10'http-equiv="Content-Type" content="text/html; 
charset=utf-8">'#13#10''#13#10' 
'..., this=) at idehelpintf.pas:367

#9  0x00849258 in TSOURCEEDITORHINTWINDOWMANAGER__ACTIVATEHINT (
SCREENRECT=..., ABASEURL=0x138b56c 'lazdoc://',
AHINT=0x14ad8838 'href="lazdoc://lazarus/lazdoc.css" type="text/css">'#13#10'http-equiv="Content-Type" content="text/html; 
charset=utf-8">'#13#10''#13#10' 
'..., AAUTOSHOWN=true, this=)

at sourceeditor.pp:1907
#10 0x0086589b in TSOURCEEDITORMANAGER__ACTIVATEHINT (SCREENRECT=...,
BASEURL=0x138b56c 'lazdoc://',
THEHINT=0x14ad8838 'href="lazdoc://lazaru
s/lazdoc.css" type="text/css">'#13#10'content="t
ext/html; charset=utf-8">'#13#10''#13#10'class="header">  
r>'..., AUTOSHOWN=true, this=)
at sourceeditor.pp:10685
#11 0x0084dbf0 in TSOURCEEDITOR__ACTIVATEHINT (CLIENTRECT=...,
ABASEURL=0x138b56c 'lazdoc://',
AHINT=0x14ad8838 'href="lazdoc://lazarus/
lazdoc.css" type="text/css">'#13#10'content="tex
t/html; charset=utf-8">'#13#10''#13#10' 
 

'..., AAUTOSHOWN=true, this=)
at sourceeditor.pp:3304
#12 0x00470cd8 in TMAINIDE__ONSRCNOTEBOOKSHOWHINTFORSOURCE (
SRCEDIT=0x128142c0, CARETPOS=..., AUTOSHOWN=true,
this=) at main.pp:10818
#13 0x0086074a in TSOURCENOTEBOOK__SHOWSYNEDITHINT (MOUSEPOS=...,
this=) at sourceeditor.pp:8860
#14 0x00849745 in TSOURCEEDITORHINTWINDOWMANAGER__HINTTIMER (
SENDER=0x1337d598, t

Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Luca Olivetti via Lazarus

El 29/09/16 a les 19:35, Luca Olivetti via Lazarus ha escrit:

Hello,

I'm playing with lazarus 1.6 (a bit late, I know) with fpc 2.6.4, win32,
 and I have a strange problem with the ide:
the object inspector information box shows nothing and, eventually, when
I click on fields in the object inspector, lazarus becomes unresponsive
and then crashes.
If try to begug the ide under lazarus (tried both with the old 1.4.4 and
the new 1.6), I see that it crashes in the heap manager (heap.inc) when
it tries to allocate 1117978624 bytes (!)
This is the call stack:


[snip]

FWIW, "transplanting" the version of turbopower_ipro from lazarus 1.4.4 
to 1.6 (and defining html_print in its lpk otherwise it doesn't compile) 
"solves" this problem.


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Luca Olivetti via Lazarus

El 30/09/16 a les 11:15, Luca Olivetti via Lazarus ha escrit:

El 29/09/16 a les 19:35, Luca Olivetti via Lazarus ha escrit:

Hello,

I'm playing with lazarus 1.6 (a bit late, I know) with fpc 2.6.4, win32,
 and I have a strange problem with the ide:
the object inspector information box shows nothing and, eventually, when
I click on fields in the object inspector, lazarus becomes unresponsive
and then crashes.
If try to begug the ide under lazarus (tried both with the old 1.4.4 and
the new 1.6), I see that it crashes in the heap manager (heap.inc) when
it tries to allocate 1117978624 bytes (!)
This is the call stack:


[snip]

FWIW, "transplanting" the version of turbopower_ipro from lazarus 1.4.4
to 1.6 (and defining html_print in its lpk otherwise it doesn't compile)
"solves" this problem.


I now found that the problem is with the directive

{$MODESWITCH NESTEDPROCVARS}.

If I compile the old turbopower_ipro with this directive (even if it 
doesn't need it) it doesn't work (the information box doesn't show 
anything, though I didn't manage to crash lazarus yet), while if I 
rewrite the new iphtml.pas in order to remove the directive it works OK.


A bug in fpc 2.6.4?

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Mattias Gaertner via Lazarus
On Fri, 30 Sep 2016 12:27:46 +0200
Luca Olivetti via Lazarus  wrote:

>[...]
> > FWIW, "transplanting" the version of turbopower_ipro from lazarus 1.4.4
> > to 1.6 (and defining html_print in its lpk otherwise it doesn't compile)
> > "solves" this problem.  
> 
> I now found that the problem is with the directive
> 
> {$MODESWITCH NESTEDPROCVARS}.
> 
> If I compile the old turbopower_ipro with this directive (even if it 
> doesn't need it) it doesn't work (the information box doesn't show 
> anything, though I didn't manage to crash lazarus yet), while if I 
> rewrite the new iphtml.pas in order to remove the directive it works OK.

Does that mean you will provide a patch to fix this?

> A bug in fpc 2.6.4?

Maybe. Although it exists since 2.6.0.

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Ondrej Pokorny via Lazarus

On 30.09.2016 12:27, Luca Olivetti via Lazarus wrote:
If I compile the old turbopower_ipro with this directive (even if it 
doesn't need it) it doesn't work (the information box doesn't show 
anything, though I didn't manage to crash lazarus yet), while if I 
rewrite the new iphtml.pas in order to remove the directive it works OK.


Strange, there is no {$MODESWITCH NESTEDPROCVARS} directive in my 
Lazarus trunk\components\turbopower_ipro\iphtml.pas or any other file 
(except of one file in examples).


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Luca Olivetti via Lazarus

El 30/09/16 a les 12:51, Ondrej Pokorny via Lazarus ha escrit:

On 30.09.2016 12:27, Luca Olivetti via Lazarus wrote:

If I compile the old turbopower_ipro with this directive (even if it
doesn't need it) it doesn't work (the information box doesn't show
anything, though I didn't manage to crash lazarus yet), while if I
rewrite the new iphtml.pas in order to remove the directive it works OK.


Strange, there is no {$MODESWITCH NESTEDPROCVARS} directive in my
Lazarus trunk\components\turbopower_ipro\iphtml.pas or any other file
(except of one file in examples).


ipdefine.inc.

An it's not the only file using it:

lcl/grids.pas
components/lazdebuggergdbmi/gdbmidebugger.pp
components/debuggerintf/dbgintfdebuggerbase.pp
components/lazutils/lcsvutils.pas

Which could explain some other random crashes I saw

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Ondrej Pokorny via Lazarus

On 30.09.2016 12:57, Luca Olivetti via Lazarus wrote:

El 30/09/16 a les 12:51, Ondrej Pokorny via Lazarus ha escrit:

On 30.09.2016 12:27, Luca Olivetti via Lazarus wrote:

If I compile the old turbopower_ipro with this directive (even if it
doesn't need it) it doesn't work (the information box doesn't show
anything, though I didn't manage to crash lazarus yet), while if I
rewrite the new iphtml.pas in order to remove the directive it works 
OK.


Strange, there is no {$MODESWITCH NESTEDPROCVARS} directive in my
Lazarus trunk\components\turbopower_ipro\iphtml.pas or any other file
(except of one file in examples).


ipdefine.inc.


Already fixed in trunk. See http://mantis.freepascal.org/view.php?id=29982

I'll add it to merge list for 1.6

Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Luca Olivetti via Lazarus

El 30/09/16 a les 12:46, Mattias Gaertner via Lazarus ha escrit:

On Fri, 30 Sep 2016 12:27:46 +0200
Luca Olivetti via Lazarus  wrote:


[...]

FWIW, "transplanting" the version of turbopower_ipro from lazarus 1.4.4
to 1.6 (and defining html_print in its lpk otherwise it doesn't compile)
"solves" this problem.


I now found that the problem is with the directive

{$MODESWITCH NESTEDPROCVARS}.

If I compile the old turbopower_ipro with this directive (even if it
doesn't need it) it doesn't work (the information box doesn't show
anything, though I didn't manage to crash lazarus yet), while if I
rewrite the new iphtml.pas in order to remove the directive it works OK.


Does that mean you will provide a patch to fix this?


Yes, attached (beware, made under windows with TortoiseSVN), but it's 
less "elegant" that the solution with nestedprocvars (if it is supposed 
to work).

And, as I said to Ondrej, there are more units using that switch.




A bug in fpc 2.6.4?


Maybe. Although it exists since 2.6.0.


I could file a bug then but I'm afraid I cannot produce a simple test case.

Bye


--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
Index: ipdefine.inc
===
--- ipdefine.inc	(revision 53057)
+++ ipdefine.inc	(working copy)
@@ -47,7 +47,7 @@
 {$DEFINE VERSION5}
 {$DEFINE Version6OrHigher}
 {$DEFINE Version7OrHigher}
-{$MODESWITCH NESTEDPROCVARS}
+//{$ MODESWITCH NESTEDPROCVARS}
 
 {$ELSE}
 
Index: iphtml.pas
===
--- iphtml.pas	(revision 53057)
+++ iphtml.pas	(working copy)
@@ -2710,7 +2710,7 @@
 property FlagErrors;
   end;
 
-  TIdFindNodeCriteria = function(ACurrNode: TIpHtmlNodeCore): Boolean is nested;
+  TIdFindNodeCriteria = function(ACurrNode: TIpHtmlNodeCore; const AId:string): Boolean;
 
 const
   NAnchorChar = #3 ; {character used to represent an Anchor }
@@ -2739,7 +2739,7 @@
 function GetNextSiblingNode(ANode: TIpHtmlNode): TIpHtmlNode;
 function GetPrevSiblingNode(ANode: TIpHtmlNode): TIpHtmlNode;
 function GetParentNodeOfClass(ANode: TIpHtmlNode; AClass: TIpHtmlNodeClass): TIpHtmlNode;
-function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria): TIpHtmlNodeCore;
+function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria; const AId:string): TIpHtmlNodeCore;
 function FindNodeByElemId(ANode: TIpHtmlNode; const AElemId: string): TIpHtmlNodeCore;
 function FindNodeByElemClass(ANode: TIpHtmlNode; const AElemClass: string): TIpHtmlNodeCore;
 
@@ -2935,7 +2935,7 @@
 Result := Result.FParentNode;
 end;
 
-function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria): TIpHtmlNodeCore;
+function FindNode(ANode: TIpHtmlNode; ACriteria: TIdFindNodeCriteria; const AId:string): TIpHtmlNodeCore;
 var
   I: Integer;
   VNode: TIpHtmlNodeMulti;
@@ -2949,43 +2949,41 @@
   for I := 0 to Pred(VNode.ChildCount) do
   begin
 VPrevNode := VNode.ChildNode[I];
-VNextNode := FindNode(VPrevNode, ACriteria);
+VNextNode := FindNode(VPrevNode, ACriteria, AId);
 if not Assigned(VNextNode) then
   VNextNode := VPrevNode;
 if VNextNode is TIpHtmlNodeCore then
 begin
   Result := VNextNode as TIpHtmlNodeCore;
-  if ACriteria(Result) then
+  if ACriteria(Result,AId) then
 Exit;
 end;
   end;
   Result := nil;
 end;
 
+function CriteriaByElemId(ACurrNode: TIpHtmlNodeCore; const AElemId:string): Boolean;
+begin
+  if ACurrNode.Id = AElemId then
+Exit(True);
+  Result := False;
+end;
+
 function FindNodeByElemId(ANode: TIpHtmlNode; const AElemId: string): TIpHtmlNodeCore;
+begin
+  Result := FindNode(ANode, CriteriaByElemId, AElemId);
+end;
 
-  function Criteria(ACurrNode: TIpHtmlNodeCore): Boolean;
-  begin
-if ACurrNode.Id = AElemId then
-  Exit(True);
-Result := False;
-  end;
-
+function CriteriaByElementClass(ACurrNode: TIpHtmlNodeCore; const AElemClass:string): Boolean;
 begin
-  Result := FindNode(ANode, Criteria);
+  if ACurrNode.ClassId = AElemClass then
+Exit(True);
+  Result := False;
 end;
 
 function FindNodeByElemClass(ANode: TIpHtmlNode; const AElemClass: string): TIpHtmlNodeCore;
-
-  function Criteria(ACurrNode: TIpHtmlNodeCore): Boolean;
-  begin
-if ACurrNode.ClassId = AElemClass then
-  Exit(True);
-Result := False;
-  end;
-
 begin
-  Result := FindNode(ANode, Criteria);
+  Result := FindNode(ANode, CriteriaByElementClass, AElemClass);
 end;
 
 procedure Register;
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] lazarus 1.6+fpc 2.6.4, win32, crashes in iphtml.pas

2016-09-30 Thread Luca Olivetti via Lazarus

El 30/09/16 a les 13:01, Ondrej Pokorny via Lazarus ha escrit:

On 30.09.2016 12:57, Luca Olivetti via Lazarus wrote:

El 30/09/16 a les 12:51, Ondrej Pokorny via Lazarus ha escrit:

On 30.09.2016 12:27, Luca Olivetti via Lazarus wrote:

If I compile the old turbopower_ipro with this directive (even if it
doesn't need it) it doesn't work (the information box doesn't show
anything, though I didn't manage to crash lazarus yet), while if I
rewrite the new iphtml.pas in order to remove the directive it works
OK.


Strange, there is no {$MODESWITCH NESTEDPROCVARS} directive in my
Lazarus trunk\components\turbopower_ipro\iphtml.pas or any other file
(except of one file in examples).


ipdefine.inc.


Already fixed in trunk. See http://mantis.freepascal.org/view.php?id=29982

I'll add it to merge list for 1.6


Duh, basically is the same fix I just sent. I deserve it for not 
checking trunk.
However, if the problem is with {$MODESWITCH NESTEDPROCVARS} and fpc 
2.6.4, there are still a handful of units that use it in trunk:


lcl/grids.pas
components/lazdebuggergdbmi/gdbmidebugger.pp
components/debuggerintf/dbgintfdebuggerbase.pp
components/fpdebug/app/fpdserver/debugthreadcommand.pas
components/turbopower_ipro/examples/sumabfrm.pas
components/lazutils/lcsvutils.pas

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus