<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Dear Erik,</p>
<p>we tested the workaround you proposed and can confirm that it so
far works.</p>
<p>Simulations that failed previously, now run smoothly with no
crashes so far.<br>
Many thanks for the help!</p>
<p>Is there a way to check - the amount of intersections reached
during a simulation?<br>
It would give us the info whether we are at the limit our still in
calm waters.<br>
<br>
Bye</p>
<p>Richard <br>
</p>
<div class="moz-cite-prefix">On 18/08/2021 13:54, Erik B Knudsen
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:48e2ea7f-6596-cae8-33f0-6b6c68076b94@fysik.dtu.dk">Dear
Richard
<br>
(writing to the mailing list as well as it may interest others)
<br>
I have now understood what happens: Your issue is caused by a
buffer overrun. If the number of intersections computed by
off_intersect exceeds 100 - this results in undefined behaviour.
<br>
The number 100 is hardcoded (via a #define) within the interoff
library.
<br>
<br>
In your particular case, it appears that when a neutron is on a
trajectory towards a corner of your square channels it may reflect
many times, each time with a higher angle, and eventually be on a
trajectory which intersects many polygons, thus triggering the
buffer overrun. Also this error was not properly caught in the
code.
<br>
<br>
I'll increase the number of possible intersections in the
development tree, and fix the check. That way it'll get better in
the next release.
<br>
<br>
In the meantime, as a workaround, you may edit the generated
c-file
<br>
or the interoff-lib.h file found in your McStas-tree.
<br>
Change the line
<br>
#define OFF_INTERSECT_MAX 100
<br>
to something bigger such as
<br>
#define OFF_INTERSECT_MAX 1000
<br>
<br>
Any bigger than 1024 is not really meaningful because that is what
the overrun-check checks for :-).
<br>
<br>
This makes the code run and it appears to work also with your
original file, i.e. the smaller ones. So that's good I suppose.
<br>
<br>
cheers
<br>
Erik
<br>
<br>
<br>
On 12/07/2021 13:39, Richard Wagner wrote:
<br>
<blockquote type="cite">Dear Erik,
<br>
<br>
the random seed has an influence on the point (in time) when the
simulation crashes.
<br>
That means for certain seeds a simulation run will survive and
crash only after repeating the run with another seed,
<br>
or depending on our simulation we have a crash at a run were we
added more nested optical elements.
<br>
<br>
If the seed is held fix and an error occurs, it is repeated each
run and becomes reproducible.
<br>
<br>
Hope that info helps to shed light on the issue.
<br>
<br>
Best,
<br>
<br>
Richard
<br>
<br>
<br>
On 07/07/2021 14:56, Erik B Knudsen wrote:
<br>
<blockquote type="cite">Dear Richard,
<br>
That is unfortunate. We will investigate the matter on our
end.
<br>
From what you describe - it sounds like there is a memory leak
somewhere.
<br>
Is the "point of crash" always the same across simulation runs
or does it vary (as I would expect)? I.e. does it depend on
the random seed?
<br>
<br>
Also thank you for the very thorough report btw. If only they
were all like this.
<br>
<br>
cheers
<br>
Erik
<br>
<br>
On 07/07/2021 14:08, Richard Wagner wrote:
<br>
<blockquote type="cite">Dear all,
<br>
<br>
here is a follow up.
<br>
<br>
In short crashes still occur.
<br>
<br>
Of our many tests I will point out two scenarios:
<br>
<br>
a) double planar optic with corrected OFF File. Now the
surfaces don't intersect each other anymore they have only
common sides. With this approach the number of points and
faces explodes as one goes to a higher number of levels
(vertices scale with the square of the levels)
<br>
<br>
The simulation start to take noticeably longer (several
minutes compared two ~20 sec). and we get a crash after
increasing to 90 levels with the message
<br>
<br>
# McStas 2.7 - Nov. 27, 2020: [pid 4509] Signal 11 detected
SIGSEGV (Mem Error)
<br>
<br>
# Simulation: NNb (NNb_90.instr)
<br>
<br>
# Breakpoint: end_event (Trace) 0.68 % ( 6771.0/ 1000000.0)
<br>
<br>
# Date: Wed Jul 7 14:03:06 2021
<br>
<br>
# Started: Wed Jul 7 14:03:00 2021
<br>
<br>
# Last I/O Error: No such file or directory
<br>
<br>
b) a Single mono Planar mirror
<br>
<br>
The simulation crashes with either of the following
messages, when the amount of nested levels is above 115.
<br>
<br>
# McStas 2.7 - Nov. 27, 2020: [pid 98724] Signal 11 detected
SIGSEGV (Mem Error)
<br>
<br>
# Simulation: NNb (NNb_115.instr)
<br>
<br>
# Breakpoint: nested (Trace) 0.18 % ( 1821.0/ 1000000.0)
<br>
<br>
# Date: Wed Jul 7 12:57:49 2021
<br>
<br>
# Started: Wed Jul 7 12:57:49 2021
<br>
<br>
# Last I/O Error: No such file or directory
<br>
<br>
# McStas 2.7 - Nov. 27, 2020: [pid 1196] Signal 11 detected
SIGSEGV (Mem Error) # Simulation: NNb (NNb.instr) #
Breakpoint: end_event (Trace) 2.17 % ( 21733.0/ 1000000.0)
<br>
<br>
Any ideas, which memory runs out?
<br>
<br>
We made the observation that when running the same
simulation with McStasScript we run into the crash earlier
(level 75 instead of the 115)
<br>
<br>
I put the off files of the two cases in the attachment. The
instrument files is the same during all tests (means only
the OFF of the Guide_anyshape) is changed
<br>
<br>
Hope for any ideas, how to proceed further.
<br>
<br>
Thanks in advance,
<br>
<br>
Best,
<br>
<br>
Richard
<br>
<br>
On 05/07/2021 11:55, Erik B Knudsen wrote:
<br>
<blockquote type="cite">Dear Richard,
<br>
Very good to hear. For sure, overlapping polygons is
expected to create problems and undefined behaviour. The
underlying routine that checks polygon intersections does
not check for consistency, and instead only checks which
polygon it hits first, which could be the wrong one.
<br>
That the problem only arises at a certain level of
complexity is perhaps connected to the sheer number of
overlaps becoming large - but that is merely guesswork on
my part.
<br>
<br>
Looking forward to hearing the further output of your
efforts.
<br>
<br>
cheers
<br>
Erik
<br>
<br>
On 02/07/2021 13:30, Richard Wagner wrote:
<br>
<blockquote type="cite">Dear all,
<br>
<br>
we had in the meantime a detailed look in the matter
from our side and suspect know a problem with the
OFF-file
<br>
<br>
If we use a mono planar version of the optic (see
example in the attachment) we can increase the nested
levels ad lib.
<br>
We are only limited by the fact that the spacing between
the levels is becoming so small, that it makes no sense
to continue.
<br>
<br>
A major difference between the single and double planar
optic is that the double planar OFF-File has surfaces
that intersect each other.
<br>
<br>
I don't know if this is "allowed" or if it can cause
McStas to have problems during the simulation.
<br>
Until a certain level of complexity it worked fine.
<br>
<br>
What we are currently doing is to change the function
(written in python), that generates the double planar
OFF-file to generate additional vertexes and faces at
the intersection of the surfaces. So we end up having a
cleanly defined optic with no 'undefined intersections'.
<br>
<br>
I will report the outcome of this changes.
<br>
<br>
Best,
<br>
<br>
Richard
<br>
<br>
<br>
<br>
<br>
On 02/07/2021 09:35, Erik B Knudsen wrote:
<br>
<blockquote type="cite">Dear Richard,
<br>
Thank you for the thorough and detailed report. We
will take a look at your problem asap and report back.
<br>
cheers
<br>
Erik
<br>
<br>
On 29/06/2021 18:31, Richard Wagner wrote:
<br>
<blockquote type="cite">Dear McStas experts,
<br>
<br>
We are currently doing simulations with nested
elliptical optics and so far things ran quiet
smoothly.
<br>
<br>
We generate the OFF file for the optic ourselves and
use the Guide_anyshape component.
<br>
<br>
We start with an outer layer and continue to add
inner layers one at a time.
<br>
If we then get to optical components that have a
high number of levels we run into the problem, that
McStas crashes resp. aborts the simulation.
<br>
<br>
Output in that case reads:
<br>
<br>
# McStas 2.7 - Nov. 27, 2020: [pid 64818] Signal 11
detected SIGSEGV (Mem Error)
<br>
# Simulation: NNb (NNb.instr)
<br>
# Breakpoint: psd_monitor (Trace) 2.46 % (
24574.0/ 1000000.0)
<br>
# Date: Tue Jun 29 17:44:13 2021
<br>
# Started: Tue Jun 29 17:44:13 2021
<br>
# Last I/O Error: No such file or directory
<br>
# McStas 2.7 - Nov. 27, 2020: Simulation stop
(abort).
<br>
<br>
Or
<br>
<br>
# McStas 2.7 - Nov. 27, 2020: [pid 66573] Signal 10
detected [proc 0] SIGBUS (Bus error)
<br>
# Simulation: NNb (NNb.instr)
<br>
# Breakpoint: nested (Trace) 85.56 % ( 855555.0/
1000000.0)
<br>
# Date: Tue Jun 29 18:00:32 2021
<br>
# Started: Tue Jun 29 18:00:28 2021
<br>
# Last I/O Error: No such file or directory
<br>
<br>
There are many messages such as the following in the
Mcstas Window, too:
<br>
<br>
Guide_anyshape: nested: Warning: Reflectivity
R=7.02318 > 1 lowered to R=1.
<br>
Guide_anyshape: nested: Warning: Reflectivity
R=7.02365 > 1 lowered to R=1.
<br>
Guide_anyshape: nested: Warning: Reflectivity
R=7.02412 > 1 lowered to R=1.
<br>
Guide_anyshape: nested: Warning: Reflectivity
R=7.0246 > 1 lowered to R=1.
<br>
<br>
I put an example of an instrument file (+OFF ,
+Source Component) of a failed run for a 1m optic in
the attachment.
<br>
<br>
The trace run for instrument visualization works.
<br>
We only run into the problem for short optics <=2
m, were a high number of nested levels is needed to
completely cover the cross section.
<br>
<br>
We run into the problem on Ubuntu 18.04 and MacOs
Big Sur machines.
<br>
<br>
Any ideas what's the problem? Are the spacing of the
elliptical getting to narrow, perhaps?
<br>
<br>
Thanks in advance,
<br>
<br>
Richard
<br>
<br>
<br>
-- <br>
*Richard Wagner*
<br>
Research Engineer
<br>
Nuclear and Particle Physics Group
<br>
Institut Laue-Langevin - ILL
<br>
71, avenue des Martyrs
<br>
CS 20156
<br>
38042 Grenoble Cedex 9
<br>
France
<br>
<br>
<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a> <<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a>>
<br>
<br>
<br>
<br>
_______________________________________________
<br>
mcstas-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:mcstas-users@mcstas.org">mcstas-users@mcstas.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">https://mailman2.mcstas.org/mailman/listinfo/mcstas-users</a>
<br>
<br>
</blockquote>
<br>
</blockquote>
-- <br>
*Richard Wagner*
<br>
Research Engineer
<br>
Nuclear and Particle Physics Group
<br>
Institut Laue-Langevin - ILL
<br>
71, avenue des Martyrs
<br>
CS 20156
<br>
38042 Grenoble Cedex 9
<br>
France
<br>
<br>
<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a> <<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a>>
<br>
<br>
<br>
<br>
_______________________________________________
<br>
mcstas-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:mcstas-users@mcstas.org">mcstas-users@mcstas.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">https://mailman2.mcstas.org/mailman/listinfo/mcstas-users</a>
<br>
<br>
</blockquote>
<br>
</blockquote>
-- <br>
*Richard Wagner*
<br>
Research Engineer
<br>
Nuclear and Particle Physics Group
<br>
Institut Laue-Langevin - ILL
<br>
71, avenue des Martyrs
<br>
CS 20156
<br>
38042 Grenoble Cedex 9
<br>
France
<br>
<br>
<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a> <<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a>>
<br>
<br>
</blockquote>
<br>
</blockquote>
-- <br>
*Richard Wagner*
<br>
Research Engineer
<br>
Nuclear and Particle Physics Group
<br>
Institut Laue-Langevin - ILL
<br>
71, avenue des Martyrs
<br>
CS 20156
<br>
38042 Grenoble Cedex 9
<br>
France
<br>
<br>
<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a> <<a class="moz-txt-link-abbreviated" href="http://www.ill.eu">www.ill.eu</a>>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<div class="moz-signature">-- <br>
<b>Richard Wagner</b><br>
Research Engineer<br>
Nuclear and Particle Physics Group<br>
Institut Laue-Langevin - ILL<br>
71, avenue des Martyrs<br>
CS 20156<br>
38042 Grenoble Cedex 9<br>
France <br>
<br>
<a href="www.ill.eu"><font color="#3984c6">www.ill.eu</font></a>
<p><br>
</p>
</div>
</body>
</html>