Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C4239902 for ; Sun, 19 Feb 2012 22:54:57 +0000 (UTC) Received: (qmail 12855 invoked by uid 500); 19 Feb 2012 22:54:56 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 12734 invoked by uid 500); 19 Feb 2012 22:54:56 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 12721 invoked by uid 99); 19 Feb 2012 22:54:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Feb 2012 22:54:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Feb 2012 22:54:54 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id CAAC61C11F0 for ; Sun, 19 Feb 2012 22:54:34 +0000 (UTC) Date: Sun, 19 Feb 2012 22:54:34 +0000 (UTC) From: "Vivek Nadkarni (Created) (JIRA)" To: dev@avro.apache.org Message-ID: <1430116248.1115.1329692074831.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (AVRO-1033) Avro-C reference count fails on x86 and x86-64 for GCC 4.1.0 and earlier MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Avro-C reference count fails on x86 and x86-64 for GCC 4.1.0 and earlier ------------------------------------------------------------------------ Key: AVRO-1033 URL: https://issues.apache.org/jira/browse/AVRO-1033 Project: Avro Issue Type: Bug Components: c Affects Versions: 1.6.2 Environment: Linux on an x86 or x86-64 platform with GCC version less than or equal to 4.1.0. Reporter: Vivek Nadkarni Fix For: 1.6.3 Item 1: ******* In the Avro-C implementation, there is a bug in the Raw x86 assembly performing the atomic increment and decrement operations in refcount.h. Specifically, the assembly language commands (mistakenly) operate on the the pointer (refcount) instead of operating on the memory pointed to (*refcount). This results in memory leaks, when trying to deallocate avro values. This problem only occurs when using GCC versions less than 4.1.0. For GCC versions greater than 4.1.0, the code uses the GCC intrinsic __sync_add_and_fetch() or __sync_sub_and_fetch() instead of the raw x86 assembly, and this works properly. Since this problem is masked for developers working with new(er) GCC compilers, greater than version 4.1.0, one way to "uncover" it is to force the GCC intrinsics off by requiring a higher GCC version (say 8.1.0) to use the GCC intrinsics. Then GCC falls back to using the x86 assembly, and the problem can be seen. I am attaching a sample test case (test_refcount.c), which will show a memory leak when compiled with the raw x86 commands enabled in refcount.h and run with valgrind using the following command: valgrind -v --leak-check=full --track-origins=yes ./test_refcount I am also attaching a simple patch to fix the bug. The patch just replaces (refcount) with (*refcount) in a few places, and the memory leak disappears. Item 2: ******* On a related note, while compiling Avro across several flavors of Linux, we noticed that the GCC atomic intrinsics __sync_add_and_fetch() and __sync_sub_and_fetch() were not implemented for all versions of GCC greater than 4.1.0, causing compile errors. Specifically, the following two versions of GCC don't appear to support the GCC atomic intrinsics: 1. GCC 4.1.2 20080704 (Red Hat 4.1.2-48) 2. GCC 4.4.3 on Mandriva for an i586 target In our local code we have updated the GCC version test in refcount.h to require versions of GCC greater than 4.5.0, before including the GCC intrinsics. We might want to do the same in the global Avro repository. If appropriate, I can create a separate JIRA item for this issue. Please let me know. Cheers, Vivek Nadkarni -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira