Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

realpath(..., NULL) busted on OS X 10.5 #4433

Closed
snigel opened this issue Sep 27, 2017 · 16 comments
Closed

realpath(..., NULL) busted on OS X 10.5 #4433

snigel opened this issue Sep 27, 2017 · 16 comments
Milestone

Comments

@snigel
Copy link

snigel commented Sep 27, 2017

OSX 10.5 powerpc
Using gcc 4.9, autoconf 2.69 and automake 1.15.1 from macports
fish 2.6.0 via tarball.

Configuring and compiling fish works as expected.
Starting fish does not.

iBookG4:fish-2.6.0 snigel$ pwd
/Users/snigel/fish-2.6.0

iBookG4:fish-2.6.0 snigel$ ./configure
iBookG4:fish-2.6.0 snigel$ make
  FISH_BUILD_VERSION = '2.6.0'
  CXX = 'g++ -std=c++11'
  CXXFLAGS = '-g -O2 -fno-exceptions -Wextra -Wno-missing-field-initializers -I/opt/local/include '
  MKDIR_P = './install-sh -c -d'
  SED = '/opt/local/bin/gsed'
  AWK = 'awk'
  FGREP = '/usr/bin/grep -F'
  doxygen  user_doc
/Users/snigel/fish-2.6.0/doc.h:4284: warning: multiple use of section label 'notes' while adding section, (first occurrence: /Users/snigel/fish-2.6.0/doc.h, line 3090)
  prefix = '/usr/local'
  sysconfdir = '/usr/local/etc'
  docdir = '/usr/local/share/doc/fish'
  extra_completionsdir = '/usr/local/share/fish/vendor_completions.d'
  extra_functionsdir = '/usr/local/share/fish/vendor_functions.d'
  extra_confdir = '/usr/local/share/fish/vendor_conf.d'
  SED      fish.pc
  SED      share/__fish_build_paths.fish

iBookG4:fish-2.6.0 snigel$ ./fish
Bus error

iBookG4:fish-2.6.0 snigel$ ./fish --version
fish, version 2.6.0
iBookG4:fish-2.6.0 snigel$ sh -c 'env HOME=$(mktemp -d) fish'
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
env: fish: No such file or directory

iBookG4:fish-2.6.0 snigel$ sh -c 'env HOME=$(mktemp -d) ./fish'
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
Bus error
@krader1961
Copy link
Contributor

The newest version of fish supported on OS X 10.5 is version 2.4. You might be able to get 2.6.0 or newer to compile and run if you've satisfied the C++11 libc requirement but it's not supported. Having said that if you do ulimit -c unlimited; ./fish and get a core dump that pinpoints where the fault is occurring we'd probably accept a patch to fix whatever is wrong.

From the README.md file:

### OS X SnowLeopard

Starting with version 2.5, fish requires a C++11 standard library on OS X 10.6 ("SnowLeopard"). If this library is not installed, you will see this error: `dyld: Library not loaded: /usr/lib/libc++.1.dylib`

MacPorts is the easiest way to obtain this library. After installing the SnowLeopard MacPorts release from the install page, run:

sudo port -v install libcxx

Now fish should launch successfully. (Please open an issue if it does not.)

This is only necessary on 10.6. OS X 10.7 and later include the required library by default.

@ridiculousfish
Copy link
Member

iBook G4, that's remarkable!

@snigel can you please try launching it with gdb and showing a backtrace when it crashes?

@snigel
Copy link
Author

snigel commented Oct 1, 2017

@krader1961 sorry about that. I should have seen those lines in the readme.
At the moment I can't get libcxx to compile under osx 10.5, although Fish strangely(?) compiled fine without.

I have barely used gdb before, so I hope I'm doing it right.

iBookG4:fish-2.6.0 snigel$ ulimit -c unlimited; ./fish
Bus error (core dumped)
iBookG4:fish-2.6.0 snigel$ gdb ./fish /cores/core.65314
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:15:14 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
unable to read unknown load command 0x24
unable to read unknown load command 0x26

Core was generated by `./fish'.
Reading symbols for shared libraries . done
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
#0  0x91f5e3d0 in realpath$DARWIN_EXTSN ()
(gdb)

@ridiculousfish

iBookG4:fish-2.6.0 snigel$ gdb ./fish
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:15:14 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
unable to read unknown load command 0x24
unable to read unknown load command 0x26

(gdb) start
Die: DW_TAG_unspecified_type (abbrev = 10, offset = 4355698)
        has children: FALSE
        attributes:
                DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /Users/snigel/fish-2.6.0/fish.dSYM/Contents/Resources/DWARF/fish]
Starting program: /Users/snigel/fish-2.6.0/fish
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ++++.+. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x91f5e3d0 in realpath$DARWIN_EXTSN ()
(gdb)

Trying with sudo.

iBookG4:fish-2.6.0 snigel$ sudo gdb
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:15:14 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin".
(gdb) exec-file fish
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
(gdb) start
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (main) pending.
Starting program: /Users/snigel/fish-2.6.0/fish
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ........ done
Die: DW_TAG_unspecified_type (abbrev = 10, offset = 4355698)
        has children: FALSE
        attributes:
                DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /Users/snigel/fish-2.6.0/fish.dSYM/Contents/Resources/DWARF/fish]
Die: DW_TAG_unspecified_type (abbrev = 10, offset = 4355698)
        has children: FALSE
        attributes:
                DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /Users/snigel/fish-2.6.0/fish.dSYM/Contents/Resources/DWARF/fish]
Die: DW_TAG_unspecified_type (abbrev = 10, offset = 4355698)
        has children: FALSE
        attributes:
                DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /Users/snigel/fish-2.6.0/fish.dSYM/Contents/Resources/DWARF/fish]

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x91f5e3d0 in realpath$DARWIN_EXTSN ()

and sudo + coredump

iBookG4:fish-2.6.0 snigel$ sudo gdb ./fish /cores/core.65314
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:15:14 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
unable to read unknown load command 0x24
unable to read unknown load command 0x26

Core was generated by `./fish'.
Reading symbols for shared libraries . done
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ....... done
#0  0x91f5e3d0 in realpath$DARWIN_EXTSN ()
(gdb) exec-file fish
unable to read unknown load command 0x24
unable to read unknown load command 0x26
warning: Unable to read symbols from [memory object "/usr/lib/dyld" at 0x0]: File format not recognized.
gdb stack crawl at point of internal error:
[ 0 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (align_down+0x0) [0x122ab0]
[ 1 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (wrap_here+0x0) [0x122dfc]
[ 2 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (dyld_load_library_from_memory+0x13c) [0x175a20]
[ 3 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (dyld_load_library+0x114) [0x176a04]
[ 4 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (dyld_load_libraries+0xe8) [0x177eb0]
[ 5 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (dyld_update_shlibs+0x9c) [0x1782a4]
[ 6 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (macosx_init_dyld+0x1b4) [0x16c87c]
[ 7 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (exec_file_attach+0x248) [0xa53b8]
[ 8 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (execute_command+0x2b8) [0x11f048]
[ 9 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (command_handler+0xf8) [0x812d8]
[ 10 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (command_line_handler+0x4ac) [0x81a44]
[ 11 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (rl_callback_read_char+0xb8) [0x1b7bc4]
[ 12 ] /usr/libexec/gdb/gdb-powerpc-apple-darwin (rl_callback_read_char_wrapper+0x1c) [0x80a10]
/SourceCache/gdb/gdb-967/src/gdb/macosx/macosx-nat-dyld-process.c:1167: internal-error: assertion failure in function "dyld_load_library_from_memory": e->abfd != NULL

A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

@kencu
Copy link

kencu commented Oct 2, 2017

See also https://trac.macports.org/ticket/54974.

I tried building it with both gcc6 and gcc7, same outcome.

Here is my crashdump:

Process:         fish [40904]
Path:            /opt/local/bin/fish
Identifier:      fish
Version:         ??? (???)
Code Type:       PPC (Native)
Parent Process:  bash [32295]

Date/Time:       2017-10-02 12:40:01.147 -0700
OS Version:      Mac OS X 10.5.8 (9L31a)
Report Version:  6
Anonymous UUID:  4F6A742C-6D8E-40B3-B0E3-1961C4592BC9

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib             	0x900403d0 realpath$DARWIN_EXTSN + 172
1   fish                          	0x000711b4 wrealpath(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, wchar_t*) + 496
2   fish                          	0x000334a0 __ZL25expand_stage_home_and_pidRKSbIwSt11char_traitsIwESaIwEEPSt6vectorI12completion_tSaIS6_EEiPS5_I13parse_error_tSaISA_EE + 64
3   fish                          	0x00034da0 expand_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::vector<completion_t, std::allocator<completion_t> >*, int, std::vector<parse_error_t, std::allocator<parse_error_t> >*) + 520
4   fish                          	0x0004d780 parse_execution_context_t::determine_arguments(parse_node_t const&, std::vector<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::allocator<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > >*, parse_execution_context_t::globspec_t) + 336
5   fish                          	0x0004e25c parse_execution_context_t::populate_plain_process(job_t*, process_t*, parse_node_t const&) + 672
6   fish                          	0x0004e574 parse_execution_context_t::populate_job_process(job_t*, process_t*, parse_node_t const&) + 324
7   fish                          	0x0004e7b0 parse_execution_context_t::populate_job_from_job_node(job_t*, parse_node_t const&, block_t const*) + 248
8   fish                          	0x0004ee58 parse_execution_context_t::run_1_job(parse_node_t const&, block_t const*) + 1144
9   fish                          	0x0004f0ec parse_execution_context_t::run_job_list(parse_node_t const&, block_t const*) + 176
10  fish                          	0x0004fed0 parse_execution_context_t::eval_node_at_offset(unsigned int, block_t const*, io_chain_t const&) + 616
11  fish                          	0x0005875c parser_t::eval_block_node(unsigned int, io_chain_t const&, block_type_t) + 260
12  fish                          	0x000595e8 parser_t::eval(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, io_chain_t const&, block_type_t, parse_node_tree_t) + 288
13  fish                          	0x000662c4 __ZL7read_niiRK10io_chain_t + 572
14  fish                          	0x0006669c reader_read(int, io_chain_t const&) + 720
15  fish                          	0x0000bc68 __ZL14builtin_sourceR8parser_tR12io_streams_tPPw + 420
16  fish                          	0x00008d28 builtin_run(parser_t&, wchar_t const* const*, io_streams_t&) + 344
17  fish                          	0x00030884 exec_job(parser_t&, job_t*) + 3444
18  fish                          	0x0004efc8 parse_execution_context_t::run_1_job(parse_node_t const&, block_t const*) + 1512
19  fish                          	0x0004f0ec parse_execution_context_t::run_job_list(parse_node_t const&, block_t const*) + 176
20  fish                          	0x0004fed0 parse_execution_context_t::eval_node_at_offset(unsigned int, block_t const*, io_chain_t const&) + 616
21  fish                          	0x0005875c parser_t::eval_block_node(unsigned int, io_chain_t const&, block_type_t) + 260
22  fish                          	0x000595e8 parser_t::eval(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, io_chain_t const&, block_type_t, parse_node_tree_t) + 288
23  fish                          	0x00059764 parser_t::eval(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, io_chain_t const&, block_type_t) + 276
24  fish                          	0x00072590 __ZL26source_config_in_directoryRKSbIwSt11char_traitsIwESaIwEE + 320
25  fish                          	0x0007400c main + 1056
26  fish                          	0x00003dfc start + 64

Thread 0 crashed with PPC Thread State 32:
  srr0: 0x900403d0  srr1: 0x0200d030   dar: 0x00000000 dsisr: 0x42000000
    r0: 0x0000002f    r1: 0xbfff9c80    r2: 0x54485244    r3: 0xa0040864
    r4: 0x00000000    r5: 0x0000000f    r6: 0x00223a9b    r7: 0x00000000
    r8: 0x00000000    r9: 0xffffffff   r10: 0x00000004   r11: 0xa000b934
   r12: 0x9000f37c   r13: 0x00000000   r14: 0x004059e4   r15: 0xbffff2c4
   r16: 0x00405ef8   r17: 0x00000001   r18: 0xbfffd858   r19: 0xaaaaaaab
   r20: 0x0000000c   r21: 0x00000000   r22: 0xbfffd8f8   r23: 0x00000040
   r24: 0xbfffd91c   r25: 0x00000000   r26: 0x00000000   r27: 0xbfffd74c
   r28: 0xbfffb6a8   r29: 0xbfffb6ac   r30: 0x0040604c   r31: 0x90040338
    cr: 0x82024252   xer: 0x00000000    lr: 0x900403c0   ctr: 0x9000f37c
vrsave: 0x00000000

Binary Images:
    0x1000 -    0x9afff +fish ??? (???) <ccbf348efd7c3471b1c467ff4ded0fd7> /opt/local/bin/fish
   0xcf000 -    0xd8fff +libintl.8.dylib ??? (???) <0072ebffba7cf65a54dc94ecafc8b5ac> /opt/local/lib/libintl.8.dylib
   0xdc000 -   0x122fff +libncurses.6.dylib ??? (???) <b40d4d32e820c4e03f9bf79f2f5cc58f> /opt/local/lib/libncurses.6.dylib
  0x134000 -   0x196fff +libpcre2-32.0.dylib ??? (???) <31f1837553f47efb7a610cfb25a7bdc9> /opt/local/lib/libpcre2-32.0.dylib
  0x19b000 -   0x249fff +libstdc++.6.dylib ??? (???) <c247b4841023380b84bf0e6de5025c3b> /opt/local/lib/libgcc/libstdc++.6.dylib
  0x2b8000 -   0x2c2ffb +libgcc_s.1.dylib ??? (???) <28a35c56857737879c15ccd0741a150b> /opt/local/lib/libgcc/libgcc_s.1.dylib
  0x2c5000 -   0x3bdfff +libiconv.2.dylib ??? (???) <0d40023623602bdc744ebff96a976c8f> /opt/local/lib/libiconv.2.dylib
0x8fe00000 - 0x8fe30c23  dyld 97.1 (???) <89a0055b0e7ea2db881b73c6e63bc774> /usr/lib/dyld
0x90003000 - 0x901a3fe3  libSystem.B.dylib ??? (???) <7dc28e19e1aac16b29cbd7c5d9ce9638> /usr/lib/libSystem.B.dylib
0x901a5000 - 0x901d0ff7  libauto.dylib ??? (???) <a64d088b2d17e013b9ee5a08d3a20d33> /usr/lib/libauto.dylib
0x90ffc000 - 0x91001ff6  libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib
0x918d1000 - 0x91a19ff3  libicucore.A.dylib ??? (???) <bdab570d90979c4f601131d442f84720> /usr/lib/libicucore.A.dylib
0x91ac7000 - 0x91becff3  com.apple.CoreFoundation 6.5.7 (476.19) <dee0f0024f3bf976cfa0a0816e8aa338> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x91ff7000 - 0x920dafff  libobjc.A.dylib ??? (???) <a1d4be2eed463c6799b6a1447fde72ba> /usr/lib/libobjc.A.dylib
0x94ad2000 - 0x94addffb  libgcc_s.1.dylib ??? (???) <ea47fd375407f162c76d14d64ba246cd> /usr/lib/libgcc_s.1.dylib
0x961e2000 - 0x96249ffb  libstdc++.6.dylib ??? (???) <a4e9b10268b3ffac26d0296499b24e8e> /usr/lib/libstdc++.6.dylib
0xfffec000 - 0xfffeffff  libobjc.A.dylib ??? (???) /usr/lib/libobjc.A.dylib
0xffff8000 - 0xffff9703  libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib

@kencu
Copy link

kencu commented Oct 2, 2017

On MacPorts we use gcc6 and gcc7 in "GCC4ABI compatible mode" so that the new string calls are compatible with the older libstdc++ in the 10.5 system. Looking at the std::basic_string call just before the crash, that may be relevant.

@kencu
Copy link

kencu commented Oct 2, 2017

and a gdb run

h$ gdb fish
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:15:14 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries ........ done
unable to read unknown load command 0x24
unable to read unknown load command 0x26

(gdb) start
Breakpoint 1 at 0x76c64
Starting program: /opt/local/bin/fish 
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
unable to read unknown load command 0x24
unable to read unknown load command 0x26
Reading symbols for shared libraries +++++.+....... done

Breakpoint 1, 0x00076c64 in main ()
(gdb) c
Continuing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x900403d0 in realpath$DARWIN_EXTSN ()
(gdb) 

@ridiculousfish
Copy link
Member

Looks like realpath on 10.5 doesn't let you pass NULL as the second parameter. Try this patch?

diff --git a/src/wutil.cpp b/src/wutil.cpp
index a65a7648..06b144be 100644
--- a/src/wutil.cpp
+++ b/src/wutil.cpp
@@ -349,8 +349,8 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) {
     while (narrow_path.size() > 1 && narrow_path.at(narrow_path.size() - 1) == '/') {
         narrow_path.erase(narrow_path.size() - 1, 1);
     }
-
-    char *narrow_res = realpath(narrow_path.c_str(), NULL);
+    char tmpbuf[PATH_MAX];
+    char *narrow_res = realpath(narrow_path.c_str(), tmpbuf);
     if (narrow_res) {
         real_path.append(narrow_res);
     } else {

@kencu
Copy link

kencu commented Oct 5, 2017

Yep - that appears to have fixed it, with 15 minutes testing. How those dumps I posted led you right to this fix is something I would dearly love to understand someday ;>

Thanks. I'll put this patch into the MacPorts portfile for now, and we'll wait for a new version that I presume might include this later.

@floam
Copy link
Member

floam commented Oct 5, 2017

@kencu The stack trace shows that we're dying while trying realpath() in our wrealpath, because of something trying to access 0x0:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000

NULL is 0 - it's not doing what we think it should with that NULL argument.

@floam floam changed the title osx 10.5 ppc: fish bus error realpath(..., NULL) busted on OS X 10.5 Oct 5, 2017
@zanchey
Copy link
Member

zanchey commented Oct 5, 2017

We used to check for that, but it looks like it was removed in 7fd3079.

@floam
Copy link
Member

floam commented Oct 5, 2017

That looks like the perfect fix, removed. I think we should just revert it.

@floam
Copy link
Member

floam commented Oct 5, 2017

A bit more work than that might be needed, it looks like it was removed out of convenience to make some other changes on the other implementation easier.

@kencu
Copy link

kencu commented Oct 7, 2017

Just to confirm that with this patch and one extra #define, fish @2.6.0 now builds and runs correctly on systems back to and including MacOSX 10.4 Tiger.

@ridiculousfish
Copy link
Member

I made an attempt at fixing this via 05c0cb7. @kencu can you please confirm that this did the job? Thanks!!

@kencu
Copy link

kencu commented Oct 11, 2017

@ridiculousfish - the commit 1f130bcc9c939f33aa9df937e22a73a64d6cf853 builds and runs fine on 10.5 PPC with no patches. Thank you!

@zanchey zanchey added this to the fish 2.7.0 milestone Oct 13, 2017
@zanchey
Copy link
Member

zanchey commented Oct 13, 2017

Cherry-picked as 99b72c0 for 2.7.0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants