Newer Versions of Octave Struggle with Character Strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Newer Versions of Octave Struggle with Character Strings

evansste
I've noticed that Octave 4.0.0 and 4.0.3 struggle to handle character strings that contain a significant number of elements.  When attempting to handle operations with large character strings, these versions return the known error message:

error: input buffer overflow, can't enlarge buffer because scanner uses REJECT
input buffer overflow, can't enlarge buffer because scanner uses REJECT

However, I've noticed that when running the same program, Octave 3.8.1 performs with no issues.

The circumstances, under which this error message occurs, are quite peculiar.  The following script won't cause the above error message to occur with Octave 4.0.0.

alphabet = 'abcdefghijklmnopqrstuvwxyz';
for n = 1:15
        alphabet = [alphabet alphabet];
end
instances = find(alphabet=='j');

However, if the "alphabet" variable is declared as a character string, rather than building it using the loop, the error will occur.  For instance, if the script were the following, you'd get the error message.

alphabet = 'abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz';
instances = find(alphabet=='j');

The "alphabet" variable contains 851968 characters.  For this reason, I used an ellipsis (...) to describe it.  However, if the script contains the actual 851968-character character string, the error will occur.

I don't currently have Octave 3.8.1 installed on my computer, but similar tests have shown that the error probably won't occur with Octave 3.8.1.  Why is that?  Why is it that Octave 3.8.1 can handle the larger declaration of a character string, but newer versions (Octave 4.0.0 and 4.0.3) can't?

I want to thank the developers for providing Octave.  It's an excellent computing tool, and I'm happy to be one of its users.  Please consider my character string observation as a tool to further improve your wonderful software.  In any case, thank you for offering Octave to the world.





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Mike Miller-4
On Mon, Jul 03, 2017 at 08:03:26 -0700, evansste wrote:
> I've noticed that Octave 4.0.0 and 4.0.3 struggle to handle character strings
> that contain a significant number of elements.  When attempting to handle
> operations with large character strings, these versions return the known
> error message:
>
> error: input buffer overflow, can't enlarge buffer because scanner uses
> REJECT
> input buffer overflow, can't enlarge buffer because scanner uses REJECT

Fortunately, this issue has already been reported and fixed. If you
update to Octave 4.2 this should be resolved for you.

For others trying to reproduce, the long input line must be read from a
script file. I used the following

    alphabet = char (repmat ('a':'z', 1, 2^15));
    fid = fopen ("foo.m", "wt");
    fprintf (fid, "alphabet = '%s';\n", alphabet);
    fclose (fid);
    clear all
    foo

which crashes 4.0.3 with the reported error but is ok in 4.2.1.

See also bug #45947.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

evansste
Thanks, Mike.  I just installed Octave 4.2.1 (compiling it from source), and, just as your solution suggested, I no longer have this issue with character strings.  Thanks for that.

What I've noticed is that Octave now doesn't seem to make changes based on my .octaverc file.  The .octaverc file is in my home directory.  Because the .octaverc file is no longer working, I thought that compiling from source may have caused Octave to look elsewhere for this file.  So I put a copy of the file in the directory from which Octave was complied.  However, this still didn't work.  Is this behavior normal?  Doesn't Octave always look in the home directory?

I compiled Octave by strictly following the detailed procedure in the following link:

https://www.scivision.co/compiling-octave-4-on-ubuntu/

Do you know why Octave isn't using my .octaverc file?  I'm using Lubuntu 16.04.

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Mike Miller-4
On Tue, Jul 04, 2017 at 09:34:28 -0700, evansste wrote:

> What I've noticed is that Octave now doesn't seem to make changes based on
> my .octaverc file.  The .octaverc file is in my home directory.  Because the
> .octaverc file is no longer working, I thought that compiling from source
> may have caused Octave to look elsewhere for this file.  So I put a copy of
> the file in the directory from which Octave was complied.  However, this
> still didn't work.  Is this behavior normal?  Doesn't Octave always look in
> the home directory?
>
> I compiled Octave by strictly following the detailed procedure in the
> following link:
>
> https://www.scivision.co/compiling-octave-4-on-ubuntu/
>
> Do you know why Octave isn't using my .octaverc file?  I'm using Lubuntu
> 16.04.

Are you sure it isn't reading your ~/.octaverc file? Can you put
something like "somevar = 42;" in the file and see if somevar is defined
when Octave is up?

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

evansste
Thanks, Mike.

You're right.  I tried your tip, and it is reading my .octaverc file!  The "somevar" variable was recognized.  However, now I don't understand why it's not obeying the "cd" command in my .octaverc file.

My .octaverc file contains the following lines:

cd /home/evansste/octdir
page_screen_output(0);
page_output_immediately(1);
somevar = 42;

However, when I try to run .m scripts, which are contained in the "octdir" directory, Octave doesn't recognize them.  If I use the same "cd" command, by typing it while Octave is running, it changes to the directory, and will then run my scripts from that directory.  However, for some reason, it doesn't change to the directory based on the command in the .octaverc file.  Any ideas what may be causing this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Doug Stewart-4


On Tue, Jul 4, 2017 at 2:23 PM, evansste <[hidden email]> wrote:
Thanks, Mike.

You're right.  I tried your tip, and it is reading my .octaverc file!  The
"somevar" variable was recognized.  However, now I don't understand why it's
not obeying the "cd" command in my .octaverc file.

My .octaverc file contains the following lines:

cd /home/evansste/octdir
page_screen_output(0);
page_output_immediately(1);
somevar = 42;

However, when I try to run .m scripts, which are contained in the "octdir"
directory, Octave doesn't recognize them.  If I use the same "cd" command,
by typing it while Octave is running, it changes to the directory, and will
then run my scripts from that directory.  However, for some reason, it
doesn't change to the directory based on the command in the .octaverc file.
Any ideas what may be causing this?





when you start octave type in

pwd

and report back what the result was.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

evansste
After typing "pwd" I receive the following:

ans = /opt/octave4/bin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Dmitri A. Sergatskov


On Tue, Jul 4, 2017 at 3:28 PM, evansste <[hidden email]> wrote:
After typing "pwd" I receive the following:

ans = /opt/octave4/bin



​Now, at the octave prompt try:

system("whoami")​

​Dmitri.
--

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

evansste
In reply to this post by evansste
After typing:

system("whoami")​

I receive:

evansste
ans = 0
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Mike Miller-4
In reply to this post by evansste
On Tue, Jul 04, 2017 at 11:23:31 -0700, evansste wrote:

> My .octaverc file contains the following lines:
>
> cd /home/evansste/octdir
> page_screen_output(0);
> page_output_immediately(1);
> somevar = 42;
>
> However, when I try to run .m scripts, which are contained in the "octdir"
> directory, Octave doesn't recognize them.  If I use the same "cd" command,
> by typing it while Octave is running, it changes to the directory, and will
> then run my scripts from that directory.  However, for some reason, it
> doesn't change to the directory based on the command in the .octaverc file.
> Any ideas what may be causing this?

I assume you are using Octave's GUI. There is a known race condition
between the GUI starting and setting the preferred initial directory and
the ~/.octaverc using the cd command. The best workaround is to not use
cd in your ~/.octaverc at this point. If you want Octave to always start
in a particular directory, use the Preferences dialog, General tab, and
set the Octave startup path there.

I don't think this problem will affect you if you are using Octave's
command line interface, this only has to do with GUI initialization.

BTW, you may just want to use addpath instead of cd. The addpath
function would add the octdir directory to your function / script search
path without requiring it to be the current working directory.

https://savannah.gnu.org/bugs/?46544

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Doug Stewart-4


On Tue, Jul 4, 2017 at 5:11 PM, Mike Miller <[hidden email]> wrote:
On Tue, Jul 04, 2017 at 11:23:31 -0700, evansste wrote:
> My .octaverc file contains the following lines:
>
> cd /home/evansste/octdir
> page_screen_output(0);
> page_output_immediately(1);
> somevar = 42;
>
> However, when I try to run .m scripts, which are contained in the "octdir"
> directory, Octave doesn't recognize them.  If I use the same "cd" command,
> by typing it while Octave is running, it changes to the directory, and will
> then run my scripts from that directory.  However, for some reason, it
> doesn't change to the directory based on the command in the .octaverc file.
> Any ideas what may be causing this?

I assume you are using Octave's GUI. There is a known race condition
between the GUI starting and setting the preferred initial directory and
the ~/.octaverc using the cd command. The best workaround is to not use
cd in your ~/.octaverc at this point. If you want Octave to always start
in a particular directory, use the Preferences dialog, General tab, and
set the Octave startup path there.

I don't think this problem will affect you if you are using Octave's
command line interface, this only has to do with GUI initialization.

BTW, you may just want to use addpath instead of cd. The addpath
function would add the octdir directory to your function / script search
path without requiring it to be the current working directory.

https://savannah.gnu.org/bugs/?46544

--
mike


I was about to say that the Startup path for the GUI might override the cd even if the cd worked.

--
DASCertificate for 206392

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

Mike Miller-4
On Tue, Jul 04, 2017 at 17:19:01 -0400, Doug Stewart wrote:
> I was about to say that the Startup path for the GUI might override the cd
> even if the cd worked.

To be clear, even if the user has not entered a specific startup path in
the Preferences dialog, the GUI still sets a default initial working
directory.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newer Versions of Octave Struggle with Character Strings

evansste
Thanks everyone.  The .octaverc issue has now been solved, thanks to your mention of the race condition.  I'm not using the GUI, but this solved my issue all the same.

Before compiling Octave 4.2.1, I never uninstalled my old version of Octave (Octave 4.0.2).  I've always typed "octave-cli" in order to start Octave.  After installing 4.2.1, the "octave-cli" command would still start 4.0.2.  So I've now changed my .bash_aliases file to contain the following line:

alias octave-cli="/opt/octave4/bin/octave -p /home/evansste/octdir --no-gui"

This was based on Mike's suggestion to use addpath, and it seems to be working well.

Thanks again for everyone's help.  This truly is a remarkable forum!
Loading...