malloc, DICE and IPC
Ronald AIGNER
aigner.eurecom at st.com
Wed Mar 30 16:19:38 CEST 2005
Hi,
Tiago Jorge wrote:
<snip>
>
> WOO_Send_Retval WOO_send(void){
> CORBA_Environment env = dice_default_environment;
<snip>
> #####################################################################
>
> all ok, until i get it to run...
> There, he gives me an error (page fault) at the stubs, when
> unmarshalling the return value of the woo_send() call, more precisely,
> when allocating the string(tag) inside the return structure. the line is
> the following:
>
> _dice_return.tag =
> (CORBA_char_ptr)(_dice_corba_env->malloc)(_dice_tmp_offset);
>
> i've checked the string size tha comes from the server and it is correct...
>
> So... why is it page faulting??
That's strange. What version of dice are you using? With the above code
it should not pagefault, but instead jump into the kernel-debugger.
Ok. You are using the default environment, which contains function
pointers to malloc and free functions to allocate memory for such things
as string returned from the server. These functions are (in old versions
of dice set to NULL -> pagefault) or a default function (in the latest
version), which jumps into the kernel debugger (to allow to see why its
pagefaulting :).
If you turn on warnings when using dice (-Wall or see --help for other
options) it tells you when and for which variable it uses malloc. The
idea is, that you can provide your own versions of malloc and free (just
have to have the same signature) and set them in the local environment:
CORBA_Environment env = dice_default_environment;
env.malloc = (dice_malloc)malloc;
The cast is to eliminate a warning: the libc malloc usually uses size_t
type, which is not defined in L4Env.
Hope that helps,
Ron.
--
With regards
Ronald Aigner @ ST Microelectronics
aigner.eurecom at st.com
More information about the l4-hackers
mailing list