Problem loading scripts in updateHook/events/command/methods (error parsing DataPorts)

Here is the problem. It seems possible to load programs in updateHook, events, commands, or methods (even if it is not real-time). There is a problem if the program uses DataPort. For example : This program (where attrDouble is a attribute) can be loaded :

program test2
{
        set attrDouble = 3.1415
}
This one (where outDouble and inDouble are DataPorts) can be loaded only while configuring the component with the Deployer, or with the TaskBrowser :
program test1
{
        do outDouble.Set( inDouble.Get() + 1)
}
If I try to load this program from updateHook, an event, a command or a method, I have a Segmentation fault. I attach the stack from gdb

Nicolas

AttachmentSize
stack-gdb.txt4.31 KB

Problem loading scripts in updateHook/events/command/methods (er

On Friday 30 January 2009 10:52:56 nicolas [dot] mabire [..] ... wrote:
> Here is the problem.
> It seems possible to load programs in updateHook, events, commands, or
> methods (even if it is not real-time). There is a problem if the program
> uses DataPort.
> For example :
> This program (where attrDouble is a attribute) can be loaded :
>
> program test2
> {
> set attrDouble = 3.1415
> }
>
> This one (where outDouble and inDouble are DataPorts) can be loaded only
> while configuring the component with the Deployer, or with the TaskBrowser
> :
>
> program test1
> {
> do outDouble.Set( inDouble.Get() + 1)
> }
>
> If I try to load this program from updateHook, an event, a command or a
> method, I have a Segmentation fault. I attach the stack from gdb

I can't reproduce this problem in a hello world example and a command which
has:
this->scripting()->loadPrograms("/tmp/test.ops");

Does your command/event do more complex things than that ? It looks like the
segfault is related to a coding error...

Peter

I used a bad way ?

My code was :

ScriptingAccess* sa;
res = sa->loadPrograms("example.ops");
With this code, I have now no problems.
this->scripting()->loadPrograms("example.ops");
Your solution is nicer than mine ... and works... Thanks ! Nicolas.

I used a bad way ?

On Friday 30 January 2009 14:37:04 nicolas [dot] mabire [..] ... wrote:
> My code was :
>

> ScriptingAccess* sa;
> res = sa->loadPrograms("example.ops");
> 

'sa' is not initialised and points to no object ('a dangling pointer'). It is
bound to crash !

Peter

Problem loading scripts in updateHook/events/command/methods (er

On Friday 30 January 2009 10:52:56 nicolas [dot] mabire [..] ... wrote:
> Here is the problem.
> It seems possible to load programs in updateHook, events, commands, or
> methods (even if it is not real-time). There is a problem if the program
> uses DataPort.
> For example :
> This program (where attrDouble is a attribute) can be loaded :
>
> program test2
> {
> set attrDouble = 3.1415
> }
>
> This one (where outDouble and inDouble are DataPorts) can be loaded only
> while configuring the component with the Deployer, or with the TaskBrowser
> :
>
> program test1
> {
> do outDouble.Set( inDouble.Get() + 1)
> }
>
> If I try to load this program from updateHook, an event, a command or a
> method, I have a Segmentation fault. I attach the stack from gdb

Thanks for reporting, I'm looking into it. Are you sure it also happens when
using a method ??

Peter

Thank you for reacting so

Thank you for reacting so quickly !
Yes I have the same problem with a method.
I have tested only from the TaskBrowser.
I attach the stack form gdb.

The problem is the same if I try to access to another component port.