[Bug ports/14266] New: tile: -fexceptions breaks pthread_cancel()

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug ports/14266] New: tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14266

             Bug #: 14266
           Summary: tile: -fexceptions breaks pthread_cancel()
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ports
        AssignedTo: [hidden email]
        ReportedBy: [hidden email]
                CC: [hidden email], [hidden email]
    Classification: Unclassified


The appended program works fine if you build it with "gcc cancel.c -pthread".
It creates a thread that blocks on stdin in a "pthread_cleanup_push()" context.
The main thread then cancels it, at which point the created thread calls the
cancel handler and returns.  However, if you add "-fexceptions" (or,
equivalently, build the program with g++ instead of gcc) the cancellation
handler doesn't get called.  This works fine on x86.

It's not clear if this is gcc or glibc bug, but I'm filing it as a glibc bug
for now, since there don't seem to be any similar failures in the gcc
testsuite.

This failure mode breaks the following glibc tests:

nptl/tst-cancel24.out
nptl/tst-cancelx4.out
nptl/tst-cancelx5.out
nptl/tst-cancelx16.out
nptl/tst-cancelx17.out
nptl/tst-cancelx18.out
nptl/tst-cancelx20.out
nptl/tst-cancelx21.out
nptl/tst-cleanupx0.out
nptl/tst-cleanupx1.out
nptl/tst-cleanupx3.out
nptl/tst-cleanupx4.out
nptl/tst-oncex3.out
nptl/tst-oncex4.out
rt/tst-mqueue8x.out


#include <unistd.h>
#include <pthread.h>
#include <stdio.h>

/* Cleanup handling test.  */
static int cl_called;

static void
cl (void *arg)
{
  printf("in cl\n");
  ++cl_called;
}

void *tf(void *arg)
{
  char c;

  printf("in tf\n");
  pthread_cleanup_push (cl, NULL);
  printf("waiting on stdin\n");
  read(0, &c, 1);
  pthread_cleanup_pop (0);
}

int main()
{
  pthread_t th;
  pthread_create(&th, NULL, tf, NULL);
  sleep(1);
  printf("cancelling\n");
  pthread_cancel(th);
  sleep(1);
  printf("%d\n", cl_called);
  return 0;
}

--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Chris Metcalf <cmetcalf at tilera dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper.fsp at gmail dot com
          Component|ports                       |nptl
               Host|                            |tilegx tilepro

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Andrew Cagney <cagney at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cagney at sourceware dot org

--- Comment #1 from Andrew Cagney <cagney at sourceware dot org> ---
Here's another example: https://github.com/cagney/pthread-cancel

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg
         Resolution|---                         |INVALID
   Target Milestone|---                         |2.28

--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Closing since tile is no longer a supported target.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Andrew Cagney <cagney at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
               Host|tilegx tilepro              |
         Resolution|INVALID                     |---

--- Comment #3 from Andrew Cagney <cagney at sourceware dot org> ---
Re-opening, bug also occurs on amd64

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

--- Comment #4 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Thread cancellation on glibc requires gcc exception frame information provided
by  PT_GNU_EH_FRAME and the compiler must instruct the linker to produce it by
--eh-frame-hdr.  On you example you are linking the shared library using linker
command directly, using default options.  If you use either gcc driver (gcc
-shared) or add --eh-frame-hdr on linker options the example does not fail.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug nptl/14266] tile: -fexceptions breaks pthread_cancel()

cvs-commit at gcc dot gnu.org
In reply to this post by cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=14266

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Close based on comment #4.

--
You are receiving this mail because:
You are on the CC list for the bug.