Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCERD crashes when there are too many elements #195

Open
aleekaup2 opened this issue Sep 15, 2021 · 1 comment
Open

MCERD crashes when there are too many elements #195

aleekaup2 opened this issue Sep 15, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@aleekaup2
Copy link
Contributor

MCERD crashes if the total amount of elements in the target composition exceeds 15.

The elements don't have to be unique, i.e. alternating pattern of GaAs and GaAsBi layers will crash the simulation after 6 layers.
If there are even more layers and elements, MCERD does not crash but simulation gets stuck on "Reading target file" or "Reading detector file"
image002

Reproduction:

  1. Create a target with for example 5 layers that have 3 elements each
  2. Start simulation (still works)
  3. Add one more element to one of the layers
  4. MCERD stopped with an error code 3221225477

Notes:

  • Does not work on February Windows release either
  • Behavior is consistent on different requests
  • Layers in Potku might be structured in a way that MCERD is given a "new" element every time even if the element is already on some previous layer. This might exceed some "element-maximum" in MCERD. (As suggested by @jaakkojulin)
@aleekaup2 aleekaup2 added the bug Something isn't working label Sep 15, 2021
@jaakkojulin
Copy link
Member

There clearly is a maximum of 20 elements defined in general.h. Some of these are reserved for a) primary ion b) target atom c) recoil d) recoil cascades in the energy detector (my code!) so this should be consistent of 15 elements left for the target. Crashing is probably due to lacking a check of boundaries somewhere.

Potku indeed adds a new element for every element in every layer, so 15 is a low limit.

Solution: make Potku re-use elements, change the maximum in MCERD to be dynamic or larger. MCERD runs out of stack space as it is, so allocation of large tables from the heap with malloc() should be done anyways.

BTW strictly MCERD bugs (crashing) can be also reported in https://github.com/JYU-IBA/mcerd/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants