Opened 11 months ago

Last modified 10 months ago

#16171 new bug

[bfs_fuse] Segmentation fault: 11 on macOS

Reported by: diver Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: - General Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by diver)

hrev54280 on macOS 10.14.6.

I hacked up bfs_shell to build on macOS:

diff --git a/src/tools/bfs_shell/Jamfile b/src/tools/bfs_shell/Jamfile
index 80f4175323..373b3e3bf7 100644
--- a/src/tools/bfs_shell/Jamfile
+++ b/src/tools/bfs_shell/Jamfile
@@ -86,7 +86,7 @@ BuildPlatformMain <build>bfs_fuse
-	$(HOST_STATIC_LIBROOT) $(fsShellCommandLibs) fuse
+	$(HOST_STATIC_LIBROOT) $(fsShellCommandLibs) osxfuse
 SEARCH on [ FGristFiles DeviceOpener.cpp QueryParserUtils.cpp ]
diff --git a/src/tools/fs_shell/fuse.cpp b/src/tools/fs_shell/fuse.cpp
index d975e4e4cb..9b386696fb 100644
--- a/src/tools/fs_shell/fuse.cpp
+++ b/src/tools/fs_shell/fuse.cpp
@@ -5,7 +5,7 @@
 #define FUSE_USE_VERSION 27
-#include <fuse/fuse.h>
+#include <osxfuse/fuse/fuse.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <syslog.h>

However, when I try to use it it segfaults:

sudo objects/darwin/x86_64/release/tools/bfs_shell/bfs_fuse -d /dev/disk0s4 /Volumes/Haiku64
Segmentation fault: 11

Not sure what to do here.

Change History (11)

comment:1 by waddlesplash, 11 months ago

Can you attach the "Report" information from the macOS crash dialog, if you can get to that?

comment:2 by diver, 11 months ago

Found reports in /Users/diver/Library/Logs/DiagnosticReports/bfs_fuse_2020-05-30-232123_MacBookPro.crash

Process:               bfs_fuse [17249]
Path:                  /Users/USER/*/bfs_fuse
Identifier:            bfs_fuse
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        bash [17133]
Responsible:           bfs_fuse [17249]
User ID:               501

Date/Time:             2020-05-30 23:21:20.469 +0300
OS Version:            Mac OS X 10.14.6 (18G4032)
Report Version:        12
Anonymous UUID:        9C7F2D2A-A424-6A4F-8F19-406222CDB658

Time Awake Since Boot: 8900 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x00007ffee2136fe8
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [17249]

VM Regions Near 0x7ffee2136fe8:
    MALLOC_SMALL           00007ffd30800000-00007ffd31000000 [ 8192K] rw-/rwx SM=PRV  
--> STACK GUARD            00007ffede937000-00007ffee2137000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
    Stack                  00007ffee2137000-00007ffee2937000 [ 8192K] rw-/rwx SM=ALI  thread 0

Application Specific Information:
dyld2 mode

Thread 0 Crashed:: Dispatch queue:
0   bfs_fuse                      	0x000000010d3109c9 BPrivate::get_path(int, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 137
1   bfs_fuse                      	0x000000010d3130fb _haiku_build_openat + 75
2   bfs_fuse                      	0x000000010d30815b open + 219
3   bfs_fuse                      	0x000000010d3116ec open_file(char const*, int, int) + 252
4   bfs_fuse                      	0x000000010d313152 _haiku_build_openat + 162
5   bfs_fuse                      	0x000000010d30815b open + 219
6   bfs_fuse                      	0x000000010d3116ec open_file(char const*, int, int) + 252
7   bfs_fuse                      	0x000000010d313152 _haiku_build_openat + 162
8   bfs_fuse                      	0x000000010d30815b open + 219
9   bfs_fuse                      	0x000000010d3116ec open_file(char const*, int, int) + 252
10  bfs_fuse                      	0x000000010d313152 _haiku_build_openat + 162
509 bfs_fuse                      	0x000000010d30815b open + 219
510 bfs_fuse                      	0x000000010d3116ec open_file(char const*, int, int) + 252
511 bfs_fuse                      	0x000000010d313152 _haiku_build_openat + 162

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007ffee2137291  rcx: 0x00007fff7cefabbe  rdx: 0x00007ffee2137030
  rdi: 0x00007ffee2137030  rsi: 0x00007ffee2137291  rbp: 0x00007ffee2137020  rsp: 0x00007ffee2136ff0
   r8: 0x0000000000000002   r9: 0x0000000000000000  r10: 0x00007fff7cefabbe  r11: 0x0000000000000246
  r12: 0x0000000000000000  r13: 0x00007ffee2137291  r14: 0x00007ffee2137030  r15: 0x0000000000000012
  rip: 0x000000010d3109c9  rfl: 0x0000000000010202  cr2: 0x00007ffee2136fe8
Logical CPU:     6
Error Code:      0x00000006
Trap Number:     14

Binary Images:
       0x10d2c9000 -        0x10d31ffff +bfs_fuse (0) <CE7AC309-BA07-32BC-8C67-420D56087702> /Users/USER/*/bfs_fuse
       0x10d3e9000 -        0x10d3f9ffb +libz.1.dylib (0) <36B1ED83-DE21-3D70-875B-55C2E2DA1D8E> /opt/local/lib/libz.1.dylib
       0x10d402000 -        0x10d428fff +libosxfuse.2.dylib (12.7) <27C8C6FC-ABFF-38C9-AA75-DB041050A75D> /usr/local/lib/libosxfuse.2.dylib
       0x118ae1000 -        0x118b4b70f  dyld (655.1.1) <C192CA31-D059-3770-9882-D864FEFA0C96> /usr/lib/dyld
    0x7fff79d2f000 -     0x7fff79d30ffb  libSystem.B.dylib (1252.250.1) <71C12F94-14DC-379B-8D2A-0523D0A58245> /usr/lib/libSystem.B.dylib
    0x7fff79ff4000 -     0x7fff7a047ff7  libc++.1.dylib (400.9.4) <9A60A190-6C34-339F-BB3D-AACE942009A4> /usr/lib/libc++.1.dylib
    0x7fff7a048000 -     0x7fff7a05dff7  libc++abi.dylib (400.17) <38C09CED-9090-3719-90F3-04A2749F5428> /usr/lib/libc++abi.dylib
    0x7fff7a05e000 -     0x7fff7a05eff3  libcharset.1.dylib (51.200.6) <2A27E064-314C-359C-93FC-8A9B06206174> /usr/lib/libcharset.1.dylib
    0x7fff7a9b3000 -     0x7fff7aaa3fff  libiconv.2.dylib (51.200.6) <2047C9B7-3F74-3A95-810D-2ED8F0475A99> /usr/lib/libiconv.2.dylib
    0x7fff7b5e8000 -     0x7fff7bd70fd7  libobjc.A.dylib (756.2) <20942D4E-CE6F-376A-8BCD-016F88E4BFD5> /usr/lib/libobjc.A.dylib
    0x7fff7cc45000 -     0x7fff7cc49ff3  libcache.dylib (81) <1987D1E1-DB11-3291-B12A-EBD55848E02D> /usr/lib/system/libcache.dylib
    0x7fff7cc4a000 -     0x7fff7cc54ff3  libcommonCrypto.dylib (60118.250.2) <1765BB6E-6784-3653-B16B-CB839721DC9A> /usr/lib/system/libcommonCrypto.dylib
    0x7fff7cc55000 -     0x7fff7cc5cff7  libcompiler_rt.dylib (63.4) <5212BA7B-B7EA-37B4-AF6E-AC4F507EDFB8> /usr/lib/system/libcompiler_rt.dylib
    0x7fff7cc5d000 -     0x7fff7cc66ff7  libcopyfile.dylib (146.250.1) <98CD00CD-9B91-3B5C-A9DB-842638050FA8> /usr/lib/system/libcopyfile.dylib
    0x7fff7cc67000 -     0x7fff7ccebfc3  libcorecrypto.dylib (602.260.2) <01464D24-570C-3B83-9D18-467769E0FCDD> /usr/lib/system/libcorecrypto.dylib
    0x7fff7cd72000 -     0x7fff7cdabff7  libdispatch.dylib (1008.270.1) <97273678-E94C-3C8C-89F6-2E2020F4B43B> /usr/lib/system/libdispatch.dylib
    0x7fff7cdac000 -     0x7fff7cdd8ff7  libdyld.dylib (655.1.1) <002418CC-AD11-3D10-865B-015591D24E6C> /usr/lib/system/libdyld.dylib
    0x7fff7cdd9000 -     0x7fff7cdd9ffb  libkeymgr.dylib (30) <0D0F9CA2-8D5A-3273-8723-59987B5827F2> /usr/lib/system/libkeymgr.dylib
    0x7fff7cde7000 -     0x7fff7cde7ff7  liblaunch.dylib (1336.261.4) <AEBAE502-D691-3D26-BFD9-CB41090C0360> /usr/lib/system/liblaunch.dylib
    0x7fff7cde8000 -     0x7fff7cdedfff  libmacho.dylib (927.0.3) <A377D608-77AB-3F6E-90F0-B4F251A5C12F> /usr/lib/system/libmacho.dylib
    0x7fff7cdee000 -     0x7fff7cdf0ff7  libquarantine.dylib (86.270.1) <3F36A3D6-9606-3D90-B520-809BAEF981C3> /usr/lib/system/libquarantine.dylib
    0x7fff7cdf1000 -     0x7fff7cdf2ff7  libremovefile.dylib (45.200.2) <9FBEB2FF-EEBE-31BC-BCFC-C71F8D0E99B6> /usr/lib/system/libremovefile.dylib
    0x7fff7cdf3000 -     0x7fff7ce0aff3  libsystem_asl.dylib (356.200.4) <A62A7249-38B8-33FA-9875-F1852590796C> /usr/lib/system/libsystem_asl.dylib
    0x7fff7ce0b000 -     0x7fff7ce0bff7  libsystem_blocks.dylib (73) <A453E8EE-860D-3CED-B5DC-BE54E9DB4348> /usr/lib/system/libsystem_blocks.dylib
    0x7fff7ce0c000 -     0x7fff7ce93fff  libsystem_c.dylib (1272.250.1) <7EDACF78-2FA3-35B8-B051-D70475A35117> /usr/lib/system/libsystem_c.dylib
    0x7fff7ce94000 -     0x7fff7ce97ffb  libsystem_configuration.dylib (963.270.3) <2B4A836D-68A4-33E6-8D48-CD4486B03387> /usr/lib/system/libsystem_configuration.dylib
    0x7fff7ce98000 -     0x7fff7ce9bff7  libsystem_coreservices.dylib (66) <719F75A4-74C5-3BA6-A09E-0C5A3E5889D7> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff7ce9c000 -     0x7fff7cea2fff  libsystem_darwin.dylib (1272.250.1) <EC9B39A5-9592-3577-8997-7DC721D20D8C> /usr/lib/system/libsystem_darwin.dylib
    0x7fff7cea3000 -     0x7fff7cea9ffb  libsystem_dnssd.dylib (878.270.3) <D5352ABD-0311-3327-8E64-93F29EB19BF1> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff7ceaa000 -     0x7fff7cef5ffb  libsystem_info.dylib (517.200.9) <D09D5AE0-2FDC-3A6D-93EC-729F931B1457> /usr/lib/system/libsystem_info.dylib
    0x7fff7cef6000 -     0x7fff7cf1eff7  libsystem_kernel.dylib (4903.278.28) <5B6BB78A-7845-3A31-B87E-03E18DDE4D86> /usr/lib/system/libsystem_kernel.dylib
    0x7fff7cf1f000 -     0x7fff7cf6aff7  libsystem_m.dylib (3158.200.7) <F19B6DB7-014F-3820-831F-389CCDA06EF6> /usr/lib/system/libsystem_m.dylib
    0x7fff7cf6b000 -     0x7fff7cf95fff  libsystem_malloc.dylib (166.270.1) <011F3AD0-8E6A-3A89-AE64-6E5F6840F30A> /usr/lib/system/libsystem_malloc.dylib
    0x7fff7cf96000 -     0x7fff7cfa0ff7  libsystem_networkextension.dylib (767.250.2) <FF06F13A-AEFE-3A27-A073-910EF78AEA36> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff7cfa1000 -     0x7fff7cfa8fff  libsystem_notify.dylib (172.200.21) <145B5CFC-CF73-33CE-BD3D-E8DDE268FFDE> /usr/lib/system/libsystem_notify.dylib
    0x7fff7cfa9000 -     0x7fff7cfb2fef  libsystem_platform.dylib (177.270.1) <9D1FE5E4-EB7D-3B3F-A8D1-A96D9CF1348C> /usr/lib/system/libsystem_platform.dylib
    0x7fff7cfb3000 -     0x7fff7cfbdff7  libsystem_pthread.dylib (330.250.2) <2D5C08FF-484F-3D59-9132-CE1DCB3F76D7> /usr/lib/system/libsystem_pthread.dylib
    0x7fff7cfbe000 -     0x7fff7cfc1ff7  libsystem_sandbox.dylib (851.270.1) <9494594B-5199-3186-82AB-5FF8BED6EE16> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff7cfc2000 -     0x7fff7cfc4ff3  libsystem_secinit.dylib (30.260.2) <EF1EA47B-7B22-35E8-BD9B-F7003DCB96AE> /usr/lib/system/libsystem_secinit.dylib
    0x7fff7cfc5000 -     0x7fff7cfccff3  libsystem_symptoms.dylib (820.267.1) <03F1C2DD-0F5A-3D9D-88F6-B26C0F94EB52> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff7cfcd000 -     0x7fff7cfe2ff7  libsystem_trace.dylib (906.260.2) <12C1B9A2-39D6-3428-AE60-2303BD201A57> /usr/lib/system/libsystem_trace.dylib
    0x7fff7cfe4000 -     0x7fff7cfe9ffb  libunwind.dylib (35.4) <24A97A67-F017-3CFC-B0D0-6BD0224B1336> /usr/lib/system/libunwind.dylib
    0x7fff7cfea000 -     0x7fff7d019fff  libxpc.dylib (1336.261.4) <7A9D1BF7-F17F-3B87-9373-B0079544E8C5> /usr/lib/system/libxpc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 4948
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=235.8M resident=0K(0%) swapped_out_or_unallocated=235.8M(100%)
Writable regions: Total=18.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=18.9M(100%)
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                    8K        1 
MALLOC                            10.1M        7 
MALLOC guard page                   16K        3 
STACK GUARD                       56.0M        1 
Stack                             8192K        1 
__DATA                            2992K       44 
__LINKEDIT                       222.6M        5 
__TEXT                            13.1M       43 
shared memory                        8K        2 
===========                     =======  ======= 
TOTAL                            312.8M      107 

Last edited 11 months ago by diver (previous) (diff)

comment:3 by diver, 11 months ago

I disabled "System Integrity Protection" but that didn't help.

comment:4 by X512, 11 months ago

495 bfs_fuse 0x000000010d3116ec open_file(char const*, int, int) + 252

496 bfs_fuse 0x000000010d313152 _haiku_build_openat + 162

497 bfs_fuse 0x000000010d30815b open + 219

Seems like infinite recursion.

Last edited 11 months ago by X512 (previous) (diff)

comment:5 by diver, 11 months ago

diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         849.0 GB   disk0s2
   3:       Microsoft Basic Data Windows10               101.0 GB   disk0s3
   4: 42465331-3BA3-10F1-802A-4861696B7521               49.9 GB    disk0s4

I'm trying to mount the last partition (4).

comment:6 by diver, 10 months ago

sudo objects/darwin/x86_64/release/tools/bfs_shell/bfs_shell /dev/rdisk0s4

bfs: Disk size (49861647360 bytes) < file system size (49865031680 bytes)!
bfs: Mount:207: Invalid argument
bfs: bfs_mount:184: Invalid argument
Error: Mounting FS failed: Invalid argument

comment:7 by diver, 10 months ago

Seems to be related to #16113. Could be a regression then.

comment:8 by diver, 10 months ago

Description: modified (diff)

comment:9 by madmax, 10 months ago

Two issues here. The Disk size < file system size is #16113 for a different host OS and disappears with a fake 1 head, 1 sector per track and mediaSize (the number of blocks for darwin) cylinders geometry.

The infinite loop comes from: _haiku_build_openat -> _kern_open -> open_file -> open. For some reason that last open is the one from libroot/function_remapper.cpp, that calls _haiku_build_open, that calls _haiku_build_openat and we get the loop.

This doesn't happen to me (Linux, not MacOS) and does not happen to diver with bfs_shell, where the open in open_file is not the one from function_remapper.cpp.

Maybe just some define or build system constant?

comment:10 by diver, 10 months ago

Interestingly, this is yes to work about 15 months ago when I last tried it.

comment:11 by Alexco, 10 months ago

Finally, I had a couple of minutes of free time to spend on the issue. Using the debugger you can see that it creates an endless loop in "errors.cpp", int *_haiku_build_errno(). It will loop forever (until seg fault) with this line here

int currentErrno = errno;

Compiler hint is "All paths through this function will call itself. This is because of this define in headers/build/os/support/Errors.h

	#undef errno
	#define errno (*_haiku_build_errno())

Strange thing that this does not happen on FreeBSD for me. So something is wrong with the darwin build system, I guess. Missing defines, maybe?

Note: See TracTickets for help on using tickets.