public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/60282] New: memory leak - Double from string, _Jv_Balloc
@ 2014-02-20  8:23 antoine.dymond at gmail dot com
  0 siblings, 0 replies; only message in thread
From: antoine.dymond at gmail dot com @ 2014-02-20  8:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60282

            Bug ID: 60282
           Summary: memory leak - Double from string, _Jv_Balloc
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoine.dymond at gmail dot com

I believe there is memory leak when creating a Double from a string. For
example

double value = (new Double("3.14")).doubleValue();

Valgrind output:

== 56 bytes in 1 blocks are definitely lost in loss record 17 of 31
==    at 0x4C2A2DB: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==    by 0x6DE98D1: _Jv_Balloc (in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x6DEA378: _Jv_d2b (in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x6DE4BDB: _Jv_dtoa_r (in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x6DE5F0F: _Jv_dtoa (in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x65CBF9D: java::lang::String* java::lang::VMDouble::toString(double,
bool) (in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x6926404: java::lang::String* java::lang::Double::toString(double)
(in /usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x6926418: java::lang::AbstractStringBuffer*
java::lang::AbstractStringBuffer::append(double) (in
/usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)
==    by 0x69264D8: java::lang::StringBuilder*
java::lang::StringBuilder::append(double) (in
/usr/lib/x86_64-linux-gnu/libgcj.so.14.0.0)



Reconstruct info
-----------------

$ more double_from_str.java 

public class double_from_str {
    public static void convert(){
    double value = (new Double("3.14")).doubleValue();
    System.out.printf("pi = " + value + "\n");
    }

}

$ more main.cpp

#include <stdio.h>
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>
#include "double_from_str.h"

int main(int argc, char *argv[])
{
  using namespace java::lang;
  try
    {
      JvCreateJavaVM(NULL);
      JvAttachCurrentThread(NULL, NULL);
      double_from_str().convert();
      JvDetachCurrentThread();
      return 0;
    }
  catch (Throwable *t)
    {
      printf("Unhandled Java exception\n");
      t->printStackTrace();
      return 1;
    }
}

$ make -B

gcj -fPIC -c double_from_str.java    
gcj -C double_from_str.java
gcjh double_from_str.class
gcj -g -lstdc++ double_from_str.o main.cpp -o main.o
cc1plus: warning: command line option
‘-fbootclasspath=./:/usr/share/java/libgcj-4.8.jar’ is valid for Java but not
for C++ [enabled by default]

$ valgrind --leak-check=yes ./main.o

...


$ apt-cache show valgrind
...
Architecture: amd64
Version: 1:3.8.1-4ubuntu1
...
>From gcc-bugs-return-444303-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 20 08:34:01 2014
Return-Path: <gcc-bugs-return-444303-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17240 invoked by alias); 20 Feb 2014 08:34:01 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 17168 invoked by uid 48); 20 Feb 2014 08:33:56 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60283] New: Wrong code: decode_omp_directive: implicit_pure not correctly unset
Date: Thu, 20 Feb 2014 08:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter
Message-ID: <bug-60283-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg02060.txt.bz2
Content-length: 884

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`283

            Bug ID: 60283
           Summary: Wrong code: decode_omp_directive: implicit_pure not
                    correctly unset
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org

decode_omp_directive (void) {
...
  if (gfc_implicit_pure (NULL))
    gfc_current_ns->proc_name->attr.implicit_pure = 0;

That code probably fails if one has BLOCK, which starts a new namespace.

Cf. discussion for OpenACC at
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg01194.html


Patch r168600 of 2011-01-08 added this assignment and possibly others; I wonder
whether those also have problems with BLOCKS.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-20  8:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20  8:23 [Bug libgcj/60282] New: memory leak - Double from string, _Jv_Balloc antoine.dymond at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).