GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Tutorial case `backwardFacingStep2D` hangs forever after compiling with Xcode CLT >= 14.3 · Issue #8 · BrushXue/OpenFOAM-AppleM1

Tutorial case backwardFacingStep2D hangs forever after compiling with Xcode CLT >= 14.3 #8

New issue
Copy link
New issue
Copy link
Closed
Closed
Tutorial case backwardFacingStep2D hangs forever after compiling with Xcode CLT >= 14.3#8
Copy link

Description

@gerlero
gerlero
opened on Jun 21, 2023
Issue body actions

$FOAM_TUTORIALS/incompressible/simpleFoam/backwardFacingStep2D gets stuck before the completing the first timestep after OpenFOAM is compiled with Xcode Command Line Tools >= 14.3 (gerlero/openfoam-app#160). Apparently, it hangs between the processing these lines:

    #includeFunc "pressureCoefficient"
    #includeFunc "sample"

in the controlDict.

I tried with your repo to see if I it was me who was doing something wrong, but after following the build instructions here I still run into the same problem. Do you have an idea on what could be going on here?

EDIT: removing mention of "Clang 14" as it might be confusing (Xcode CLT < 14.3 also comes with Clang 14)

Activity

Next
  1. gerlero commented on Jun 21, 2023

    @gerlero
    gerlero
    on Jun 21, 2023
    ContributorAuthor
    More actions

    BTW for anyone else seeing this, a workaround is to use Xcode Command Line Tools 14.2 to compile OpenFOAM.

  2. BrushXue commented on Jun 21, 2023

    @BrushXue
    BrushXue
    on Jun 21, 2023
    Owner
    More actions

    Is that a ARM-specific problem or universal? I tested it with Xcode 14.0 on a x86 Hackintosh and I don't have any problem.

  3. gerlero commented on Jun 21, 2023

    @gerlero
    gerlero
    on Jun 21, 2023
    ContributorAuthor
    More actions

    Is that a ARM-specific problem or universal?

    Good question. My Intel builds so far are using CLT 13.2 on Big Sur, so it's expected that those are not affected. I'll try a compile with Xcode CLT 14.3 (Clang 14) on Intel Ventura to see what happens.

    Xcode 14.0

    Just to note, Xcode CLT 14.3 and 14.3.1 seem to trigger the problem (on Ventura at least). 14.2 and before work fine.

  4. gerlero commented on Jun 22, 2023

    @gerlero
    gerlero
    on Jun 22, 2023
    ContributorAuthor
    More actions

    I'm back with some results (macOS Ventura 13.4 on Intel, Xcode Command Line Tools 14.3.1.0.1.1683849156):

    OpenFOAM v2212

    • build OK
    • backwardFacingStep2D runs OK

    OpenFOAM v2206

    wmake meshTools
        Ctoo: geompack.C
    clang: error: unable to execute command: Segmentation fault: 11
    clang: error: clang frontend command failed due to signal (use -v to see invocation)
    Apple clang version 14.0.0 (clang-1400.0.29.202)
    Target: x86_64-apple-darwin22.5.0
    Thread model: posix
    InstalledDir: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    clang: note: diagnostic msg: 
    ********************
    
    PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
    Preprocessed source(s) and associated run script(s) are located at:
    clang: note: diagnostic msg: /var/folders/2p/6fxzqc0d64xbxvt_6n0252k40000gn/T/geompack-20d5e5.cpp
    clang: note: diagnostic msg: /var/folders/2p/6fxzqc0d64xbxvt_6n0252k40000gn/T/geompack-20d5e5.sh
    clang: note: diagnostic msg: Crash backtrace is located in
    clang: note: diagnostic msg: /Users/runner/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
    clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
    clang: note: diagnostic msg: 
    
    ********************
    

    OpenFOAM v2112

    Similar errors to v2206

    Conclusion

    Seems only affect Apple silicon as of v2212 (and not Intel). IDK what's going in with v2206 and v2112 making the compiler crash, but that's a different (although possibly related) issue.

    The Clang bundled in Xcode CLT 14.3 seems to have enabled floating point exception support on Apple silicon (as it no longer emits the "Overriding currently unsupported..." compile warnings), so this issue might have something to do with that (OpenFOAM issue about FPE on arm64)

    EDIT: disregard these results!. This was actually built with Xcode 14.2, as can be clearly seen in the log output. My bad! This doesn't say anything on whether the problem also affects Intel or not.

  5. BrushXue commented on Jun 22, 2023

    @BrushXue
    BrushXue
    on Jun 22, 2023
    Owner
    More actions

    I’ve seen this geompack.C patch before.
    https://github.com/mrklein/openfoam-os-x/blob/274546a8aec2911e9078e3b070d2f028460b4f51/OpenFOAM-v2206.patch#L195
    Maybe it’s related to this issue.

    Reacted by Gabriel Gerlero
  6. gerlero commented on Jun 22, 2023

    @gerlero
    gerlero
    on Jun 22, 2023
    ContributorAuthor
    More actions

    Good find. That patch looks like it's worth a shot.

  7. gerlero commented on Jun 23, 2023

    @gerlero
    gerlero
    on Jun 23, 2023
    ContributorAuthor
    More actions

    Well, looks like that patch has been upstreamed (https://develop.openfoam.com/Development/openfoam/-/issues/2555), and is already part of v2212. This likely explains why earlier OpenFOAM versions fail to compile on Intel, but it won't do anything for this issue.

    EDIT: https://develop.openfoam.com/Development/openfoam/-/issues/2555 directly mentions the compiler segfaults, so confirmed that that's the cause of the build failures on Intel

  8. gerlero commented on Jul 5, 2023

    @gerlero
    gerlero
    on Jul 5, 2023
    ContributorAuthor
    More actions

    OpenFOAM v2306 seems to also be affected by this. @BrushXue what version of Xcode/CLT are you using to build? Are you able to confirm this issue?

  9. BrushXue commented on Jul 5, 2023

    @BrushXue
    BrushXue
    on Jul 5, 2023
    Owner
    More actions

    I'm staying in Monterey because Ventura drains my battery quickly. I didn't encounter your problem.

    $ clang --version
    Apple clang version 14.0.0 (clang-1400.0.29.202)
    Target: arm64-apple-darwin21.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

    Xcode 14.3 dropped Monterey support.

  10. gerlero commented on Jul 5, 2023

    @gerlero
    gerlero
    on Jul 5, 2023
    ContributorAuthor
    More actions

    Thanks. This is the offending version on Ventura:

    Apple clang version 14.0.3 (clang-1403.0.22.14.1)
    Target: arm64-apple-darwin22.5.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    

    I assume yours is the latest clang available for Monterey? Then, this issue affects only macOS Ventura on Apple silicon.

    I'm fairly confident in pointing the finger at FPE support (which didn't work at all with previous Clang versions) but I've tried every way I could think of disabling that and the problem always persists.

    EDIT: saw your edit. Since CLT 14.3 is Ventura-only then this issue can only affect this macOS version.

  11. BrushXue commented on Jul 5, 2023

    @BrushXue
    BrushXue
    on Jul 5, 2023
    Owner
    More actions

    What if you patch these lines? (I removed these recently because I thought export FOAM_SIGFPE=false was enough to disable sigfpe)

    OpenFOAM-AppleM1/M1.patch

    Lines 44 to 83 in 5295d03

    diff --git a/src/OSspecific/POSIX/signals/sigFpe.C b/src/OSspecific/POSIX/signals/sigFpe.C
    index 29a95852..bc284b9b 100644
    --- a/src/OSspecific/POSIX/signals/sigFpe.C
    +++ b/src/OSspecific/POSIX/signals/sigFpe.C
    @@ -44,7 +44,7 @@ License
    #include <malloc.h>
    #endif
    -#ifdef __APPLE__
    +#if defined(__APPLE__) && defined(__x86_64__)
    #include "feexceptErsatz.H"
    #endif
    @@ -117,7 +117,7 @@ void* Foam::sigFpe::mallocNan(size_t size)
    void Foam::sigFpe::sigHandler(int)
    {
    - #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
    + #if (defined(__linux__) && defined(__GNUC__)) || (defined(__APPLE__) && defined(__x86_64__))
    resetHandler("SIGFPE", SIGFPE);
    @@ -184,7 +184,7 @@ void Foam::sigFpe::set(bool verbose)
    {
    if (!sigActive_ && requested())
    {
    - #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
    + #if (defined(__linux__) && defined(__GNUC__)) || (defined(__APPLE__) && defined(__x86_64__))
    feenableexcept
    (
    @@ -240,7 +240,7 @@ void Foam::sigFpe::set(bool verbose)
    void Foam::sigFpe::unset(bool verbose)
    {
    - #if (defined(__linux__) && defined(__GNUC__)) || defined(__APPLE__)
    + #if (defined(__linux__) && defined(__GNUC__)) || (defined(__APPLE__) && defined(__x86_64__))
    if (sigActive_)
    {
    if (verbose)

  12. gerlero commented on Jul 5, 2023

    @gerlero
    gerlero
    on Jul 5, 2023
    ContributorAuthor
    More actions

    Will try and report back.

    I thought export FOAM_SIGFPE=false was enough to disable sigfpe

    It's enough to disable it at runtime, but doing that doesn't seem to help for this particular issue. Setting sigFpe 0; in etc/controlDict should do the same (tried that too but still no luck).

    The issue behaves like it's a compiler thing, so I've also tried disabling FPE support at the compiler level by removing the -ftrapping-math flag from the darwin64Clang (or replacing it with -fno-trapping-math, which should be the default) before building OpenFOAM. That didn't fix it either, even when running with FOAM_SIGFPE=false.

  13. BrushXue commented on Jul 5, 2023

    @BrushXue
    BrushXue
    on Jul 5, 2023
    Owner
    More actions

    Do you think if this is related to your issue?
    python/cpython#97524 (comment)

  14. gerlero commented on Jul 5, 2023

    @gerlero
    gerlero
    on Jul 5, 2023
    ContributorAuthor
    More actions

    Do you think if this is related to your issue?
    python/cpython#97524 (comment)

    Not sure. IIRC I've been seeing those ld warnings for a while (~ since Ventura came out), while this problem is more recent...

    EDIT: typo

  15. BrushXue commented on Jul 5, 2023

    @BrushXue
    BrushXue
    on Jul 5, 2023
    Owner
    More actions

    Yes I've been using -Wl,-w to suppress these warnings for a while. But the compiler changed it behavior again since 14.3.

  16. 28 remaining items

  17. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    Here's the lldb log

    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
        frame #0: 0x00000001000465c0 simpleFoam`Foam::min(s1=0.065987628869999995, s2=0.067035051550000002) at doubleFloat.H:55:1
       52  	}
       53
       54
    -> 55  	MAXMINPOW(double, double, double)
       56  	MAXMINPOW(double, double, float)
       57  	MAXMINPOW(double, float, double)
       58  	MAXMINPOW(double, double, int)
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (double) $0 = 0.065987628869999995
    
        frame #0: 0x000000010304a84c libfiniteVolume.dylib`Foam::minOp<double>::operator()(this=0x000000016fdf836f, x=0x000000016fdf8650, y=0x00000001180e3480) const at ops.H:218:1
       215 	Op(cmptPow, cmptPow(x, y))
       216 	Op(cmptDivide, cmptDivide(x, y))
       217 	Op(stabilise, stabilise(x, y))
    -> 218 	Op(min, min(x, y))
       219 	Op(max, max(x, y))
       220 	Op(minMagSqr, (magSqr(x) <= magSqr(y) ? x : y))
       221 	Op(maxMagSqr, (magSqr(x) >= magSqr(y) ? x : y))
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (double) $1 = 0.065987628869999995
    
        frame #0: 0x000000010304a7fc libfiniteVolume.dylib`void Foam::VectorSpaceOps<(unsigned char)3, (unsigned char)0>::op<Foam::Vector<double>, Foam::VectorSpace<Foam::Vector<double>, double, (unsigned char)3>, Foam::minOp<double>>(vs=0x000000016fdf83f8, vs1=0x000000016fdf8650, vs2=0x00000001180e3480, o=minOp<double> @ 0x000000016fdf836f) at VectorSpaceOps.H:87:9
       84  	    template<class V, class V1, class Op>
       85  	    static inline void op(V& vs, const V1& vs1, const V1& vs2, Op o)
       86  	    {
    -> 87  	        vs.v_[I] = o(vs1.v_[I], vs2.v_[I]);
       88  	        VectorSpaceOps<N, I+1>::op(vs, vs1, vs2, o);
       89  	    }
       90  	};
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x000000010304a7c8 libfiniteVolume.dylib`Foam::Vector<double> Foam::min<Foam::Vector<double>, double, (unsigned char)3>(vs1=0x000000016fdf8650, vs2=0x00000001180e3480) at VectorSpaceI.H:666:5
       663 	{
       664 	    Form v;
       665 	    VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, minOp<Cmpt>());
    -> 666 	    return v;
       667 	}
       668
       669
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x00000001038609d8 libfiniteVolume.dylib`Foam::boundBox::add(this=0x000000016fdf8650, pt=0x00000001180e3480) at boundBoxI.H:339:12
       336
       337 	inline void Foam::boundBox::add(const point& pt)
       338 	{
    -> 339 	    min_ = ::Foam::min(min_, pt);
       340 	    max_ = ::Foam::max(max_, pt);
       341 	}
       342
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000107441264 libOpenFOAM.dylib`void Foam::boundBox::add<Foam::UList<int>>(this=0x000000016fdf8650, points=0x000000012380acc8, indices=0x00000001281093f0) at boundBoxTemplates.C:113:9
       110 	        if (pointi >= 0 && pointi < len)
       111 	        {
       112 	            add(points[pointi]);
    -> 113 	        }
       114 	    }
       115 	}
       116
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x000000010744116c libOpenFOAM.dylib`Foam::boundBox::boundBox(this=0x000000016fdf8650, points=0x000000012380acc8, indices=0x00000001281093f0, doReduce=false) at boundBox.C:120:9
       117 	{
       118 	    add(points, indices);
       119
    -> 120 	    if (doReduce)
       121 	    {
       122 	        reduce();
       123 	    }
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000107443a10 libOpenFOAM.dylib`Foam::treeBoundBox::treeBoundBox(this=0x000000016fdf8650, points=0x000000012380acc8, indices=0x00000001281093f0) at treeBoundBox.C:84:9
       81  	:
       82  	    boundBox(points, indices, false)
       83  	{
    -> 84  	    if (points.empty() || indices.empty())
       85  	    {
       86  	        WarningInFunction
       87  	            << "No bounding box for zero-sized pointField" << nl;
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000107443aa4 libOpenFOAM.dylib`Foam::treeBoundBox::treeBoundBox(this=0x000000016fdf8650, points=0x000000012380acc8, indices=0x00000001281093f0) at treeBoundBox.C:83:1
       80  	)
       81  	:
       82  	    boundBox(points, indices, false)
    -> 83  	{
       84  	    if (points.empty() || indices.empty())
       85  	    {
       86  	        WarningInFunction
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101cd119c libmeshTools.dylib`Foam::treeDataFace::getBounds(this=0x0000600003be6200, index=16915) const at treeDataFace.C:161:5
       158 	Foam::treeDataFace::getBounds(const label index) const
       159 	{
       160 	    const label facei = objectIndex(index);
    -> 161 	    return treeBoundBox(mesh_.points(), mesh_.faces()[facei]);
       162 	}
       163
       164
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101cd0e38 libmeshTools.dylib`Foam::treeDataFace::overlaps(this=0x0000600003be6200, index=16915, searchBox=0x000000016fdf8710) const at treeDataFace.C:545:29
       542 	    (
       543 	        cacheBb_
       544 	      ? !searchBox.overlaps(bbs_[index])
    -> 545 	      : !searchBox.overlaps(getBounds(index))
       546 	    )
       547 	    {
       548 	        return false;
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (bool) $2 = false
    
        frame #0: 0x0000000101c0e2dc libmeshTools.dylib`Foam::indexedOctree<Foam::treeDataFace>::divide(this=0x0000600003be6200, indices=0x00000001183411b0, bb=0x000000016fdf8998, dividedIndices=0x000000016fdf8838) const at indexedOctree.C:56:25
       53
       54  	        for (const label index : indices)
       55  	        {
    -> 56  	            if (shapes_.overlaps(index, subBbs))
       57  	            {
       58  	                contains.push_back(index);
       59  	            }
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101c0d920 libmeshTools.dylib`Foam::indexedOctree<Foam::treeDataFace>::divide(this=0x0000600003be6200, bb=0x000000016fdf8998, contents=0x000000016fdf8db0, contentIndex=282) const at indexedOctree.C:96:5
       93  	    const labelList& indices = contents[contentIndex];
       94
       95  	    FixedList<labelList, 8> dividedIndices;
    -> 96  	    divide(indices, bb, dividedIndices);
       97
       98  	    node nod;
       99  	    nod.bb_ = bb;
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101c0dc14 libmeshTools.dylib`Foam::indexedOctree<Foam::treeDataFace>::splitNodes(this=0x0000600003be6200, minSize=10, nodes=0x000000016fdf8dc8, contents=0x000000016fdf8db0) const at indexedOctree.C:172:39
       169 	                    const treeBoundBox bb(nod.bb_.subBbox(octant));
       170
       171 	                    node subNode(divide(bb, contents, contentI));
    -> 172 	                    subNode.parent_ = nodeI;
       173 	                    label sz = nodes.size();
       174 	                    nodes.push_back(subNode);
       175 	                    nodes[nodeI].subNodes_[octant] = nodePlusOctant(sz, octant);
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101c0d148 libmeshTools.dylib`Foam::indexedOctree<Foam::treeDataFace>::indexedOctree(this=0x0000600003be6200, shapes=0x000000016fdf8ef8, bb=0x0000600001b52be0, maxLevels=8, maxLeafRatio=10, maxDuplicity=3) at indexedOctree.C:2229:9
       2226
       2227	        // Split nodes with more than maxLeafRatio elements
       2228	        label nOldNodes = nodes.size();
    -> 2229	        splitNodes
       2230	        (
       2231	            label(maxLeafRatio),
       2232	            nodes,
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101bfa3dc libmeshTools.dylib`Foam::indexedOctree<Foam::treeDataFace>::indexedOctree(this=0x0000600003be6200, shapes=0x000000016fdf8ef8, bb=0x0000600001b52be0, maxLevels=8, maxLeafRatio=10, maxDuplicity=3) at indexedOctree.C:2156:1
       2153	    nodes_(),
       2154	    contents_(),
       2155	    nodeTypes_()
    -> 2156	{
       2157	    int oldMemSize = 0;
       2158	    if (debug)
       2159	    {
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101c370dc libmeshTools.dylib`Foam::meshSearch::boundaryTree(this=0x0000000123107680) const at meshSearch.C:629:17
       626
       627 	        boundaryTreePtr_.reset
       628 	        (
    -> 629 	            new indexedOctree<treeDataFace>
       630 	            (
       631 	                treeDataFace(mesh_, bndFaces),  // Boundary faces
       632
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000101c37ef8 libmeshTools.dylib`Foam::meshSearch::intersections(this=0x0000000123107680, pStart=0x000000016fdf9268, pEnd=0x000000016fdf9240) const at meshSearch.C:874:31
       871 	) const
       872 	{
       873 	    DynamicList<pointIndexHit> hits;
    -> 874 	    findUniqueIntersectOp iop(boundaryTree(), hits);
       875
       876 	    while (true)
       877 	    {
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 14628 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (Foam::List<Foam::PointIndexHit<Foam::Vector<double> > >) $3 = {
      Foam::UList<Foam::PointIndexHit<Foam::Vector<double> > > = {
        size_ = 1876922360
        v_ = 0x000000016fdf8ff8
      }
    }
    
        frame #0: 0x00000001054182bc libsampling.dylib`Foam::faceOnlySet::calcSamples(this=0x00006000020e1380, samplingPts=0x000000016fdf9590, samplingCells=0x000000016fdf9578, samplingFaces=0x000000016fdf9560, samplingSegments=0x000000016fdf9548, samplingCurveDist=0x000000016fdf9530) const at faceOnlySet.C:128:48
       125 	    passiveParticleCloud particleCloud(mesh());
       126
       127 	    // Get all boundary intersections
    -> 128 	    List<pointIndexHit> bHits = searchEngine().intersections
       129 	    (
       130 	        start_ - smallVec,
       131 	        end_ + smallVec
    Target 0: (simpleFoam) stopped.
  18. gerlero commented on Aug 4, 2023

    @gerlero
    gerlero
    on Aug 4, 2023
    ContributorAuthor
    More actions

    Nice. I guess one of those functions is in an infinite loop?

  19. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    Maybe the new Clang failed to expand the macro defined in src/OpenFOAM/primitives/Scalar/doubleFloat.H?

  20. gerlero commented on Aug 4, 2023

    @gerlero
    gerlero
    on Aug 4, 2023
    ContributorAuthor
    More actions

    Maybe the new Clang failed to expand the macro defined in src/OpenFOAM/primitives/Scalar/doubleFloat.H?

    Not sure.. isn't this line showing the expansion?

        frame #0: 0x00000001000465c0 simpleFoam`Foam::min(s1=0.065987628869999995, s2=0.067035051550000002) at doubleFloat.H:55:1
    
  21. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    Forget about it. I ran lldb again and this time it gives an another totally different result. Now I'm totally lost.

  22. gerlero commented on Aug 4, 2023

    @gerlero
    gerlero
    on Aug 4, 2023
    ContributorAuthor
    More actions

    How different? If it's an infinite loop then the function that "contains" that loop must appear in the trace no matter when the snapshot is taken, right?

  23. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    I feel it's in a huge infinite loop across multiple functions. If it's cause by a compiler bug, this method may not work at all.

    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
        frame #0: 0x000000010001e040 simpleFoam`Foam::UList<int>::checkIndex(this=0x0000000120009810, i=2) const at UListI.H:173:1
       170 	            << size_ << "]\n"
       171 	            << abort(FatalError);
       172 	    }
    -> 173 	}
       174
       175
       176 	template<class T>
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000100045cec simpleFoam`Foam::UList<int>::operator[](this=0x0000000120009810, i=2) const at UListI.H:311:5
       308 	inline const T& Foam::UList<T>::operator[](const label i) const
       309 	{
       310 	    #ifdef FULLDEBUG
    -> 311 	    checkIndex(i);
       312 	    #endif
       313 	    return v_[i];
       314 	}
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000102d899dc libfiniteVolume.dylib`Foam::UList<int>::fcValue(this=0x0000000120009810, i=1) const at UListI.H:75:5
       72  	template<class T>
       73  	inline const T& Foam::UList<T>::fcValue(const label i) const
       74  	{
    -> 75  	    return this->operator[](this->fcIndex(i));
       76  	}
       77
       78
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000103131cb0 libfiniteVolume.dylib`Foam::face::nextLabel(this=0x0000000120009810, i=1) const at faceI.H:192:23
       189
       190 	inline Foam::label Foam::face::nextLabel(const label i) const
       191 	{
    -> 192 	    return labelList::fcValue(i);
       193 	}
       194
       195
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (Foam::label) $0 = 6355
    
        frame #0: 0x0000000103130c88 libfiniteVolume.dylib`Foam::face::edge(this=0x0000000120009810, edgei=1) const at faceI.H:142:41
       139
       140 	inline Foam::edge Foam::face::edge(const label edgei) const
       141 	{
    -> 142 	    return Foam::edge(thisLabel(edgei), nextLabel(edgei));
       143 	}
       144
       145
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
    Return value: (Foam::edge) $1 = {
      Foam::labelPair = {
        Foam::FixedList<int, 2> = {
          v_ = ([0] = 1876921420, [1] = 1)
        }
      }
    }
    
        frame #0: 0x0000000100846940 liblagrangian.dylib`Foam::particle::changeFace(this=0x000000016fdf9160, tetTriI=3) at particle.C:299:47
       296 	        (
       297 	            ;
       298 	            edgeI < newFace.size()
    -> 299 	         && edge::compare(sharedEdge, newFace.edge(edgeI)) != edgeComp;
       300 	            ++ edgeI
       301 	        );
       302
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000100846458 liblagrangian.dylib`Foam::particle::changeTet(this=0x000000016fdf9160, tetTriI=3) at particle.C:217:13
       214 	            if (tetPti_ == firstTetPtI)
       215 	            {
       216 	                changeFace(tetTriI);
    -> 217 	            }
       218 	            else
       219 	            {
       220 	                reflect();
    Target 0: (simpleFoam) stopped.
    (lldb) finish
    Process 20383 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = step out
        frame #0: 0x0000000100848b60 liblagrangian.dylib`Foam::particle::trackToFace(this=0x000000016fdf9160, displacement=0x000000016fdf8f70, fraction=0) at particle.C:686:13
       683 	        else
       684 	        {
       685 	            // Move to the next tet and continue the track
    -> 686 	            changeTet(tetTriI);
       687 	        }
       688 	    }
       689
    Target 0: (simpleFoam) stopped.
  24. gerlero commented on Aug 4, 2023

    @gerlero
    gerlero
    on Aug 4, 2023
    ContributorAuthor
    More actions

    If it's cause by a compiler bug, this method may not work at all.

    That's an interesting point.

    I feel it's in a huge infinite loop across multiple functions.

    Yeah, glancing at both stack traces (and assuming any compiler bug that may exist is not that bad) I see no functions that appear in both. Is there a way to print it with maximum depth (i.e. down to main())?

  25. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    I tested llvm@16 from homebrew and it failed at the same place. So it's not Apple's fault, but an upstream problem (the bug could be introduced between 14.0.0 and 14.0.3).

    llvm@13 is working and could fit your current workflow: it's the last working formula that is still available. Since the bug is still in llvm@16, I would expect the same thing happens in at least macOS 15. So llvm@13 might be a better long-term solution, until the bug is fixed by llvm upstream.

  26. BrushXue commented on Aug 4, 2023

    @BrushXue
    BrushXue
    on Aug 4, 2023
    Owner
    More actions

    You'll need to do

    brew install llvm@13 flex
    

    and

    export PATH="/opt/homebrew/opt/llvm@13/bin:/opt/homebrew/opt/flex/bin:$PATH"
    export FOAM_EXTRA_CXXFLAGS="-I/opt/homebrew/opt/flex/include"
    export FOAM_EXTRA_LDFLAGS="-L/opt/homebrew/opt/flex/lib -L/opt/homebrew/opt/llvm@13/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@13/lib/c++"
    

    plus you may want to suppress compiler warnings with -fno-trapping-math

  27. BrushXue commented on Aug 5, 2023

    @BrushXue
    BrushXue
    on Aug 5, 2023
    Owner
    More actions

    Problem solved! I tested it on Xcode 15 beta and didn't trigger the infinite loop.
    Clang changed its default floating point number behavior: https://releases.llvm.org/14.0.0/tools/clang/docs/ReleaseNotes.html#floating-point-support-in-clang. FMA is a very dangerous thing in scientific computing(unless you really know what you are doing) so I don't understand why they changed the default behavior. For some reason, Apple didn't pull this upstream change until 14.0.3 (my guess, because Apple clang 14.0.0 is OK.)
    So please add this flag:-ffp-contract=off and test again. If it works we can close this issue.

    Additional reading: https://www.kdab.com/fma-woes/

    Reacted by Gabriel Gerlero
  28. gerlero commented on Aug 6, 2023

    @gerlero
    gerlero
    on Aug 6, 2023
    ContributorAuthor
    More actions

    Yes, that definitely does it! Excellent find; thanks!

    If you can open a PR at https://github.com/gerlero/openfoam-app, I'd prefer it so that you get the full credit for the fix. FWIW, adding these lines:

    sed -i '' 's|-ftrapping-math|-ftrapping-math -ffp-contract=off|' wmake/rules/darwin64Clang/c
    sed -i '' 's|-ftrapping-math|-ftrapping-math -ffp-contract=off|' wmake/rules/darwin64Clang/c++

    to configure.sh did the trick for me. Let me know if you're able to do it.

    I guess this workaround should be upstreamed too; what do you think? If you agree, I'd also prefer that you were the one to open the issue there so that you get credited for that as well.

  29. BrushXue commented on Aug 6, 2023

    @BrushXue
    BrushXue
    on Aug 6, 2023
    Owner
    More actions

    I’ve already opened an issue there.
    https://develop.openfoam.com/Development/openfoam/-/issues/2958

    Reacted by Gabriel Gerlero
  30. BrushXue commented on Aug 6, 2023

    @BrushXue
    BrushXue
    on Aug 6, 2023
    Owner
    More actions

    Looks like it’s a well-know issue in computational geometry.
    WebAssembly/relaxed-simd#5 (comment)

  31. gerlero
    closed this as completedon Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.