public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christian Nolte <ch.nolte@noltec.org>
To: abhishek desai <abhi00@gmail.com>
Cc: java@gcc.gnu.org
Subject: Re: problem when mapping malloc to GC_malloc.
Date: Thu, 18 Jun 2009 15:14:00 -0000	[thread overview]
Message-ID: <4A3A59BA.4070804@noltec.org> (raw)
In-Reply-To: <898285d30906180800q3b5bd3b2h1d4a11d6a8245e34@mail.gmail.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi Abhishek,

abhishek desai wrote:
> My JNI code includes redefinitions to the malloc, free and realloc
> functions (shown below). These functions call GC_malloc, GC_free and
> GC_realloc respectively. This is done so that any calls to the malloc
> get allocated through the garbage collector. 

I presume you are using Hans Boehm's garbage collector? If so, did you
follow the instructions on:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/simple_example.html

What platform are you developing for? If it is not Linux, you have to
make sure that GC_INIT() is being called before using any of the GC_xxx
functions.


> However this is failing
> with segfault. Any clues why this does not work ?
> I am using this code along with the libgcj library linked dynamically
> with my application.
> 
> void *malloc(size_t size)
> {
>         return GC_malloc(size);
> }
> 
> void *realloc(void *ptr, size_t size)
> {
>         return GC_realloc(ptr, size);
> }
> 
> void free(void *ptr)
> {
>         GC_free(ptr);
> }

Perhaps you can give us some more context. A simple, compilable example
would be great to see where and how exactly you are using your
redefinitions.

Best regards,
Christian


- --
"He's an unconventional pirate paramedic with a mysterious suitcase
 handcuffed to his arm. She's a pregnant gypsy widow from aristocratic
 European stock. They fight crime!"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAko6WboACgkQCNjA0nfhW7xDYwCgpI3ntEEScbqbQOpCkfi1Z3KG
lrQAoI8+xh/swyVSgREAMmjX1B8rIWFl
=A/lO
-----END PGP SIGNATURE-----

  reply	other threads:[~2009-06-18 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-18 15:00 abhishek desai
2009-06-18 15:14 ` Christian Nolte [this message]
2009-06-18 16:30 ` Hans Boehm
2009-06-18 18:18   ` abhishek desai
2009-06-18 19:01     ` BGB
2009-06-18 18:07 ` BGB

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A3A59BA.4070804@noltec.org \
    --to=ch.nolte@noltec.org \
    --cc=abhi00@gmail.com \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).