View Issue Details

IDProjectCategoryView StatusLast Update
0016240CentOS-7glibcpublic2019-07-19 10:51
Reporterpengwei 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionnot fixable 
Platformaarch64OScentosOS Version7.6
Product Version7.6.1810 
Target VersionFixed in Version 
Summary0016240: setjmp&longjmp run unexcepetedly
Descriptionmy program test4.cpp is as follow:

#include <setjmp.h>
#include <iostream>

using namespace std;

jmp_buf g_jmp;


int a()
{
  cout<<"a"<<endl;
  if(setjmp(g_jmp)==0)
  {
    cout<<"setjmp called!"<<endl;
  }
  else
  {
    cout<<"longjmp called!"<<endl;
    return 2;
  }
  cout<<"a end."<<endl;
  return 1;

}

void b()
{
  longjmp(g_jmp,-1);
}

int c()
{
  cout<<"c"<<endl;
  b();
  cout<<"retrun from b"<<endl;
  return 0;
}

int d()
{
  cout<<"d"<<endl;
  int text=c();
  cout<<"return from c"<<endl;
  return 0;
}



int main()
{
  a();
  cout<<"a-b"<<endl;
  int i=d();
  cout<<i<<endl;
}

i use gcc4.8.5 to compile the program : g++ -g test4.cpp

and i executed the ./a.out, the result is just like this:

pengwei@BoardServer2:~/test$ ./a.out
a
setjmp called!
a end.
a-b
d
c
longjmp called!
2
d
c
longjmp called!
d
c
longjmp called!
.......

it's an endless cycle, but the same program i run in x86 server, the result is normal as follow:

pengwei@BoardServer2:~/test$ ./a.out
a
setjmp called!
a end.
a-b
d
c
longjmp called!
2

Please help to resolve the problem, tks.









Steps To Reproduce1. compile the program:
g++ -g test4.cpp

2. run the program:
./a.out
TagsNo tags attached.
abrt_hash
URL

Activities

fweimer

fweimer

2019-07-19 10:50

reporter   ~0034847

You cannot return to an activation frame that has already been exited. The jump buffer created by the function a becomes invalid immediately when a exits.
TrevorH

TrevorH

2019-07-19 10:51

manager   ~0034848

Closing as per above comments, Thanks.

Issue History

Date Modified Username Field Change
2019-07-04 07:22 pengwei New Issue
2019-07-19 10:50 fweimer Note Added: 0034847
2019-07-19 10:51 TrevorH Status new => closed
2019-07-19 10:51 TrevorH Resolution open => not fixable
2019-07-19 10:51 TrevorH Note Added: 0034848