bugGNU Octave - Bugs: bug #60998, fatal: unable to find current...

 
 

bug #60998: fatal: unable to find current directory when configured on NFS

Submitter:  BaldStrong <baldstrong>
Submitted:  Sun 01 Aug 2021 04:55:53 PM UTC
   
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Assigned to:  None
Originator Name:  BaldStrong Open/Closed:  * Closed
Release:  * 6.3.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 03 Aug 2021 06:46:51 AM UTC, comment #12: 

In any case, I think we have determined with reasonable confidence that the issue is caused by functions in gnulib.
Configuring (and building) on a shared file system might be a corner case that isn't well tested.
If you care enough about it, you could probably ask on their mailing list if this is a use case they try to support. They might also be able to give better suggestions on how to handle your use case correctly.

I'll close this report for now because I think this is caused by something upstream.
If they determine that we are using their module in a wrong way, please report back and we can re-open.

Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 04:50:15 PM UTC, comment #11: 

Can you try and build on a local drive? Does that work?

Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 04:47:42 PM UTC, comment #10: 

You are so awesome ! Yes, I'm using a cluster that uses a shared file system NFS.

BaldStrong <baldstrong>
Mon 02 Aug 2021 04:34:30 PM UTC, comment #9: 

Thanks for uploading those files.

It looks like the test "checking whether getcwd handles long file names properly" failed for you. That causes the build system to use gnulib's replacement of that function.
The same test succeeds for me on Ubuntu 21.04.
It might be that this is a bug in that function that has been fixed in the meantime (CentOS 7's code base is "old" compared to Ubuntu 21.04). But even if it is, gnulib's replacement should probably not cause the error you are seeing.

Is this on a local disc? Or some kind of network share?

Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 03:26:45 PM UTC, comment #8: 

You are right. With this result, it looks like the bug is in gnulib's implementation of `getcwd`.

Could you please attach `config.h` and `config.log` from your build directory?

Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 03:23:28 PM UTC, comment #7: 

Thank you all so much, I did what you said and it compiles and runs successfully. But is this even a fix for the bug? I don't think this guarantees compatibility on Windows. I think the octave_getcwd_wrapper function in unistd-wrappers.c should be changed.

BaldStrong <baldstrong>
Mon 02 Aug 2021 02:57:44 PM UTC, comment #6: 

Oops. Sorry. I wanted to use the function of the top-level namespace.

Could you please try with this change?

diff -r ace96e3bba66 liboctave/system/lo-sysdep.cc
--- a/liboctave/system/lo-sysdep.cc        Sun Aug 01 15:58:12 2021 +0200
+++ b/liboctave/system/lo-sysdep.cc        Mon Aug 02 16:56:15 2021 +0200
@@ -30,6 +30,7 @@
 #include <cstdlib>
 #include <locale>
 #include <codecvt>
+#include <unistd.h>

 #include "dir-ops.h"
 #include "file-ops.h"
@@ -90,7 +91,7 @@
       // will allocate a buffer as large as necessary if buf and size are
       // both 0.

-      char *tmp = octave_getcwd_wrapper (nullptr, 0);
+      char *tmp = ::getcwd (nullptr, 0);

       if (! tmp)
         (*current_liboctave_error_handler) ("unable to find current directory");


Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 02:55:48 PM UTC, comment #5: 

Try


char *tmp = ::getcwd (nullptr, 0);


to select the global getcwd function instead of the one defined in the octave::sys namespace.  You may also need to include <unistd.h>.

John W. Eaton <jwe>
Group administrator
Mon 02 Aug 2021 02:49:20 PM UTC, comment #4: 


comment #3:

> Afaict, "get_current_dir_name" isn't part of the POSIX specifications [1]. So, we can't use it (at least not unconditionally).
>
> Does it also work if you replace that line with the following (i.e., using the system's getcwd instead of gnulib's implementation)?


>       char *tmp = getcwd (nullptr, 0);


>
> [1]: https://linux.die.net/man/3/get_current_dir_name

-------------------------------------------------------
As you said:
../liboctave/system/lo-sysdep.cc: In function ‘std::string octave::sys::getcwd()’:
../liboctave/system/lo-sysdep.cc:76:35: error: too many arguments to function ‘std::string octave::sys::getcwd()’
       char *tmp = getcwd(nullptr,0);
                                   ^
../liboctave/system/lo-sysdep.cc:53:5: note: declared here
     getcwd (void)
     ^~~~~~
../liboctave/system/lo-sysdep.cc:76:35: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘char*’ in initialization
       char *tmp = getcwd(nullptr,0);
                                   ^
  CXX      liboctave/util/libutil_la-glob-match.lo
make[2]: * [Makefile:24609: liboctave/system/libsystem_la-lo-sysdep.lo] Error 1

BaldStrong <baldstrong>
Mon 02 Aug 2021 01:52:55 PM UTC, comment #3: 

Afaict, "get_current_dir_name" isn't part of the POSIX specifications [1]. So, we can't use it (at least not unconditionally).

Does it also work if you replace that line with the following (i.e., using the system's getcwd instead of gnulib's implementation)?

      char *tmp = getcwd (nullptr, 0);


[1]: https://linux.die.net/man/3/get_current_dir_name

Markus Mützel <mmuetzel>
Group administrator
Mon 02 Aug 2021 06:56:19 AM UTC, comment #2: 


comment #1:

> Could you attach a 'diff -u' for the change you made to lo-sysdep.cc?  The vast majority of people never see this problem.  I'd like to try and debug whether it is something with the Octave code, gnulib, or something odd about your system.  Which distribution of Linux and version are you using?


diff result:
--- ./liboctave/system/lo-sysdep.cc     2021-08-02 14:38:55.000000000 +0800
+++ ../octave-release-6-3-0/liboctave/system/lo-sysdep.cc       2021-07-12 01:19:32.000000000 +0800
@@ -72,7 +72,7 @@
       // will allocate a buffer as large as necessary if buf and size are
       // both 0.
 
-      char *tmp = get_current_dir_name();
+      char *tmp = octave_getcwd_wrapper (nullptr, 0);
 
       if (! tmp)
         (*current_liboctave_error_handler) ("unable to find current directory");

OS:Centos7
Kernel:Linux 3.10.0-957.el7.x86_64
CPU:AMD

BaldStrong <baldstrong>
Mon 02 Aug 2021 12:15:16 AM UTC, comment #1: 

Could you attach a 'diff -u' for the change you made to lo-sysdep.cc?  The vast majority of people never see this problem.  I'd like to try and debug whether it is something with the Octave code, gnulib, or something odd about your system.  Which distribution of Linux and version are you using?

Rik <rik5>
Group administrator
Sun 01 Aug 2021 04:55:53 PM UTC, original submission:  

bug:After make, ./run-octave appears "fatal: unable to find current directory".

The solution is mentioned here:https://github.com/gnu-octave/GNU-Octave-enable-64/issues/7.

But I don't konw how to change it.

Then I changed the octave_getcwd_wrapper(nullptr, 0) in liboctave/system/lo-sysdep.cc to get_current_dir_name().

solve!

BaldStrong <baldstrong>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51730:  config.zip added by baldstrong (203KiB - application/x-zip-compressed - Strange, I've uploaded it several times and the 3MB config.log doesn't seem to upload.)
file #51729:  config.h added by baldstrong (99KiB - text/plain - I restored the code as before and recompiled it to get config.h,config.log.)
file #51728:  config.h added by baldstrong (99KiB - text/plain - I restored the code as before and recompiled it to get config.h,config.log.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-08-03 mmuetzel StatusNeed Info None
        Open/ClosedOpen Closed
        Summaryfatal: unable to find current directory fatal: unable to find current directory when configured on NFS
    2021-08-02 baldstrong Attached File- Added config.zip, #51730
    2021-08-02 baldstrong Attached File- Added config.h, #51729
    2021-08-02 baldstrong Attached File- Added config.h, #51728
    2021-08-02 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code