leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
450 stars 50 forks source link

Filters hang in a loop without returning #18

Closed larryhynes closed 7 years ago

larryhynes commented 7 years ago

(Again, this may be OSX-specific, and may well be related to the renowned brokenness of poll on OSX.)

No filter, that I've tried, on any type/subtype, will return its output to the screen and allow mshow to continue processing; it just hangs indefinitely and has to be aborted.

A trace reveals that the filter does actually return its output (the line:

read(0x5, "This is a test, with some html formatting, and an attachment.\n\n\n\0", 0x200)        = 64 0

below), but for some reason it doesn't make it as far as the tty. Example, using the 'default' text/html filter:

SYSCALL(args)        = return
thread_selfid(0x0, 0x0, 0x0)         = 3264522 0
csops(0x0, 0x0, 0x7FFF56447228)      = 0 0
issetugid(0x0, 0x0, 0x7FFF56447228)      = 0 0
shared_region_check_np(0x7FFF56445168, 0x0, 0x7FFF56447228)      = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF564462F8, 0x7FFF56447228)         = 0 0
open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0)         = 3 0
pread(0x3, "\312\376\272\276\0", 0x1000, 0x0)        = 4096 0
pread(0x3, "\317\372\355\376\a\0", 0x1000, 0x1000)       = 4096 0
fcntl(0x3, 0x3D, 0x7FFF56444660)         = 0 0
mmap(0x1097CB000, 0x2000, 0x5, 0x12, 0x3, 0x1000)        = 0x1097CB000 0
mmap(0x1097CD000, 0x1000, 0x3, 0x12, 0x3, 0x3000)        = 0x1097CD000 0
mmap(0x1097CE000, 0x1FC0, 0x1, 0x12, 0x3, 0x4000)        = 0x1097CE000 0
close(0x3)       = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF56446C78, 0x1)        = 0 0
stat64("/usr/lib/libiconv.2.dylib\0", 0x7FFF56446118, 0x1)       = 0 0
stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF56446118, 0x1)      = 0 0
stat64("/usr/lib/system/libcache.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libcopyfile.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libcorecrypto.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libdispatch.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libdyld.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libkeymgr.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/liblaunch.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libmacho.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libquarantine.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libremovefile.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_asl.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libsystem_c.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libsystem_configuration.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libsystem_coreservices.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libsystem_coretls.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libsystem_info.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libsystem_m.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libsystem_malloc.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libsystem_network.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_networkextension.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libsystem_notify.dylib\0", 0x7FFF56445C28, 0x1)      = 0 0
stat64("/usr/lib/system/libsystem_platform.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libsystem_pthread.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_secinit.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libsystem_stats.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libsystem_trace.dylib\0", 0x7FFF56445C28, 0x1)       = 0 0
stat64("/usr/lib/system/libunc.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/system/libunwind.dylib\0", 0x7FFF56445C28, 0x1)         = 0 0
stat64("/usr/lib/system/libxpc.dylib\0", 0x7FFF56445C28, 0x1)        = 0 0
stat64("/usr/lib/libobjc.A.dylib\0", 0x7FFF56444F08, 0x1)        = 0 0
stat64("/usr/lib/libauto.dylib\0", 0x7FFF56444F08, 0x1)      = 0 0
stat64("/usr/lib/libc++abi.dylib\0", 0x7FFF56444DE8, 0x1)        = 0 0
stat64("/usr/lib/libc++.1.dylib\0", 0x7FFF56444DE8, 0x1)         = 0 0
stat64("/usr/lib/libDiagnosticMessagesClient.dylib\0", 0x7FFF56444CD8, 0x1)      = 0 0
getpid(0x7FFF8ED9B740, 0x7FFF56444CD8, 0x1)      = 36802 0
open("/dev/dtracehelper\0", 0x2, 0x7FFF56447120)         = 3 0
ioctl(0x3, 0x80086804, 0x7FFF564470A8)       = 0 0
close(0x3)       = 0 0
sysctl(0x7FFF56446748, 0x2, 0x7FFF56446758)      = 0 0
thread_selfid(0x7FFF56446748, 0x2, 0x7FFF56446758)       = 3264522 0
bsdthread_register(0x7FFF8E7FE3E0, 0x7FFF8E7FE3D0, 0x2000)       = 1073741855 0
mprotect(0x1097C8000, 0x88, 0x1)         = 0 0
mprotect(0x1097D0000, 0x1000, 0x0)       = 0 0
mprotect(0x1097E6000, 0x1000, 0x0)       = 0 0
mprotect(0x1097E7000, 0x1000, 0x0)       = 0 0
mprotect(0x1097FD000, 0x1000, 0x0)       = 0 0
mprotect(0x1097CA000, 0x1000, 0x1)       = 0 0
mprotect(0x1097C8000, 0x88, 0x3)         = 0 0
mprotect(0x1097C8000, 0x88, 0x1)         = 0 0
issetugid(0x1097C8000, 0x88, 0x1)        = 0 0
getpid(0x1097C8000, 0x88, 0x1)       = 36802 0
stat64("/AppleInternal/XBS/.isChrooted\0", 0x7FFF564466A8, 0x1)      = -1 Err#2
stat64("/BuildSupport/makeProject\0", 0x7FFF564466A8, 0x1)       = -1 Err#2
stat64("/AppleInternal\0", 0x7FFF56446618, 0x1)      = -1 Err#2
csops(0x8FC2, 0x7, 0x7FFF56446140)       = -1 Err#22
csops(0x8FC2, 0x7, 0x7FFF56445A20)       = -1 Err#22
open("/Users/larry/.mblaze/filter\0", 0x0, 0x8)      = 3 0
read(0x3, "#:text/plain: t-prot --body --bigq -mces --diff --fixind -l -L ~/t-prot\ntext/html: lynx -dump -stdin -nomargins ${PIPE_CHARSET:+-assume_charset $PIPE_CHARSET}\n#:image: file -b -\n\0", 0x1000)         = 178 0
read(0x3, "\0", 0x1F4E)      = 0 0
close(0x3)       = 0 0
ioctl(0x0, 0x4004667A, 0x7FFF56447ACC)       = 0 0
open("/Users/larry/.mblaze/seq\0", 0x0, 0x7FFF56447690)      = 3 0
fstat64(0x3, 0x7FFF56447570, 0x7FFF56447690)         = 0 0
read(0x3, "/Users/larry/.mail/logs/cur/1490538571.34923_0.sutro.larryhynes.com:2,\n/Users/larry/.mail/logs/cur/1490538572.34927_0.sutro.larryhynes.com:2,\n/Users/larry/.mail/obsd/cur/1490538571.34921_0.sutro.larryhynes.com:2,\n/Users/larry/.mail/obsd/cur/1490538572.3492", 0x11C)      = 284 0
close(0x3)       = 0 0
readlink("/Users/larry/.mblaze/cur\0", 0x1097C0F40, 0x3FF)       = 59 0
readlink("/Users/larry/.mblaze/cur\0", 0x1097C0F40, 0x3FF)       = 59 0
open(".mail/inbox//cur/1490462878.95690_0.sutro.larryhynes.com:2,\0", 0x0, 0x0)      = 3 0
fstat64(0x3, 0x7FFF56446510, 0x0)        = 0 0
read(0x3, "Return-Path: xxx@xxx.com\nDelivered-To: yyy@yyy.com\nReceived: from forward4m.xxx.net (forward4m.xxx.net [1.2.3.4])\n\tby yyy.com (OpenSMTPD) with ESMTPS id 1f53a4de (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO", 0x14E7A)      = 85626 0
close(0x3)       = 0 0
getrlimit(0x1008, 0x7FFF564463B0, 0x14E7A)       = 0 0
fstat64(0x1, 0x7FFF56446448, 0x14E7A)        = 0 0
pipe(0x1, 0x7FFF56446448, 0x14E7A)       = 3 0
pipe(0x1, 0x7FFF56446448, 0x14E7A)       = 5 0
fork()       = 36803 0
close(0x3)       = 0 0
close(0x6)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
write(0x4, "<div>This is a test, with some <strong>html</strong> formatting, and an attachment.</div>ZUCS01GOrZ\ntJZDL2Kh4RrqFtcyrZVVe7QSge99pcZ46HpzZEWbd4cr1pq+LY3N1xBWlYN4upw0irO0CoMd0VY6\nWO4mmwBxxtA7ME8y+sodLvHc3n2s8bFxH/1JRNWdTFHSV7O7sjBt/kTR6MxvHg8nGwEIA/7gtscu\nqT", 0x59)      = 89 0
close(0x4)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
dtrace: 151721 dynamic variable drops with non-empty dirty list
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "This is a test, with some html formatting, and an attachment.\n\n\n\0", 0x200)        = 64 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0
poll(0x7FFF564453E0, 0x2, 0xFFFFFFFF)        = 1 0
read(0x5, "\0", 0x200)       = 0 0

(it just continues like this until abort.)

leahneukirchen commented 7 years ago

Does changing

                        else if (ret < 0)
                                close(fds[0].fd);

in filter.c to use <= fix it?

larryhynes commented 7 years ago

Yes. Yes it does. :smile: