Found an issue in SpiderBasic ? Please report it here !
User avatar
Niffo
 
Posts: 52
Joined: Sat Jun 16, 2018 10:30 pm

2.21 : 64 bits version of SB generates bad Javascript code

by Niffo Mon Feb 25, 2019 6:18 pm

64 bits version of SB generates trashed Javascript code (seen on MacOS and Linux, while Windows 32bits SB generates good code :
I am not able to reproduce in a simple sample, so i am posting the SB source code of a Procedure then the conversion in Javascript by SB. The problem is in the "For Row = 0 To \FixedRows - 1" loop.

SB Source code :
Code: Select all
Procedure GridGadget_UpdatevScrollBar(*GridGadget.GridGadget)
   Define.w Y, Count, Row

   With *GridGadget

   If Not \vScrollGadget : ProcedureReturn : EndIf
   
   Y = 0
   ForEach \Rows()
      Y + \Rows()\Height
      If Y > GadgetHeight(\CanvasGadget) : Break : EndIf
   Next

   ; No ScrollBar needed
   If Y < GadgetHeight(\CanvasGadget)
      ScrollerGadget_SetMaxValue(\vScrollGadget, ScrollerGadget_GetPageLength(\vScrollGadget) - 1)
      ProcedureReturn
   EndIf
   
   Y = 0
   ; Fixed rows
   SelectElement(\Rows(), 0)
   For Row = 0 To \FixedRows - 1
      Y + \Rows()\Height
      Count + 1
      NextElement(\Rows())
   Next Row
   ; Other rows
   If LastElement(\Rows())
      Repeat 
         Y + \Rows()\Height
         Count + 1
         If Y > GadgetHeight(\CanvasGadget) : Break : EndIf
      Until Not PreviousElement(\Rows())
   EndIf
   ScrollerGadget_SetMaxValue(\vScrollGadget, ListSize(\Rows()) - Count + ScrollerGadget_GetPageLength(\vScrollGadget))

   EndWith
EndProcedure


SB 32 bits (Windows) Javascript generated code (OK)
Code: Select all
function f_gridgadget_updatevscrollbar(p_gridgadget) {
var v_y=0;
var v_row=0;
var v_count=0;
if (!(p_gridgadget._vScrollGadget)) {
if (1) return 0;
}
v_y=0;
spider_ResetList(p_gridgadget._Rows); while (spider_NextElement(p_gridgadget._Rows)) {
v_y=(v_y+p_gridgadget._Rows.current._Height);
if (v_y>spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
break;
}
}
if (v_y<spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
f_scrollergadget_setmaxvalue(p_gridgadget._vScrollGadget,(f_scrollergadget_getpagelength(p_gridgadget._vScrollGadget)+-1),0);
if (1) return 0;
}
v_y=0;
spider_SelectElement(p_gridgadget._Rows,0);
v_row=0;
for (;(p_gridgadget._FixedRows+-1)>=v_row;v_row+=1) {
v_y=(v_y+p_gridgadget._Rows.current._Height);
v_count=(v_count+1);
spider_NextElement(p_gridgadget._Rows);
}
if (spider_LastElement(p_gridgadget._Rows)) {
do {
v_y=(v_y+p_gridgadget._Rows.current._Height);
v_count=(v_count+1);
if (v_y>spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
break;
}
} while (!(!(spider_PreviousElement(p_gridgadget._Rows))));
}
f_scrollergadget_setmaxvalue(p_gridgadget._vScrollGadget,((spider_ListSize(p_gridgadget._Rows)-v_count)+f_scrollergadget_getpagelength(p_gridgadget._vScrollGadget)),0);
return 0;
}


SB 64 bits (MacOS, Linux) Javascript generated code (NOT OK)
In the FOR loop, "r15w" does not exist.
Code: Select all
function f_gridgadget_updatevscrollbar(p_gridgadget) {
var v_y=0;
var v_row=0;
var v_count=0;
if (!(p_gridgadget._vScrollGadget)) {
if (1) return 0;
}
v_y=0;
spider_ResetList(p_gridgadget._Rows); while (spider_NextElement(p_gridgadget._Rows)) {
v_y=(v_y+p_gridgadget._Rows.current._Height);
if (v_y>spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
break;
}
}
if (v_y<spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
f_scrollergadget_setmaxvalue(p_gridgadget._vScrollGadget,(f_scrollergadget_getpagelength(p_gridgadget._vScrollGadget)+-1),0);
if (1) return 0;
}
v_y=0;
spider_SelectElement(p_gridgadget._Rows,0);
v_row=0;
for (;r15w>=v_row;v_row+=1) {
v_y=(v_y+p_gridgadget._Rows.current._Height);
v_count=(v_count+1);
spider_NextElement(p_gridgadget._Rows);
}
if (spider_LastElement(p_gridgadget._Rows)) {
do {
v_y=(v_y+p_gridgadget._Rows.current._Height);
v_count=(v_count+1);
if (v_y>spider_GadgetHeight(p_gridgadget._CanvasGadget)) {
break;
}
} while (!(!(spider_PreviousElement(p_gridgadget._Rows))));
}
f_scrollergadget_setmaxvalue(p_gridgadget._vScrollGadget,((spider_ListSize(p_gridgadget._Rows)-v_count)+f_scrollergadget_getpagelength(p_gridgadget._vScrollGadget)),0);
return 0;
}
Fred
Site Admin
 
Posts: 1162
Joined: Mon Feb 24, 2014 10:51 am

Re: 2.21 : 64 bits version of SB generates bad Javascript co

by Fred Fri Aug 30, 2019 1:55 pm

It's probably a buffer overflow, but without a compilable code I won't be able to track it down... Any chance to get the faulty code ?
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 3 guests