1. Tomas Beran
  2. PowerBuilder
  3. Wednesday, 13 April 2022 08:46 AM UTC

Hello

In PB2021 I'm getting this strange error when I open or close an object inherited from nonvisual:

---------------------------
PowerBuilder application execution error (R0021)
---------------------------
Application terminated.

Error: Bad runtime function reference at line 3 in create event of object pfc_n_base.
---------------------------
OK   
---------------------------

It starts happening randomly and the solution is a full rebuild of the target. It helps for next few hours and then it starts again. Sometimes it helps just open and close pfc_n_base. Pfc_n_base is just an empty object. I see nothing suspicious here. Therefore I thing pfc_n_base is just a victim. My guess is there's another broken object in my project which makes this message. Did you meet this strange behavior? Do you have an idea how to investigate it?

What I tried:

Rebuild

Optimise every library

Migrate all libraries

rebuild it again

 

Here's pfc_n_base code:

forward
global type pfc_n_base from nonvisualobject
end type
end forward

global type pfc_n_base from nonvisualobject
end type
global pfc_n_base pfc_n_base

type variables
Public:
constant integer 		SUCCESS = 1
constant integer 		FAILURE = -1
constant integer 		NO_ACTION = 0
constant integer 		CONTINUE_ACTION = 1
constant integer 		PREVENT_ACTION = 0

end variables

forward prototypes
protected function integer of_messagebox (string as_id, string as_title, string as_text, icon ae_icon, button ae_button, integer ai_default)
end prototypes

protected function integer of_messagebox (string as_id, string as_title, string as_text, icon ae_icon, button ae_button, integer ai_default);Return MessageBox(as_title, as_text, ae_icon, ae_button, ai_default)
end function

on pfc_n_base.create
call super::create
TriggerEvent( this, "constructor" )
end on

on pfc_n_base.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

Tomas Beran Accepted Answer Pending Moderation
  1. Monday, 5 December 2022 19:16 PM UTC
  2. PowerBuilder
  3. # 1

I'm closing this thread. It seems that the issue has been solved in PB 2022 because I haven't seen it there yet.

Comment
There are no comments made yet.
Tomas Beran Accepted Answer Pending Moderation
  1. Friday, 24 June 2022 14:23 PM UTC
  2. PowerBuilder
  3. # 2

Hi

It looks like the problem are autoinstantiate NVOs declared as global variables.

I've moved all these global variables to n_cst_appmanager instance variables and the problem disappeared.

So the workaround is not to use autoinstantiate classes as global variables.

Comment
  1. Chris Pollach @Appeon
  2. Monday, 27 June 2022 10:27 AM UTC
Hi Thomas ... Yes, great points & observations! That is another reason why I never recommend Auto Instantianted objects. :-(
  1. Helpful
  1. John Fauss
  2. Monday, 27 June 2022 13:20 PM UTC
Tomas - I get your point. Maybe this will help: PB manages an AI'd NVO the same as it does a structure (stated in the first sentence of the doc topic that Mark referenced in his earlier comment), so the rules for an AI'd object differ from those for non-AI'd objects. Here's another reference (look for the sub-heading "Using User Objects as Structures"): https://docs.appeon.com/pb2021/application_techniques/CHAPTER_2_Selected.html

If the docs you quoted said instead "When you pass a non-autoinstantiated object by value,..." and differentiated the behavior for AI'd objects, would that be sufficient?
  1. Helpful
  1. Tomas Beran
  2. Monday, 27 June 2022 14:57 PM UTC
Hi John

"If the docs you quoted said instead "When you pass a non-autoinstantiated object by value,..." and differentiated the behavior for AI'd objects, would that be sufficient? "

- It would be better than nothing.

- I think the best would be a table with

columns:

value

reference

readonly

rows:

simple datatype (integer, string etc.)

structure

object (non-AI)

object (AI)

Values:

value (copied)

pointer copied

pointer referenced

  1. Helpful
There are no comments made yet.
Tomas Beran Accepted Answer Pending Moderation
  1. Tuesday, 19 April 2022 09:21 AM UTC
  2. PowerBuilder
  3. # 3

Hi

Unfortunately I can't migrate to newer PFC. I'm planning it but it requires manual check of every object. The PFC I'm using is heavily modified 10.5. But I think this is not the issue. My guess is there's a problem in some library which doesn't affect the compiler but can confuse the IDE. This is why I'm looking for IDE debugging or logging option. Like PB app has /PBDEBUG parameter.

I remember there was a bug in earlier version of PB which under some circumstances doubled methods in objects. It was visible only in source and it was no issue until you changed the affected code.

Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 April 2022 00:38 AM UTC
As far as I can remember, the code duplication happened within global functions and also window functions.

Another bug I remember is having "create" and "destroy" objects appear within pb objects/windows in the list of events. These, unlike "constructor" and "destructor", should never appear in the list."

My first step though, as Andreas already suggested, is to make sure you don't have any duplicate objects in different libraries. Also make sure that a library doesn't appear in more than one place in the library list.

Regards.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 20 April 2022 00:50 AM UTC
This might sound crazy:

Do a "Chkdsk /f"

Do an "sfc /scannow"

Probably not the problem, but it won't hurt anything.

regards.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 20 April 2022 00:55 AM UTC
One last thing: I've googled on this and more than one suggestion seems to be that it could be related to having some incorrect external function declaration.

Knowing that you're using 'old' pfc classes, that definitely sounds as a possible cause. Therefore, it would be useful - just as a test - to make a copy of your application and compile against the latest version of PFC. If the problem doesn't appear then, then at least you know it has something to do with the 'old' pfc classes.

  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 15 April 2022 17:56 PM UTC
  2. PowerBuilder
  3. # 4

Have you migrated the PFC all the way up from version 5 or are you using the latest PFC 2021 version?  If you don't have any extensions, I'd suggest backing everything up and then swapping out the migrated pfc with the latest pfc 2021:

GitHub - OpenSourcePFCLibraries/2021: The open source PowerBuilder Foundation Class libraries for Appeon PowerBuilder 2021

Comment
There are no comments made yet.
Tomas Beran Accepted Answer Pending Moderation
  1. Wednesday, 13 April 2022 09:23 AM UTC
  2. PowerBuilder
  3. # 5

Of course yes, we edited it many times. The project started at PB5 and contains dozens of libraries like Powertool, Padlock etc. But the project can be compiled and the compiled code works. The only issue is this pointless messagebox in PB2021 IDE (commandline compilec compiles without this error).

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 13 April 2022 09:15 AM UTC
  2. PowerBuilder
  3. # 6

Have you checked for duplicate objects? Also, did you source edit any object? Did you modified anything related on objects inheritance?

Andreas.

Comment
There are no comments made yet.
Tomas Beran Accepted Answer Pending Moderation
  1. Wednesday, 13 April 2022 09:10 AM UTC
  2. PowerBuilder
  3. # 7

This is what I've done. Rebuils - Optimise - Migrate - Rebuilt. It helps for a while. Then something happen and the message is back.

Plus I forgot I get this message when I compile the project from PB2021 IDE. It appears in the middle of build process at the end of stage 2. Not in Error console but as a messagebox.

Another aspect is I can't use Autoscript functionality. I think these two issues are somehow connected together. Is there a PB IDE debugging or logging option which could help me?

 

Thank you

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 13 April 2022 09:01 AM UTC
  2. PowerBuilder
  3. # 8

Message may be shown by pfc_n_base but you have to check the full chain. I would take a backup, optimize my pbls and do a full rebuild.

Andreas.

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.