Issue where return doesn't really return to octave prompt

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue where return doesn't really return to octave prompt

jswensen
I am having an issue that has me baffled.  An apparently small change to code
causes very unexpected results.  The following snippet of code shows both the
case in which the problem does not occur and when it does occur.  Also, the
error does not occur in Linux or OSX, only in Cygwin.

DEFUN_DLD(hget,args,,"hget(handle,string)\n\
 gets a property for the given handle")
{

// Works here if uncommented
//return octave_value();

//  Get the 'figure' object from the HandleManager
handle* handlePtr = handle::getHandle( args(0).int_value() );

// Works here if uncommented
//return octave_value();

// Make sure the handle retrieved is a 'handle' object
if( (handlePtr != NULL) &&
        (handlePtr->type_id() == handle::static_type_id()) )
{
        // Works here if uncommented
        //return octave_value();

        string propName = args(1).string_value();

        // Fails here - never returns to the octave prompt
        return octave_value();
}
else
{
        error("handle: The handle id specified does not exist");
}

}

Any suggestions?

John Swensen

----------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Issue where return doesn't really return to octave prompt

John W. Eaton-6
On 15-Aug-2005, [hidden email] wrote:

| I am having an issue that has me baffled.  An apparently small change to code
| causes very unexpected results.  The following snippet of code shows both the
| case in which the problem does not occur and when it does occur.  Also, the
| error does not occur in Linux or OSX, only in Cygwin.
|
| DEFUN_DLD(hget,args,,"hget(handle,string)\n\
|  gets a property for the given handle")
| {
|
| // Works here if uncommented
| //return octave_value();
|
| //  Get the 'figure' object from the HandleManager
| handle* handlePtr = handle::getHandle( args(0).int_value() );
|
| // Works here if uncommented
| //return octave_value();
|
| // Make sure the handle retrieved is a 'handle' object
| if( (handlePtr != NULL) &&
| (handlePtr->type_id() == handle::static_type_id()) )
| {
| // Works here if uncommented
| //return octave_value();
|
| string propName = args(1).string_value();
|
| // Fails here - never returns to the octave prompt
| return octave_value();
| }
| else
| {
| error("handle: The handle id specified does not exist");
| }
|
| }
|
| Any suggestions?

Are you sure the string_value function returns?

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

jswensen
I'm positive the string_value returns OK.  I added the following just
to verify.

Modified Code
------------------------------------
string propName = args(1).string_value();
cout << "Returned from string_value()" << endl;

// Fails here - never returns to the octave prompt
return octave_value(propName);

Octave Output
-----------------------------------
octave:1> hget(0,'DiaryFile')
Creating root object
After root init
Returned from string_value()


I suppose I could attach with the debugger and figure out where it is getting
stuck.  The problem is I don't think I built Octave with debugging symbols
included.

John


Quoting "John W. Eaton" <[hidden email]>:

> On 15-Aug-2005, [hidden email] wrote:
>
> | I am having an issue that has me baffled.  An apparently small
> change to code
> | causes very unexpected results.  The following snippet of code
> shows both the
> | case in which the problem does not occur and when it does occur.  Also, the
> | error does not occur in Linux or OSX, only in Cygwin.
> |
> | DEFUN_DLD(hget,args,,"hget(handle,string)\n\
> |  gets a property for the given handle")
> | {
> |
> | // Works here if uncommented
> | //return octave_value();
> |
> | //  Get the 'figure' object from the HandleManager
> | handle* handlePtr = handle::getHandle( args(0).int_value() );
> |
> | // Works here if uncommented
> | //return octave_value();
> |
> | // Make sure the handle retrieved is a 'handle' object
> | if( (handlePtr != NULL) &&
> | (handlePtr->type_id() == handle::static_type_id()) )
> | {
> | // Works here if uncommented
> | //return octave_value();
> |
> | string propName = args(1).string_value();
> |
> | // Fails here - never returns to the octave prompt
> | return octave_value();
> | }
> | else
> | {
> | error("handle: The handle id specified does not exist");
> | }
> |
> | }
> |
> | Any suggestions?
>
> Are you sure the string_value function returns?
>
> jwe
>



----------------------------------------------------------------



Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

jswensen
In reply to this post by John W. Eaton-6
I just tried a MUCH simpler test case and am seeing the same thing.

Code Used
-------------------------
// Octave Includes
#include<octave/oct.h>
#include<octave/parse.h>

#include <iostream>
using namespace std;

DEFUN_DLD(test_func,args,,"blah")
{
        string testString = args(1).string_value();

        return octave_value();
}

Compile command line
-----------------------------------
mkoctfile test_func.cc

Octave command line
---------------------------
test_func(0,'TestFunc')

Quoting "John W. Eaton" <[hidden email]>:

> On 15-Aug-2005, [hidden email] wrote:
>
> | I am having an issue that has me baffled.  An apparently small
> change to code
> | causes very unexpected results.  The following snippet of code
> shows both the
> | case in which the problem does not occur and when it does occur.  Also, the
> | error does not occur in Linux or OSX, only in Cygwin.
> |
> | DEFUN_DLD(hget,args,,"hget(handle,string)\n\
> |  gets a property for the given handle")
> | {
> |
> | // Works here if uncommented
> | //return octave_value();
> |
> | //  Get the 'figure' object from the HandleManager
> | handle* handlePtr = handle::getHandle( args(0).int_value() );
> |
> | // Works here if uncommented
> | //return octave_value();
> |
> | // Make sure the handle retrieved is a 'handle' object
> | if( (handlePtr != NULL) &&
> | (handlePtr->type_id() == handle::static_type_id()) )
> | {
> | // Works here if uncommented
> | //return octave_value();
> |
> | string propName = args(1).string_value();
> |
> | // Fails here - never returns to the octave prompt
> | return octave_value();
> | }
> | else
> | {
> | error("handle: The handle id specified does not exist");
> | }
> |
> | }
> |
> | Any suggestions?
>
> Are you sure the string_value function returns?
>
> jwe
>



----------------------------------------------------------------



Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

Andy Adler
On Mon, 15 Aug 2005 [hidden email] wrote:

> I just tried a MUCH simpler test case and am seeing the same thing.
>
> Code Used
> -------------------------
> // Octave Includes
> #include<octave/oct.h>
> #include<octave/parse.h>
>
> #include <iostream>
> using namespace std;
>
> DEFUN_DLD(test_func,args,,"blah")
> {
> string testString = args(1).string_value();
>
> return octave_value();
> }
>
> Compile command line
> -----------------------------------
> mkoctfile test_func.cc
>
> Octave command line
> ---------------------------
> test_func(0,'TestFunc')

Works fine for me with 2.9.3 under cygwin. What version are you
using?

--
Andy Adler

Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

Shai Ayal-2
In reply to this post by jswensen
This works for me on a self compiled octave 2.1.71 using gcc 3.3.3 on
cygwin WinXP.

I see no problem, the function returns to the octave prompt

Shai

On 8/15/05, [hidden email] <[hidden email]> wrote:

> I just tried a MUCH simpler test case and am seeing the same thing.
>
> Code Used
> -------------------------
> // Octave Includes
> #include<octave/oct.h>
> #include<octave/parse.h>
>
> #include <iostream>
> using namespace std;
>
> DEFUN_DLD(test_func,args,,"blah")
> {
>        string testString = args(1).string_value();
>
>        return octave_value();
> }
>
> Compile command line
> -----------------------------------
> mkoctfile test_func.cc
>
> Octave command line
> ---------------------------
> test_func(0,'TestFunc')
>
> Quoting "John W. Eaton" <[hidden email]>:
>
> > On 15-Aug-2005, [hidden email] wrote:
> >
> > | I am having an issue that has me baffled.  An apparently small
> > change to code
> > | causes very unexpected results.  The following snippet of code
> > shows both the
> > | case in which the problem does not occur and when it does occur.  Also, the
> > | error does not occur in Linux or OSX, only in Cygwin.
> > |
> > | DEFUN_DLD(hget,args,,"hget(handle,string)\n\
> > |  gets a property for the given handle")
> > | {
> > |
> > | // Works here if uncommented
> > | //return octave_value();
> > |
> > | //  Get the 'figure' object from the HandleManager
> > | handle* handlePtr = handle::getHandle( args(0).int_value() );
> > |
> > | // Works here if uncommented
> > | //return octave_value();
> > |
> > | // Make sure the handle retrieved is a 'handle' object
> > | if( (handlePtr != NULL) &&
> > |     (handlePtr->type_id() == handle::static_type_id()) )
> > | {
> > |     // Works here if uncommented
> > |     //return octave_value();
> > |
> > |     string propName = args(1).string_value();
> > |
> > |     // Fails here - never returns to the octave prompt
> > |     return octave_value();
> > | }
> > | else
> > | {
> > |     error("handle: The handle id specified does not exist");
> > | }
> > |
> > | }
> > |
> > | Any suggestions?
> >
> > Are you sure the string_value function returns?
> >
> > jwe
> >
>
>
>
> ----------------------------------------------------------------
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

jswensen
In reply to this post by Andy Adler
Quoting Andy Adler <[hidden email]>:

> On Mon, 15 Aug 2005 [hidden email] wrote:
>
>> I just tried a MUCH simpler test case and am seeing the same thing.
>>
>> Code Used
>> -------------------------
>> // Octave Includes
>> #include<octave/oct.h>
>> #include<octave/parse.h>
>>
>> #include <iostream>
>> using namespace std;
>>
>> DEFUN_DLD(test_func,args,,"blah")
>> {
>> string testString = args(1).string_value();
>>
>> return octave_value();
>> }
>>
>> Compile command line
>> -----------------------------------
>> mkoctfile test_func.cc
>>
>> Octave command line
>> ---------------------------
>> test_func(0,'TestFunc')
>
> Works fine for me with 2.9.3 under cygwin. What version are you
> using?
>
> --
> Andy Adler
>

I was running a self-built 2.1.65.  I thought that might be the problem, so I
uninstalled it and installed the newly released 2.1.71 version from the cygwin
octave maintainer.  I am still seeing the same problem.  I think I am going to
try it on a different computer with a fresh Cygwin install to see if the
problem is somehow in my install.

John


----------------------------------------------------------------



Reply | Threaded
Open this post in threaded view
|

Re: Issue where return doesn't really return to octave prompt

James R. Phillips-2
--- jswensen wrote:

> I just tried a MUCH simpler test case and am seeing the same thing.
>

The cygwin octave package is compiled with gcc3.3.3, because gcc3.4.4 has not
(yet) produced a working package.  Suggest you revert to this compiler and try
again.  To keep from upgrading, you have to tell cygwin setup.exe _every_ time
you run it that you don't want to upgrade gcc, g++, g77, etc.

Jim Phillips