caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Garbage Again
@ 2001-12-28 15:22 Warp
  2002-01-03 14:35 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Warp @ 2001-12-28 15:22 UTC (permalink / raw)
  To: OCaml

It crashed again....
First, I'm allocating memory ( I think it's the good way to do it ) :
------------

 value *windata = malloc(sizeof(value));

 messageid = alloc(1,MSGID_TAG);
 Store_field(messageid,1,Val_int(0));

 handletag = alloc(1,HANDLE_TAG);
 Store_field(handletag,1,Val_int(0));

 message = alloc(5,MESSAGE_TAG);
 Store_field(message,0,handletag);
 Store_field(message,1,messageid);
 Store_field(message,2,Val_int(0)); // wParam
 Store_field(message,3,Val_int(0)); // lParam
 Store_field(message,4,Val_int(0)); // MSG*

 *windata = alloc(4,WINDOW_TAG);
 register_global_root(windata);
 Store_field(*windata,0,Val_unit);
 Store_field(*windata,1,callback);
 Store_field(*windata,2,message);
 Store_field(*windata,3,Val_int(func)); // default proc

---------
Then, creating the window, and linking custom data and handle

HWND handle = CreateWindow( .... )
// store handle into data
Store_field(*windata,0,Val_int(handle));
// store data into handle
SetWindowLong(handle,GWL_USERDATA,(long)windata);

--------
And my windowProc :
having parameters  ( hwnd, uMsg, wParam, lParam )

 windata = (value*)GetWindowLong(hwnd,GWL_USERDATA);
 callback = Field(*windata,1);

// update message fields
 message = Field(*windata,2);
 Store_field(Field(message,0),0,Val_int(hwnd));
 Store_field(Field(message,1),0,Val_int(uMsg));
 Store_field(message,2,Val_int(wParam));
 Store_field(message,3,Val_int(lParam));

// caml callback
 result = Int_val(callbackN_exn(callback,1,&message));
 return result;

---------
I got a crash in callbackN_exn / interprete / minor_collection /
empty_minor_head / oldify_local_root / .... (4 oldify calls) / *p = v
 minor_gc.c:122)

I can see that message is being collected, but I don't know why because
*windata contains it so....
I've tryed both with/without CAML* garbage macros, it doesn't work

Thanks for any help / clue.

Warp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-01-03 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-28 15:22 [Caml-list] Garbage Again Warp
2002-01-03 14:35 ` Xavier Leroy
2002-01-03 15:42   ` warplayer

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 NNTP newsgroup(s).