Skip to content

Segmentation fault in tutor2pp #1140

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

Open
1 of 4 tasks
YiHui-Liu opened this issue Jun 3, 2024 · 3 comments
Open
1 of 4 tasks

Segmentation fault in tutor2pp #1140

YiHui-Liu opened this issue Jun 3, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@YiHui-Liu
Copy link

Describe the bug
Segmentation fault in tutor2pp

To Reproduce

  1. make
  2. tutor2pp -i test1 -p tutor_data

Expected behavior
image
(from tutor2)

Screenshots
image

Operating system

  • Linux: WSL Ubuntu22.04
  • Windows
  • macOS
  • Other:

EGSnrc version
v2023b

Additional context
tutor2pp.zip

@YiHui-Liu YiHui-Liu added the bug label Jun 3, 2024
@rtownson rtownson self-assigned this Jun 3, 2024
@rtownson
Copy link
Collaborator

rtownson commented Jun 3, 2024

Confirmed that this is a bug. I think that the EGS_SimpleApplication has been broken at some point. Right now I don't have a work-around, aside from just using tutor2 instead of tutor2pp.

@ftessier ftessier added this to the Release 2024 milestone Jun 3, 2024
@rtownson rtownson modified the milestones: Release 2025, Release 2026 Feb 10, 2025
@MattInglisWhalen
Copy link

I've been encountering the same thing when making my own usercode that inherits from EGS_SimpleApplication. I've found that I simply have to remove line 204 from egs_simple_application.cpp, currently reading

delete source_input;

to avoid this seg fault. Not sure what line 200 is doing with createSource(...) but it seems to be clobbering the pointer.

@mainegra
Copy link
Contributor

Reason for the bug: createSource calls EGS_Object *EGS_ObjectFactory::createObjects(EGS_Input *i,... where i is passed to the local EGS_input pointer input, which is deleted at the end of createObject.

There are two ways of fixing the segfault error:

  1. Pass a copy of EGS_Input *i in the argument of createObjects
  2. In line 204 of egs_simple_application.cpp use
    if (source_input) delete source input`

I think option 1 is more intentional, explicitly stating: "I am intentionally passing a copy of the EGS_Input object and taking care of the original version here ..." while option 2 is more cautious, implying lack of knowing what is actually going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants