Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • S src
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 60
    • Issues 60
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OPAL
  • src
  • Issues
  • #490

Closed
Open
Created Mar 20, 2020 by snuverink_j@snuverink_jDeveloper

BEAM without particles specified crashes

Summary

When the BEAM command has no particles (NPARTS) specified, OPAL crashes.

Steps to reproduce

drift-noparts.in

What is the current bug behavior?

Crash.

What is the expected correct behavior?

Exit with error that no particles are specified.

Relevant logs and/or screenshots

traceback:

Program received signal SIGSEGV, Segmentation fault.
Distribution::createOpalT(PartBunchBase<double, 3u>*, unsigned long&) ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Distribution/Distribution.cpp:2820
2820	    double maxTOrZ = *longIt;
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.x86_64 infinipath-psm-3.0.1-115.1015_open.2.el6.x86_64 libnl-1.1.4-2.el6.x86_64 nss-pam-ldapd-0.7.5-20.el6_6.3.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt
#0  Distribution::createOpalT(PartBunchBase<double, 3u>*, unsigned long&) ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Distribution/Distribution.cpp:2820
#1  0x0000000000885814 in TrackRun::setDistributionParallelT(Beam*) ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Classic/Algorithms/PartBunchBase.hpp:254
#2  0x000000000088861f in TrackRun::setupTTracker() () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Track/TrackRun.cpp:505
#3  0x000000000088914c in TrackRun::execute() () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Track/TrackRun.cpp:197
#4  0x00000000006ea0aa in OpalParser::execute(Object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:139
#5  0x00000000006ee452 in OpalParser::parseAction(Statement&) const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:172
#6  0x00000000006edcf3 in OpalParser::parse(Statement&) const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:90
#7  0x00000000006e9d4c in OpalParser::run() const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:607
#8  0x000000000088276a in TrackCmd::execute() () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Track/TrackCmd.cpp:212
#9  0x00000000006ea0aa in OpalParser::execute(Object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:139
#10 0x00000000006ee452 in OpalParser::parseAction(Statement&) const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:172
#11 0x00000000006edcf3 in OpalParser::parse(Statement&) const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:90
#12 0x00000000006e9d4c in OpalParser::run() const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:607
#13 0x00000000006eeb90 in OpalParser::run(TokenStream*) const ()
    at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/OpalParser/OpalParser.cpp:632
#14 0x0000000000642812 in main () at /home/scratch/OPAL/OPAL-fork/OPAL-src/src/Main.cpp:360

Possible fixes

The method that crashes, takes the first entry without checking its size: https://gitlab.psi.ch/OPAL/src/blob/master/src/Distribution/Distribution.cpp#L2817

double Distribution::getMaxTOrZ() {

    std::vector<double>::iterator longIt = tOrZDist_m.begin();
    double maxTOrZ = *longIt;

This should be fixed. But in addition, it would be good to catch this when parsing, and OPAL can exit with an exception.

Assignee
Assign to
Time tracking