From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13813 invoked by alias); 29 Jan 2011 08:13:00 -0000 Received: (qmail 13800 invoked by uid 22791); 29 Jan 2011 08:12:59 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_DD,TW_GJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 29 Jan 2011 08:12:54 +0000 From: "patrick.marlier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/47530] New: [trans-mem] tail call optimization problem with _ITM_commitTransaction X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: patrick.marlier at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 29 Jan 2011 11:24:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg03213.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47530 Summary: [trans-mem] tail call optimization problem with _ITM_commitTransaction Product: gcc Version: trans-mem Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: patrick.marlier@gmail.com CC: rth@gcc.gnu.org, aldyh@gcc.gnu.org According to: http://gcc.gnu.org/ml/gcc/2011-01/msg00314.html http://gcc.gnu.org/ml/gcc/2011-01/msg00279.html The tail call optimization should not be possible on _ITM_commitTransaction because this function can go (longjmp) to _ITM_beginTransaction and thus the stack will be corrupted. Here ASM: _function: pushq %r12 pushq %rbp pushq %rbx subq $16, %rsp ... call _ITM_beginTransaction .L8: ... call _ITM_WU8 addq $16, %rsp popq %rbx popq %rbp popq %r12 jmp _ITM_commitTransaction In this example, if _ITM_commitTransaction rolls back to L8, the function epilogue will restore wrong values to registers (modified by the function _ITM_commitTransaction) when leaving the _function. Moreover I think that the function _ITM_beginTransaction should have the flag ECS_RETURNS_TWICE because it is how it behaves (ie the transaction can abort and longjmp behind the _ITM_beginTransaction call). Draft patch proposed in http://gcc.gnu.org/ml/gcc/2011-01/msg00279.html Patrick Marlier.