bugGNU Octave - Bugs: bug #50183, tempname() returns an empty string...

 
 

bug #50183: tempname() returns an empty string on Solaris

Submitter:  Michele <michele31415>
Submitted:  Sun 29 Jan 2017 08:33:52 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  Need Info Assigned to:  None
Originator Name:  Michele31415 Open/Closed:  * Closed
Release:  * 4.0.1 Operating System:  * Solaris/SunOS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 06 Sep 2017 09:26:04 PM UTC, comment #33: 

Well actually following a system reboot, it no longer works at all:

bash-3.2$ ./octave --no-site-file
ld.so.1: octave-gui: fatal: libgcc_s.so.1: version 'GCC_4.0.0' not found (required by file /export/home/miller/octave/lib/octave/4.0.1-rc4/liboctinterp.so.3)
ld.so.1: octave-gui: fatal: libgcc_s.so.1: open failed: No such file or directory
octave exited with signal 9
bash-3.2$

Thanks for trying anyway.  I'll try to figure out what environment variable used to be set but no longer is.

Michele <michele31415>
Wed 06 Sep 2017 08:54:03 PM UTC, comment #32: 

The use of OCTAVE_INITFILE was only an example of how the file might not be what Octave was looking for.  There are other ways as well.  As Mike said, the sitewide file is called "octaverc" without the preceding '.', not ".octaverc" that you searched for.    That's why its best to let Octave figure out whether it is the site-wide file that is causing the problem by checking if


octave --no-site-file


works.

I also think that this is too old a bug to fix.  The next time there is a reproducible error on Solaris with the development version of the code a new report can be filed that we can look into.

Rik <rik5>
Group administrator
Wed 06 Sep 2017 08:06:48 PM UTC, comment #31: 

"what file did you search for? The init file can be re-defined through the environment variable OCTAVE_INITFILE so it's possible that you were looking for 'octaverc' when the name is something else. "

I searched for ".octaverc".  The variable OCTAVE_INITFILE is not set.

"Also, I suspect that we should really try to repeat this using the development code (not 4.0.1 which is very, very ancient)."

That's a good idea and it's fine with me, but unless Mike wants to try it I'm afraid it's beyond my limited skills.

Michele <michele31415>
Tue 05 Sep 2017 09:22:41 PM UTC, comment #30: 

Right, but rather than relying on searching the filesystem, just rely on Octave to tell you which situation works and which does not.  For example, if you rely on searching the file system, what file did you search for?  The init file can be re-defined through the environment variable OCTAVE_INITFILE so it's possible that you were looking for 'octaverc' when the name is something else.

Also, I suspect that we should really try to repeat this using the development code (not 4.0.1 which is very, very ancient).  There have been upgrades to gnulib which might have impacted this.

Rik <rik5>
Group administrator
Tue 05 Sep 2017 09:05:34 PM UTC, comment #29: 

The site-wide and version-specific octaverc files are just called "octaverc" without the leading dot. Defaults are installed with Octave, I believe they should be /export/home/miller/octave/share/octave/4.0.1-rc4/m/startup/octaverc and /export/home/miller/octave/share/octave/site/m/startup/octaverc on your system. If you run "octave --no-site-file" it skips both of these startup files. Can you confirm whether that also fixes this the same as "octave --norc"?

Mike Miller <mtmiller>
Group Member
Tue 05 Sep 2017 08:44:07 PM UTC, comment #28: 

&quot;The first one disables the user's ~/.octaverc and any local ./.octaverc file. The second one disables the site-wide octaverc file.&quot;

I have no .octaverc in my home nor is there one in the directory (/export/home/miller) in which octave was built.  I can't find any .octaverc anywhere else in /export.

Michele <michele31415>
Tue 05 Sep 2017 05:09:42 AM UTC, comment #27: 

To narrow things further, try the following start-up options individually:


octave --no-init-file


and


octave --no-site-file


The first one disables the user's ~/.octaverc and any local ./.octaverc file.  The second one disables the site-wide octaverc file.

That might help point out which rc file is in error.


Rik <rik5>
Group administrator
Sat 04 Mar 2017 11:13:58 PM UTC, comment #26: 


> Neither account has a .octaverc file.
> Running octave --norc and doing a tempname works in both accounts.


So that seems to indicate that Octave is built correctly and the system libraries are working, but something in a startup file, maybe not ~/.octaverc, somewhere is changing something causing this to break. No idea what that may be.

Mike Miller <mtmiller>
Group Member
Sat 04 Mar 2017 02:56:10 AM UTC, comment #25: 

I don't have a good explanation for why changing HOME would affect this, unless it's something in the .octaverc under one account's home directory that is different from the other. Running octave with the --norc (or -f) option might show whether that is the case or not. Or running octave with HOME set to a completely different directory.

Mike Miller <mtmiller>
Group Member
Sat 04 Mar 2017 01:29:43 AM UTC, comment #24: 

"Well, what did you do differently to get the results in comment #21? Way back in comment #3 you ran tempname and it returned an empty string."

That is true.  That was run from my account.

"Now you've run tempname and it returns a valid temporary file name, how did you run Octave in comment #21 vs before? Did you set the HOME and LD_LIBRARY_PATH variables as I did? Or something else?"

I had LD_LIBRARY_PATH set to your directory, but nothing else.  IF LD_LIBRARY_PATH is not set, Octave won't even start.  The key change appears to involve setting HOME to the value you gave.  That got tempname to work.  Why, I do not know.

This system grew from a plain vanilla Solaris 10 DVD.  As I discovered I needed various tools they got added, using whatever defaults were involved.  This resulted in stuff being spread across /usr/bin, /usr/local/bin, /opt/sfw, /opt/csw, /export/home and perhaps more.  In addition, there are 32 bit and 64 bit versions of things in all of these.  I am not a systems engineer and this is the first time I've tried to bring a Solaris 10 system up to date.  It's pretty difficult to do by myself.

So I guess this looks like a configuration issue and not a bug.  You can close it.  Thanks for your time investigating.

Michele <michele31415>
Fri 03 Mar 2017 03:02:05 AM UTC, comment #23: 

If the relevant bit that is needed is setting LD_LIBRARY_PATH to /export/home/miller/libs, then that sounds like it's related to the same trouble I had earlier when building Octave on this system, namely several overlapping package management systems that I don't fully understand, with some library conflicts and broken dependencies that I tried to work around with that libs directory.

Mike Miller <mtmiller>
Group Member
Fri 03 Mar 2017 02:01:01 AM UTC, comment #22: 

Well, what did you do differently to get the results in comment #21? Way back in comment #3 you ran tempname and it returned an empty string. Now you've run tempname and it returns a valid temporary file name, how did you run Octave in comment #21 vs before? Did you set the HOME and LD_LIBRARY_PATH variables as I did? Or something else?

Mike Miller <mtmiller>
Group Member
Fri 03 Mar 2017 01:53:33 AM UTC, comment #21: 

"What does this script look like for you?"

octave:9> tempname
ans = /var/tmp/oct-lwXcI9
octave:10> tempname
ans = /var/tmp/oct-KV9F39
octave:11> P_tmpdir
ans = /var/tmp/
octave:12> tempdir
ans = /tmp/
octave:13> setenv TMPDIR /tmp
octave:14> tempdir
ans = /tmp/
octave:15> tempname
ans = /var/tmp/oct-FbJ5Ph
octave:16> tempname (tempdir)(tempdir)
ans = /tmp/oct-Koi1Zn
octave:17> tempname (P_tmpdir)(P_tmpdir)
ans = /var/tmp/oct-nzOs0x
octave:18>

So is the whole problem just that I'm trying to run it from my own account with some unknown permutation of environment variables?

Michele <michele31415>
Fri 03 Mar 2017 01:37:27 AM UTC, comment #20: 

Hmm, it works for me on your system.

Assuming we're talking about the same instance of Octave here,


$ export HOME=/export/home/miller
$ export LD_LIBRARY_PATH=$HOME/libs
$ env -i HOME=$HOME LD_LIBRARY_PATH=$LD_LIBRARY_PATH ~/octave/bin/octave-cli --silent
octave:1> tempname
ans = /var/tmp/oct-0OS2cb
octave:2> tempname
ans = /var/tmp/oct-AoK2Sj
octave:3> P_tmpdir
ans = /var/tmp/
octave:4> tempdir
ans = /var/tmp/
octave:5> setenv TMPDIR /tmp
octave:6> tempdir
ans = /tmp/
octave:7> tempname
ans = /var/tmp/oct-IXXiPZ
octave:8> tempname (tempdir)
ans = /tmp/oct-vs3FFj


Command 7 is the old behavior, in Octave 4.2 this should return a file under /tmp instead of /var/tmp.

Other than that, everything seems to be working for me with my account / environment / permissions.

What does this script look like for you?


tempname
tempname
P_tmpdir
tempdir
setenv TMPDIR /tmp
tempdir
tempname
tempname (tempdir)
tempname (P_tmpdir)


Mike Miller <mtmiller>
Group Member
Fri 03 Mar 2017 12:18:39 AM UTC, comment #19: 

Sure, send/remind me of the login info, and I will try to debug this directly.

Mike Miller <mtmiller>
Group Member
Thu 02 Mar 2017 05:26:33 PM UTC, comment #18: 

"I think this is the same build of Octave that I made last summer on this server"

Yes, that's the one.  If it would be of any help, I could send you the current access information so you could look at it directly.  Otherwise I don't mind continuing to answer questions.

Michele <michele31415>
Thu 02 Mar 2017 05:12:44 PM UTC, comment #17: 

I think this is the same build of Octave that I made last summer on this server (/export/home/miller/octave).

If that's the case, I think it was built with as close to default options as possible (-g -O2).

The test project results in comment #15 seem to show that there's no problem with the underlying gnulib gen_tempname function on Solaris, but maybe in the functions that are determining what the default temporary directory should be or in building up the template string (debugging with gdb was indeterminate).

For example if I set TMPDIR=/root, I get the same symptom, an empty string return value from tempname and no error thrown.

Mike Miller <mtmiller>
Group Member
Thu 02 Mar 2017 03:58:51 PM UTC, comment #16: 

Is there any particular reason that you are using 4.0.1-rc4?

Did you build Octave yourself?  If so, can you build the current release and see whether the problem is still there?

If you built Octave yourself, can you rebuild without -O and with -g so that debugging with gdb might work better?

Does


tempname ("/tmp")


work?  What about setting TMPDIR="/tmp" or TMP="/tmp" before starting Octave?

John W. Eaton <jwe>
Group administrator
Thu 02 Mar 2017 06:04:29 AM UTC, comment #15: 

"Do you have a TMPDIR or TMP in your environment?"

Nope:
bash-3.2$ echo $TMPDIR

bash-3.2$ echo $TMP

bash-3.2$

"Does setting or unsetting either one of them (before starting Octave) make any difference? "

What should I set them to?

"Can you try the attached project? Just extract, build, and run: "

bash-3.2$ ./tempname
template = /var/tmp//oct-XXXXXX
tempname = /var/tmp//oct-eSBySO
bash-3.2$

Michele <michele31415>
Thu 02 Mar 2017 01:23:25 AM UTC, comment #14: 

Well I have no idea how to use gdb here, so moving on.

Do you have a TMPDIR or TMP in your environment? Does setting or unsetting either one of them (before starting Octave) make any difference?

Can you try the attached project? Just extract, build, and run:


$ tar xf tempname-0.tar.gz
$ cd tempname-0
$ ./configure
$ make
$ ./tempname


And what does it print? This should be replicating the same library calls that Octave is using in its own tempname function.

(file #39875)

Mike Miller <mtmiller>
Group Member
Thu 02 Mar 2017 01:01:32 AM UTC, comment #13: 

"Can you try again with "p tname" after the breakpoint is hit?"

(gdb) p tname
No symbol "tname" in current context.

Michele <michele31415>
Thu 02 Mar 2017 12:45:34 AM UTC, comment #12: 

It's possible this is a bug in gnulib, further debugging looks like it's needed at this point. I expect the gen_tempname function to return either a valid temporary file name or an error message. You are seeing no error message, and it's returning an empty string (but the 'No symbol "retval"' is weird, maybe gdb doesn't work the way I think it should on your OS).

Can you try again with "p tname" after the breakpoint is hit?

Mike Miller <mtmiller>
Group Member
Wed 01 Mar 2017 10:24:42 PM UTC, comment #11: 

"You answered "n" to the prompt about adding the pending breakpoint, so no breakpoint was set. Try answering "y", run again."

Well I didn't know what to say and so I just took the default, which was n.  This is what I get now:

Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (file-ops.cc:720) pending.
(gdb) r
Starting program: /export/home/miller/octave/bin/octave-cli
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
warning: kpathsea: variable 'PATH' references itself (eventually)
warning: called from
    /export/home/miller/octave/lib/octave/4.0.1-rc4/oct/sparc-sun-solaris2.10/PKG_ADD at line 5 column 1
Xlib: connection to ":11.0" refused by server
Xlib: No protocol specified

GNU Octave, version 4.0.1-rc4
Copyright (C) 2015 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "sparc-sun-solaris2.10".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> tempname
[Switching to Thread 1 (LWP 1)]

Breakpoint 1, octave_tempnam (dir=..., pfx=..., msg=...)
    at ../../liboctave/system/file-ops.cc:721
721     }
(gdb) p retval
No symbol "retval" in current context.
(gdb) p msg
$1 = (std::string &) @0xffbfea74: {static npos = <optimized out>,
  _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0xfb69c604 <std::string::_Rep::_S_empty_rep_storage+12> ""}}
(gdb)

Michele <michele31415>
Wed 01 Mar 2017 10:07:48 PM UTC, comment #10: 

You answered "n" to the prompt about adding the pending breakpoint, so no breakpoint was set. Try answering "y", run again. The "p retval" and "p msg" commands are assuming it actually hits a breakpoint and returns to the (gdb) prompt.

Mike Miller <mtmiller>
Group Member
Wed 01 Mar 2017 10:04:21 PM UTC, comment #9: 

""I would try something like this in gdb"

bash-3.2$ gdb /export/home/miller/octave/bin/octave-cli
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /export/home/miller/octave/bin/octave-cli...done.
(gdb) b file-ops.cc:720
No source file named file-ops.cc.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) r
Starting program: /export/home/miller/octave/bin/octave-cli
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
warning: kpathsea: variable 'PATH' references itself (eventually)
warning: called from
    /export/home/miller/octave/lib/octave/4.0.1-rc4/oct/sparc-sun-solaris2.10/PKG_ADD at line 5 column 1
Xlib: connection to ":11.0" refused by server
Xlib: No protocol specified

GNU Octave, version 4.0.1-rc4
Copyright (C) 2015 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "sparc-sun-solaris2.10".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> tempname
ans = /var/tmp/oct-8Q83Yd
octave:2> p retval
error: 'p' undefined near line 1 column 1
octave:2> p msg
error: 'p' undefined near line 1 column 1
octave:2>


/var/tmp has permisisons:
drwxrwxrwt  32 root     sys         8704 Mar  1 10:01 tmp

Michele <michele31415>
Wed 01 Mar 2017 07:15:55 PM UTC, comment #8: 

I would try something like this in gdb


$ gdb octave-cli
(gdb) b file-ops.cc:720
(gdb) r
octave:1> tempname
Breakpoint hit
(gdb) p retval
(gdb) p msg


Mike Miller <mtmiller>
Group Member
Thu 09 Feb 2017 09:35:51 PM UTC, comment #7: 

Is there anything further I can do to assist in resolving this issue?

Michele <michele31415>
Sat 04 Feb 2017 01:26:19 AM UTC, comment #6: 

"Can you run octave-cli in a debugger and see why tempname is returning an empty string?"

Possibly - if I knew how to do that.  I tried this (not sure if this is what you meant) and stopped:  I am (clearly) a gdb novice.

# gdb octave-cli
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from octave-cli...done.
(gdb) break tempname
Function "tempname" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) break install
Function "install" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n

Michele <michele31415>
Fri 03 Feb 2017 09:49:52 PM UTC, comment #5: 

I also think it might be good if tempname actually did throw an error if the underlying function had a problem generating a temporary file name. The code is in place to get the error string, but Octave is throwing it away and assuming the function always works.

Mike Miller <mtmiller>
Group Member
Fri 03 Feb 2017 09:48:04 PM UTC, comment #4: 

Well, that's unfortunate.

I see that in some logs I saved from earlier tests I ran on your system last year, looks like that was the case at the time and I did not catch it or report it as a bug then.

Can you run octave-cli in a debugger and see why tempname is returning an empty string? The underlying function does return an error message string, but it looks like Octave ignores it along the stack so there is no way to tell from the interpreter. It would be best to be testing this with the development version, or at least 4.2.0, but it generally looks like not much has changed with this function since 4.0 other than some code refactoring.

Mike Miller <mtmiller>
Group Member
Fri 03 Feb 2017 05:58:41 AM UTC, comment #3: 

Thanks for the suggestion.  I get this:

>> pkg install -verbose /export/home/user1/Downloads/parallel-3.1.1.tar.gz

mkdir ()
couldn't create temporary directory: No such file or directory
error: called from 'install' in file /export/home/user2/octave/share/octave/4.0.1-rc4/m/pkg/private/install.m near line 74, column 11

>>


Looking in install.m, it appears that tempname () isn't returning anything:

>> tempname ()

ans =

>>

Michele <michele31415>
Fri 03 Feb 2017 01:34:32 AM UTC, comment #2: 

Try running


more off
pkg install -verbose /export/home/user1/Downloads/parallel-3.1.1.tar.gz


If this error is reproducible, you should see a line saying "mkdir (/some/directory)" in the output before the error happens. This should be a safe temporary directory name returned by the tempname() function, maybe there is a problem with the temporary directory permissions on your system or the functions used to generate a safe temp name.

Mike Miller <mtmiller>
Group Member
Tue 31 Jan 2017 08:25:30 PM UTC, comment #1: 
Michele <michele31415>
Sun 29 Jan 2017 08:33:52 PM UTC, original submission:  

While trying to install a package in Solaris Octave, I get:

>> pkg install /export/home/user1/Downloads/parallel-3.1.1.tar.gz

couldn't create temporary directory: No such file or directory
error: called from 'install' in file /export/home/user2/octave/share/octave/4.0.1-rc4/m/pkg/private/install.m near line 74, column 11

>>


Not quite sure what it's complaining about here.  What temporary directory can't it create?  Any help would be appreciated.  Thanks.

Michele <michele31415>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #39875:  tempname-0.tar.gz added by mtmiller (371KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by michele31415 (Submitted the item)
  • -email is unavailable- added by michele31415
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-26 mtmiller Carbon-CopyRemoved 80942 -
    2017-09-06 rik5 Open/ClosedOpen Closed
    2017-03-02 mtmiller Attached File- Added tempname-0.tar.gz, #39875
    2017-02-03 mtmiller CategoryOctave Package Octave Function
        Item GroupInstallation Failure Missed Error or Warning
    2017-02-03 mtmiller Summarypkg install error tempname() returns an empty string on Solaris
    2017-02-03 mtmiller StatusNone Need Info
    2017-01-29 michele31415 Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code