Comment 5 for bug 1666339

Revision history for this message
Robert Caulk (rcaulk) wrote :

First, thank you Bruno for the tips and please excuse my developing understanding of C++, CGAL, and YADE source.

>If your idea was correct the current code would not work at all, you
>need to include in the picture the fact that this same code actually
>works for us without problem.
I should mention that the attached mwe.py is my attempt at creating the most basic DFNflow model possible by avoiding any special cases that may extend beyond the original functionality. Since you mention that this code does work fine for you guys, it is possible that my input script contains an error.

Bug update:

>Could you output more data on the crashing facet? Which are the vertices
>connected to it, etc. It may ring a bell about which special case need
>to be handled differently.
The crash occurs no matter which facet is currently being used to declare cell1 and cell2. Based on my debugging, the crash occurs even when the facet maps to nonfictitious cells. The problem occurs in the declaration of cell1 (which should simply grab the cellhandle of the facet using "facet->first"). Instead, it is declaring some junky values within cell1 despite facet1 pointing to a perfectly normal cell. Once the junky cellhandle is passed to CGAL, it throws the error.

So I've managed to fix the problem by dereferencing the circulator to obtain the facet, and then grabbing the cellhandle from the facet directly [1]. It appears to do exactly what the original code is doing, but in a more verbose manner. However, cell1 is no longer filled with junk values and I am no longer getting a segmentation fault.

Obviously, this is strange since the original code was already working for other people, but this fix suggests that it should not be. Since I've already associated this bug with the compiler optimization level, it might be possible that my compiler is optimizing the code differently than it was intended to when this was written in 2014. Also, I will continue to investigate my input script for possible mistakes.

[1] void DFNFlowEngine::trickPermeability(RTriangulation::Facet_circulator& facet, Real aperture, Real residualAperture)
{
 const RTriangulation::Facet& currentFacet = *facet; // seems verbose but facet->first was declaring a junk cell and crashing program
 const RTriangulation& Tri = solver->T[solver->currentTes].Triangulation();
 const CellHandle& cell1 = currentFacet.first;
 const CellHandle& cell2 = currentFacet.first->neighbor(currentFacet.second);
if ( Tri.is_infinite(cell1) || Tri.is_infinite(cell2)) cerr<<"Infinite cell found in trickPermeability, should be handled somehow, maybe"<<endl;
 cell1->info().kNorm()[currentFacet.second]=cell2->info().kNorm()[Tri.mirror_index(cell1, currentFacet.second)] = pow((aperture+residualAperture),3)/