Bug 752883 - setjmp/longjmp behavior seems to have changed in glibc-2.14.90-15.1
Summary: setjmp/longjmp behavior seems to have changed in glibc-2.14.90-15.1
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Andreas Schwab
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-10 17:50 UTC by Tom Lane
Modified: 2016-11-24 16:03 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-10 18:12:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Tom Lane 2011-11-10 17:50:10 UTC
Description of problem:
postgresql is failing its regression tests in rawhide since about two days ago.  Debugging the problem reveals that an error-handling chunk of code reached by setjmp() is failing to restore a global variable that it is supposed to restore.

Normally I would think that this is a gcc issue, especially since it goes away at -O0.  But gcc hasn't changed recently and the appearance of the problem coincides with the introduction of glibc-2.14.90-15.1 into rawhide.  So I'm wondering if longjmp is now forgetting to restore some registers, or something like that.

Version-Release number of selected component (if applicable):
glibc-2.14.90-15.1

How reproducible:
100%

Steps to Reproduce:
1.  Try to build current postgresql SRPM (9.1.1-2)
  
Actual results:
Regression test failure for plpython module --- it prints one line that it shouldn't.

Expected results:
No failure.

Additional info:
Failure is observed on both x86_64 and i386 architectures.

The problematic code looks approximately like this:


static PLyProcedure *PLy_curr_procedure = NULL;

Datum
plpython_call_handler(FunctionCallInfo fcinfo)
{
 PLyProcedure *save_curr_proc;

 save_curr_proc = PLy_curr_procedure;

 do {
    sigjmp_buf *save_exception_stack = PG_exception_stack;
    sigjmp_buf local_sigjmp_buf;

    if (__sigsetjmp (local_sigjmp_buf, 0) == 0) {
      PG_exception_stack = &local_sigjmp_buf;
      ...
    } else {
      PG_exception_stack = save_exception_stack;
      PLy_curr_procedure = save_curr_proc;  // this assignment is getting lost
      PyErr_Clear();
      pg_re_throw(); // this does a longjmp(), so it doesn't return
    }
    PG_exception_stack = save_exception_stack;
 } while (0);

 PLy_curr_procedure = save_curr_proc;
 ...
}


and the observed behavior is that PLy_curr_procedure isn't getting restored during a longjmp exit.

Comment 1 Jeff Law 2011-11-10 18:07:43 UTC
PLy_curr_procedure is in static storage, so its value would not be restored -- it will contain whatever value it had when longjmp was called.  So the assignment to pLy_curr_procedure = save_curr_proc  would be lost if there were any later assignments to PLy_curr_procedure.

Jeff

Comment 2 Tom Lane 2011-11-10 18:12:32 UTC
I'm not expecting longjmp to restore the value --- I'm expecting the explicit assignment to handle that.

After some inspection of the generated assembly code, I've concluded that this is indeed a gcc issue not a glibc issue; it's simply not generating the assignment.  Not sure why we didn't see it before the glibc update, but anyway I will refile this over there; sorry for the false alarm.

Comment 3 Jeff Law 2011-11-10 18:19:59 UTC
I was kindof wondering if underneath it all GCC omitted the store, I was pretty sure you knew setjmp/longjmp semantics.  Odd that it only showed up now...

Either way it's my team that'll own it, so it's not a false alarm, just different folks within the team that'll be charged with fixing it.

If you could pass along the .i/.ii file, compile options and since you've identified the missing store, whatever comments you have on the resulting assembly, that'd be a huge help to the GCC engineer ultimately assigned to fix the problem.

Comment 4 Tom Lane 2011-11-10 19:03:30 UTC
Done at bug #752905.


Note You need to log in before you can comment on or make changes to this bug.