1. backya ayyappan
  2. PowerBuilder
  3. Sunday, 7 June 2020 11:19 AM UTC

hi 

i am using powerbuilder 8 version. suddenly my application gets closed in a particular screen in which whenever i click ok button.In ok button it calls the function updaterightstree(root); in that line app gets closed.Its an existing screen only.but dont know why the issue occurred suddenly

root=tv_userrights.finditem(RootTreeitem!,0);
updaterightstree(root);

updaterightstree(root) has below lines:

int h_child;
char flag;
String ls_windowname

h_child=tv_userrights.finditem( childtreeitem!,h_root)

if h_child=-1 then
return
else
do while h_child <> -1
treeviewitem tvi;
tv_userrights.getitem( h_child,tvi);
if tvi.statepictureindex=1 then
flag='N';
else
flag='Y';
end if

insert into ENT_RIGHTS(USERS,WINDOWNAME,RIGHTS)
select :sle_userid.text,windowname,:flag from ent_menuitems where description=:tvi.label;
if sqlca.sqlcode = -1 then
messagebox('Alert !..',sqlca.sqlerrtext)
end if
updateRightsTree(h_child);
h_child=tv_userrights.finditem(nexttreeitem!,h_child)
loop
end if

can anyone please help regarding this???

Regards

Backya

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Sunday, 14 June 2020 17:57 PM UTC
  2. PowerBuilder
  3. # 1

Hi Backya;

   Wow, I am amazed that the function did not GPF your App back in PB version 8.x time frame. I don't see anywhere where the code uses an IsValid() command to make sure that pointer variables (ie: root, h_child, tvi, etc) are valid. If any of those are invalid or Null, your app could certainly be headed for the GPF heap.

Food for thought.

HTH

Regards ... Chris

Comment
  1. backya ayyappan
  2. Monday, 15 June 2020 05:42 AM UTC
Hi Chris,

i dont get you.. What is GPF? Where i need to use isvalid() command? can you pls explain





Regards

Backya
  1. Helpful
  1. Andrew Barnes
  2. Monday, 15 June 2020 17:05 PM UTC
GPF - General Protection Fault which is shorthand for a program crash, often causes by a memory by a memory overwrite where it is not supposed to.



You should probably use IsValid(tvi) or check the return code after tv_userrights.getitem( h_child,tvi); I would expect that the GetItem would work when given a valid handle, and you are properly checking h_child, but it is a good programming practice to check these sorts of things and be able to eliminate them from consideration as causing unexpected crashes.



You should probably be checking the return value after root=tv_userrights.finditem(RootTreeitem!,0); to verify that the FindItem actually found something. Again, I would expect that h_child=tv_userrights.finditem( childtreeitem!,h_root) would return a -1 if the h_root sent to it was -1, but verifying ahead of time is good practice and would eliminate that as a possible source of the program crash.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 8 June 2020 16:45 PM UTC
  2. PowerBuilder
  3. # 2

First I will state the obvious, PB8 is no longer supported, so you should consider upgrading.  For your current environment, have you had a windows update recently?  That's a common culprit in an existing application having a new failure.  Is it happening in the IDE also, or just the EXE?

 

In addition to what Rene said about using the PBDEBUG option, try wrapping the updaterightstree code in a try/catch, and catch runtimeerror like this - Catch(RuntimeError re).  In the catch, you can do a messagebox and display the re.getmessage().  If it fails in the IDE, you should run the debugger and step through the code to see exactly what line is failing.

 

Kevin

Comment
  1. backya ayyappan
  2. Sunday, 14 June 2020 09:51 AM UTC
I have tried what you said..the catch block didnt workout.. the application gets closed while calling the function updaterightstree(root) for a particular user.For another user in debug mode it goes inside the function and it gets closed in the recursive function updaterightstree(hchild).. can you please help me??

the function calls here



long root;



delete from ENT_RIGHTS where users = :sle_userid.text;

try

root=tv_userrights.finditem(RootTreeitem!,0);

updaterightstree(root);->app gets closed here for user1

catch(runtimeerror re)

messagebox("",re.getmessage())

end try

return 1



the function updaterightstree(root) has following lines.





int h_child;

char flag;

String ls_windowname



h_child=tv_userrights.finditem( childtreeitem!,h_root)



if h_child=-1 then

return

else





do while h_child <> -1

try

treeviewitem tvi;

tv_userrights.getitem( h_child,tvi);

if tvi.statepictureindex=1 then

flag='N';

else

flag='Y';

end if



insert into ENT_RIGHTS(USERS,WINDOWNAME,RIGHTS)

select :sle_userid.text,windowname,:flag from ent_menuitems where description=:tvi.label;

if sqlca.sqlcode = -1 then

messagebox('Alert !..',sqlca.sqlerrtext)

end if

updateRightsTree(h_child);->app gets closed here for user2

h_child=tv_userrights.finditem(nexttreeitem!,h_child)



catch(runtimeerror re)



messagebox("",re.getmessage())

end try



loop

end if





Backya
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 8 June 2020 14:54 PM UTC
  2. PowerBuilder
  3. # 3

Rene is right, you need to run the app in DEBUG mode and step through the OK button processing to see exactly WHERE the abend occurs. That will give you more information, hopefully enough to determine WHY the code code is barfing now.

Good Luck,
Olan

Comment
There are no comments made yet.
backya ayyappan Accepted Answer Pending Moderation
  1. Monday, 8 June 2020 06:10 AM UTC
  2. PowerBuilder
  3. # 4

Hi Rene,

Thanks for your response. This is very old screen.Now the prob occurs recently.Any other guess?? 

 

 

Regards,

Backya

 

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 8 June 2020 05:43 AM UTC
  2. PowerBuilder
  3. # 5

Hi Backya,

I guess there is an infinite loop in your recursive function calls.

You may try to run application using PBDEBUG option to create a log file where you can see every call. Maybe it helps to find what causes the crash.

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.