Opened 4 years ago

Closed 4 years ago

#59678 closed defect (fixed)

fftw-3 @3.3.8 (math): on macOS Catalina (only) segmentation fault for 2^N with N=12

Reported by: sa35 Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc: astroboylrx (Rixin Li)
Port: fftw-3

Description

On macOS Catalina 10.15.1 I get a segmentation fault for 2 to power N with N=12. If I am downloading fftw3 source (3.3.8) and compile it myself, this is not the case. Hence I assume something is wrong with the fftw-3 package.

Attachments (2)

fftw3_bare.tar.gz (2.1 KB) - added by sa35 4 years ago.
Little example I used to reproduce the seg.fault
fftw_crash.c (286 bytes) - added by volgy (Peter Volgyesi) 4 years ago.
Minimal program demonstrating the crash.

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by sa35

Attachment: fftw3_bare.tar.gz added

Little example I used to reproduce the seg.fault

comment:1 Changed 4 years ago by jmroot (Joshua Root)

How did you configure it when you built it yourself?

comment:2 Changed 4 years ago by sa35

I just used the automake tool chain:

configure 
make 
make install
Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 4 years ago by jmroot (Joshua Root)

Yes but what configure options and CFLAGS etc did you use? That's going to be the difference between your build and one done with MacPorts.

comment:4 Changed 4 years ago by sa35

To compile fftw I just configured it with

--enable-shared

and nothing else.

Version 0, edited 4 years ago by sa35 (next)

Changed 4 years ago by volgy (Peter Volgyesi)

Attachment: fftw_crash.c added

Minimal program demonstrating the crash.

comment:5 Changed 4 years ago by volgy (Peter Volgyesi)

I have a similar problem with several packages using fftw-3 or fftw-3-single (3.3.8) on Catalina. I created a minimal program to trigger the crash (Abort trap: 6), see the attached file (fftw_crash.c). The FFTW library corrupts the stack during the planning phase (fftw_plan_dft_1d)

It seems the problem is with the binary distribution, only. Installing the same package from source (port -s install fftw-3) resolves the problem. Here is some information on my system:

$ uname -a
Darwin watney.local 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov  9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

$ /usr/bin/xcodebuild -version
Xcode 11.3
Build version 11C29

comment:6 Changed 4 years ago by astroboylrx (Rixin Li)

Cc: astroboylrx added

comment:7 Changed 4 years ago by astroboylrx (Rixin Li)

I've countered this issue, too. I don't know whose bug it is, either fftw-3 or Catalina. But there are reports from other softwares with this issue, e.g., ffmpeg https://trac.ffmpeg.org/ticket/8073

If you use LLDB to debug the program you attached (see below), you'll see it's a general protection fault: code=EXC_I386_GPFLT (some explanations here https://stackoverflow.com/a/19652167/4009531). And the error is called libdyld.dylib`stack_not_16_byte_aligned_error. The 12th comment https://trac.ffmpeg.org/ticket/8073#comment:12 in the ffmpeg bug tracker forum explained a little bit: "Stack checking is on by default on all platforms to prevent memory corruptions. (25859140)". And this post https://artempyanykh.com/blog/posts/2019-01-16-assembling-fizz-buzz.html#stack-align also explains a little bit: "When memory is not aligned the processor generates a general protection exception that translates to a segmentation fault."

➜  ~/build $ lldb ./fftw3_test
(lldb) target create "./fftw3_test"
Current executable set to './fftw3_test' (x86_64).
(lldb) run
Process 80432 launched: '/Users/rixin/Downloads/fftw3_bare/build/fftw3_test' (x86_64)
debug> N=4096, offset=0
Process 80432 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00007fff655352be libdyld.dylib`stack_not_16_byte_aligned_error
libdyld.dylib`stack_not_16_byte_aligned_error:
->  0x7fff655352be <+0>: movdqa %xmm0, (%rsp)
    0x7fff655352c3 <+5>: int3
    0x7fff655352c4 <+6>: nop
    0x7fff655352c5 <+7>: nop
Target 0: (fftw3_test) stopped.

Hopefully, my search can contribute more information to the discussions here. Sadly, there is no listed maintainer for this port. I've tried to Google this error but got no luck. Thanks a lot for mentioning that compiling fftw from the source could work. I will try that.

comment:8 Changed 4 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Owner: set to MarcusCalhoun-Lopez
Status: newaccepted

comment:9 Changed 4 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Resolution: fixed
Status: acceptedclosed

In 86e82cd007b387d3b3762654ce670db810602324/macports-ports (master):

fftw-3: use xcode_workaround PG

Fixes #59678

Note: See TracTickets for help on using tickets.