mfp changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.11.2 released | Inscription for OCaml Meeting 2010 is opened http://wiki.cocan.org/events/europe/ocamlmeetingparis2010
Smerdyakov has joined #ocaml
pimmhogeling has quit [Ping timeout: 256 seconds]
bzzbzz has joined #ocaml
Anarchos has joined #ocaml
thrasibule has joined #ocaml
Smerdyakov has quit [Quit: Leaving]
slash_ has quit [Quit: Lost terminal]
avsm1 has quit [Quit: Leaving.]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
rwmjones has quit [Read error: Operation timed out]
Drk-Sd has quit [Quit: night]
jknick has quit [Quit: Lost terminal]
threeve has joined #ocaml
_unK has quit [Remote host closed the connection]
<Alpounet> yziquel, disable the GC ?
<yziquel> yes. to see if it's causing my problems.
<Alpounet> OCaml's runtime is based on it, afaik, so my guess is that it isn't that much of a good idea
cognizant-cog has joined #ocaml
<Alpounet> you can get GC statistics etc
<Alpounet> force GC'ing
<yziquel> (segfaults with caml_copy_string)
<Alpounet> it may help revealing your problem
<yziquel> main program is C, calling OCaml code.
<Alpounet> yziquel, any potential scope issues with ocaml<->native code ?
<Alpounet> like a pointer already released but still manipulated from OCaml code
<Alpounet> freed*
<yziquel> that's what i'd like to know.
<yziquel> disabling the GC, or at least heap compaction, would be useful here.
<Alpounet> hmm
<Alpounet> gdb isn't of help here ?
<yziquel> nope.
<Alpounet> just sit and watch your pointers in action
<yziquel> it crashes as soon as the callback runs. first opcode.
<Alpounet> and see if one goes into ocaml code while in an invalid state
<Alpounet> watching what you pass to caml_copy_string gives you any information ?
<yziquel> currently going through the asm of caml_copy_string to see what's going on.
<yziquel> what I pass to caml_copy_string is a string.
<yziquel> i want to check what i get out of it. not easy.
<Alpounet> I guess caml_copy_string just accesses your pointer and copies cells from there
<Alpounet> thus the address may be invalid
<Alpounet> hmm yeah
<yziquel> { value s = Val_unit; Begin_roots1(s); value s = caml_copy_string(my_string); value x = caml_callback(*caml_named_value("value of string"), s); End_roots(); }
yakischloba has quit [Quit: Leaving.]
<yziquel> Alpounet: the repnz scas %es:(%rdi),%al instruction, you mean?
<yziquel> %rdi: first argument passed to caml_copy_string (amd64). a char *
<Alpounet> I guess it's somewhere in there that you have an invalid address being accessed, or some similar undesired behavior
<Alpounet> so there
<Alpounet> it segfaults on value s = caml_copy_string(my_string);
<yziquel> no
<yziquel> it segfaults in the first opcode of the callback function. i.e. as soon as it enters ocaml code.
<yziquel> i believe it tries to access the value, i.e. the ocaml string.
<Alpounet> yziquel, are you including caml/alloc.h ?
<yziquel> memory.h mlvalues.h and callback.h
<Alpounet> including caml/alloc.h should fix your issue
<yziquel> callq 0x40b39f <caml_alloc_string> is screwed?
<Alpounet> it seems the return type is biased depending on whether you include alloc.h or not
<yziquel> mkay... that's a pain.
<Alpounet> yziquel, does it work now ?
<yziquel> wait.
<Alpounet> (if it's the issue, yeah, I agree, it's much of a pain)
<yziquel> i'm pretty sure that it's this,
<yziquel> i'm surprised that the bug report is closed.
<Alpounet> yeah
<Alpounet> going the following way "you must include caml/alloc.h, that's all, like if we were gonna do it for you"
<yziquel> i mean: you want to call OCaml from C. you compile your .o, your .cmx. you ocamlopt the whole bunch. (the manual doc isn't overly clear on the topic btw). you fill in headers one by one. and then you cannot allocate on C side just because you're on amd64?
<yziquel> at least there should be a more detailed doc on embedding OCaml in C code in the manual. with an alloc.h included.
<Alpounet> well
<Alpounet> memory.h SHOULD include alloc.h
<Alpounet> or maybe I'm stupid ?
<Alpounet> but hey
<Alpounet> how do you handle memory without allocating ?
<Alpounet> and, as we've just seen it, such a bug is quite tricky to find.
<yziquel> it works now, with alloc.h
<Alpounet> yeah, great !
<Alpounet> now we'll both know it... in case
<yziquel> yeah sure. but the idea of ocaml segfaulting... doesn't cut it...
<Alpounet> heh
<Alpounet> now, 4AM in France, I'm off
<Alpounet> ttyl
pad has quit [Remote host closed the connection]
M|_ has joined #ocaml
Asmadeus_ has joined #ocaml
msteele_ has joined #ocaml
LionMade1fLions has joined #ocaml
bitbckt_ has joined #ocaml
fremo___ has joined #ocaml
bitbckt has quit [Write error: Broken pipe]
fremo_ has quit [Write error: Broken pipe]
dark has joined #ocaml
LionMadeOfLions has quit [Ping timeout: 265 seconds]
M| has quit [Ping timeout: 265 seconds]
Asmadeus has quit [Ping timeout: 265 seconds]
msteele has quit [Ping timeout: 265 seconds]
cognizant-cog has quit [Quit: ChatZilla 0.9.86 [Firefox 3.5.7/20100106054534]]
cognizant-cog has joined #ocaml
cognizant-cog has quit [Quit: ChatZilla 0.9.86 [Firefox 3.5.7/20100106054534]]
Associat0r has quit [Quit: Associat0r]
yakischloba has joined #ocaml
bzzbzz_ has joined #ocaml
caligula__ has joined #ocaml
cognizant-cog has joined #ocaml
bzzbzz has quit [Read error: Connection reset by peer]
caligula_ has quit [Remote host closed the connection]
sabren has joined #ocaml
sabren has quit []
threeve has quit [Quit: threeve]
ulfdoz has joined #ocaml
Gooffy has joined #ocaml
cognizant-cog has quit [Quit: ChatZilla 0.9.86 [Firefox 3.5.7/20100106054534]]
bzzbzz_ has quit [Quit: leaving]
ulfdoz has quit [Ping timeout: 265 seconds]
ttamttam has joined #ocaml
joewilliams is now known as joewilliams_away
Gooffy has quit [Read error: Connection reset by peer]
Gooffy has joined #ocaml
nop has joined #ocaml
yakischloba has quit [Quit: Leaving.]
nop has quit [Ping timeout: 248 seconds]
ikaros has joined #ocaml
nop has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
cygnus_ has quit [Ping timeout: 248 seconds]
avsm has joined #ocaml
Yoric has joined #ocaml
slash_ has joined #ocaml
Yoric has quit [Quit: Yoric]
_zack has joined #ocaml
seafood has joined #ocaml
seafood has quit [Client Quit]
valross has quit [Quit: Ex-Chat]
sgnb`` has joined #ocaml
nop_ has joined #ocaml
rbancrof1 has joined #ocaml
maskd- has joined #ocaml
nop has quit [*.net *.split]
maskd has quit [*.net *.split]
bjorkintosh has quit [*.net *.split]
rbancroft has quit [*.net *.split]
gim has quit [*.net *.split]
sgnb` has quit [*.net *.split]
_unK has joined #ocaml
tmaedaZ is now known as tmaeda
maskd- is now known as maskd
yziquel has quit [Ping timeout: 252 seconds]
mrvn has joined #ocaml
<mrvn> Hi.
<quelqun_dautre> hi.
<mrvn> I have a little design problem. I have a C function that takes a callback as argument and returns. Sometime later it then calls the callback either with a success or with an error. I would like to throw an exception but how do I throw that into the callback?
<mrvn> Should I use 2 callbacks or use a variant type to pass either the succes or exception?
execve has joined #ocaml
<fraggle_> show us the source :)
<mrvn> The source that doesn't exist because I don't know how to best write it?
<mrvn> val read : context -> Unix.file_descr -> int64 -> Buffer.t -> (XXX -> unit) -> unit
<mrvn> If the read succeeds the callback should get the Buffer.t back. If it fails then the Unix.error
<fraggle_> it looks like a monad
<mrvn> Async IO
jao has quit [Ping timeout: 256 seconds]
<Alpounet> mrvn, do you really really want an exception ? 'cause you may use a type like : type 'a computation_that_can_fail = Error of string | Success of 'a
<Alpounet> and indeed it's quite much in the monad spirit
<mrvn> Yes I would like an exception.
<mrvn> Makes it if only for the sake of learning how to do that.
<Alpounet> mrvn, then I'd go for a variant type
<mrvn> and then match res with Success buf -> ... | Fail exn -> raise exn ?
<fraggle_> should do the trick indeed
<mrvn> ugly
<Alpounet> mrvn, yeah but with appropriate chaining functions and all, your code would be quite elegant
<fraggle_> you want async I/O on string ?
<mrvn> fraggle_: Only on Aio.Buffer.t, which is a page aligned Bigarray
<mrvn> Ocaml strings can be moved by the GC so no async IO with them.
<fraggle_> yep, and you use Buffer module to store them
<mrvn> type t = private (int, int8_unsigned_elt, c_layout) Array1.t
<mrvn> external create : int -> t = "caml_aio_buffer_create"
Asmadeus_ is now known as Asmadeus
<mrvn> Need a special Bigarray for the alignment and you can't pass it a normal one.
<mrvn> I also do truely evil things like: let buf = ((Obj.magic buf) : (int, int16_unsigned_elt, c_layout) Array1.t) in Array1.unsafe_get buf off
<fraggle_> it's a read/write buffer
<mrvn> That is still a string.
<fraggle_> it use a callback :)
<mrvn> But doesn't throw the exception to the callback but to the calling function.
<mrvn> Since my read is async I only know that there will be an exception when the callback is invoked.
<fraggle_> why don't you wait on non blocking mode during the read and bail out when an error is thrown ?
<mrvn> Because then it wouldn't be async.
<fraggle_> it's not AIO
<fraggle_> but it works :)
<mrvn> A libaio-ocaml that does sync read/writes. Great idea.
boscop has joined #ocaml
<fraggle_> ;-)
<mrvn> fraggle_: That is me.
<fraggle_> ah ok
* fraggle_ hide
<fraggle_> well, you can ape glibc implemantation
<mrvn> That one uses threads. I'm using libaio.
<mrvn> The linux kernels own async IO syscalls.
<fraggle_> you want to do a binding then
<fraggle_> non portable
<fraggle_> camlidl would help then
<mrvn> That is what I'm doing and I don't care about portability to non linux.
<fraggle_> you just want to map a C function to a OCaml one ?
<mrvn> No. I want to have a nice interface.
fomatt has quit [Ping timeout: 252 seconds]
<fraggle_> I really suggest using camlidl as a starting point to do the fisrt mapping
<fraggle_> then refine the API
<mrvn> camlidl won't help one bit in designing the api.
<fraggle_> sure, but it's just to have a first code snippet
<mrvn> already have the bindings. Except for the callback type basically.
<fraggle_> ok I look to your code
Gooffy has quit [Quit: Leaving.]
Yoric has joined #ocaml
<fraggle_> as far as i understand, all your callback are in C
<mrvn> Not really. C doesn't have callbacks in the interface. It gives me an event that contains a pointer into my table of callbacks.
<mrvn> // Get callback and buffer
<mrvn> ml_fn = Field(ml_ctx, slot);
<mrvn> ml_buf = Field(ml_ctx, slot + 1);
<fraggle_> quite honestly, Alpounet's solution is the simplest way to implement want you want
<fraggle_> s/want/what/
<mrvn> type result = Result of Buffer.t | Errno of int | Partial of Buffer.t * int
<mrvn> val read : context -> Unix.file_descr -> int64 -> Buffer.t -> (result -> unit) -> unit
<mrvn> That is what I have now.
<mrvn> Errno of int is suposed to become the Unix.error
<mrvn> How do I specify an int64 as hex? 0x123456789abcdefLL seems wrong
<mrvn> nm, too many L
<mrvn> *grummel* Reading an int, int32 or int64 from my Buffer segfaults.
<mrvn> Can't Obj.magic an int8 Bigarray to int32/int64
_unK has quit [Remote host closed the connection]
<mrvn> I wonder what is faster now. Reading bytes and shifting them into int32/int64 in ocaml or a call that does it directly.
<Camarade_Tux> anyone with some experience with FRP? I'm trying to decide if it fits what I need (reading on it right now): I have a set of tabs which is stored as a list and two keyboard shortcuts: ^t to create a new tab and ^w to close one, unfortunately, callbacks in lablgtk return a boolean but I need to return the updated list
tmaeda is now known as tmaedaZ
<Camarade_Tux> would frp fit this?
<_zack> thelema: JFYI, the homepage of batteries still points to 1.0.0, whereas 1.0.1 is out
thrasibule has quit [Ping timeout: 256 seconds]
Pepe_ has quit [Ping timeout: 240 seconds]
Pepe_ has joined #ocaml
munga has joined #ocaml
_unK has joined #ocaml
palomer has joined #ocaml
pimmhogeling has joined #ocaml
tmaedaZ is now known as tmaeda
threeve has joined #ocaml
munga has quit [Quit: Ex-Chat]
munga has joined #ocaml
<mrvn> http://mrvn.homeip.net/libaio-ocaml/ if anyone is interested
<mehdid> thelema: is batteries v1.1 out?
<Camarade_Tux> iirc there is a library to use FRP in gtk apps with lwt but I can't remember the name nor find it, anyone remember what it is?
<Alpounet> Camarade_Tux, isn't it React ?
<Alpounet> or something like that.
<Camarade_Tux> Alpounet: actually I think it might be React but I can't find anything mentionning an interface between the two
<Alpounet> Camarade_Tux, I remember messages on the mailing list
_unK has quit [Remote host closed the connection]
<mehdid> Camarade_Tux: isn't lwt_glib what you are looking for?
<Camarade_Tux> mehdid: I may be wrong but I'm under the impression there was a more complete bridge
_unK has joined #ocaml
_zack has quit [Quit: Leaving.]
palomer has quit [Ping timeout: 256 seconds]
<Camarade_Tux> ok, I was most probably wrong
sysop_fb has quit [Ping timeout: 240 seconds]
<thelema> mehdid: well, almost. I was in the process of releasing it, and luckily didn't complete the process
<mehdid> why luckily?
<thelema> mehdid: it would have broken backwards compatibility, and would have to have been numbered 2.0.0
sysop_fb has joined #ocaml
<thelema> link fixed.
<mehdid> oh :)
<thelema> I'm tempted to use git tags + github for releases...
<thelema> mehdid: yes, we need to get backwards compatibility for the threads/no-threads compilation
<thelema> I think I'm going to make the easy fix short term, with a note (where?) that this'll change once we hit 2.0
_unK has quit [Remote host closed the connection]
derdon has joined #ocaml
<mehdid> I'd say in the ChangeLog file, if there is one (actually, there is one but seems empty)
<thelema> The changelog is officially 'git log'
joewilliams_away is now known as joewilliams
_unK has joined #ocaml
itewsh has joined #ocaml
threeve has quit [Ping timeout: 248 seconds]
<avsm> github works great, i find
<avsm> and the issue tracker and page hosting "just works" also.
threeve has joined #ocaml
<thelema> avsm: I'm happy with it, and wouldn't mind deprecating the ocaml forge, except for a few things
bitbckt_ has left #ocaml []
tmaeda is now known as tmaedaZ
<mehdid> Camarade_Tux: http://code.google.com/p/ocamlrt/?
<Camarade_Tux> mehdid: I saw it but it has last been modified 3 years ago
<Camarade_Tux> mehdid: also, there is an ocamlrt2 (mentionned on lambda-ultimate) but the link is dead and the author said he has stopped working on it
<mehdid> ok
<Camarade_Tux> I think I'll write something myself, not sure when though
<mrvn> Camarade_Tux: another Do-It-Yourself guy. :)
yakischloba has joined #ocaml
<Camarade_Tux> mrvn: unfortunately, yes: gives me much more work ;-)
<avsm> thelema: what are the things with github you dont like?
ido has quit [Remote host closed the connection]
dark has quit [Remote host closed the connection]
avsm has quit [Quit: Leaving.]
<Camarade_Tux> now, I have no idea how I'm going to make react and lablgtk work together :-)
<derdon> Camarade_Tux: are you familiar with menus in LablGTK?
tty56 has joined #ocaml
<Camarade_Tux> derdon: a bit but just ask
_zack has joined #ocaml
<derdon> Camarade_Tux: I want to use image items in the file menu (or in menus in general)
seanmcl has joined #ocaml
<derdon> Camarade_Tux: but the item is not dislpayed, only the usual one (line 20)
ttamttam has quit [Quit: Leaving.]
<Camarade_Tux> derdon: why go through the "factory" thing?
<derdon> Camarade_Tux: I learned it like that in a tutorial, but I think it looks rather ugly
<Camarade_Tux> which tutorial?
<derdon> Camarade_Tux: this one: http://www.ocaml-tutorial.org/introduction_to_gtk
<Camarade_Tux> oh, I read the page a bit but see nothing about menus
<Camarade_Tux> you might want to see: http://plus.kaist.ac.kr/~shoh/ocaml/lablgtk2/lablgtk2-tutorial/c1731.html , I think it's more complete
nop_ has quit [Ping timeout: 248 seconds]
<derdon> Camarade_Tux: and when I add the image buttons omitting factory, it will work?
<Camarade_Tux> no idea :-)
<thelema> The Itemfactory is much easier to use, and to add new menus to, although writing a few wrapper functions to create menus using the manual method could go a long way towards usability. With the Itemfactory, it is not possible to add images or the character '/' to the menus.
<thelema> <from the page Camarade_Tux linked to>
<Camarade_Tux> bah, should have seen it
<Camarade_Tux> on the other hand, I removed firefox and since my browser isn't ready, I'm stuck without a "search" function :P
<derdon> thelema: ah, I see
<derdon> yeah, it works now :)
<derdon> I love you guys!
<thelema> glad to help
<derdon> glad to be helped :)
<thelema> now can you pre-emptively pass it on by... improving the ocaml-tutorial docs?
<Camarade_Tux> :-)
<derdon> thelema: not yet. still not experienced enough.
<derdon> thelema: In addition, I work on the German translation
<thelema> I don't buy the "not experienced" argument, but I'll let it slide this time. :)
<derdon> well, it works :)
<derdon> what about the "too much homework" argument?
<Camarade_Tux> not experienced enough to be confident ;-)
<thelema> get off IRC if you have too much homework. :)
<derdon> thelema: you're right. but OCaml is much more fun
<thelema> yes it is.
LionMade1fLions has left #ocaml []
LionMade1fLions has joined #ocaml
ttamttam has joined #ocaml
bjorkintosh has joined #ocaml
Yoric has quit [Quit: Yoric]
ttamttam has quit [Quit: Leaving.]
Leonidas has joined #ocaml
ikaros has joined #ocaml
nop has joined #ocaml
_unK has quit [Remote host closed the connection]
tty56 has quit [Quit: tty56]
Submarine has joined #ocaml
Submarine has quit [Read error: Connection reset by peer]
ikaros has quit [Quit: Leave the magic to Houdini]
Submarine has joined #ocaml
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
derdon has quit [Quit: derdon]
Submarine has quit [Read error: Connection reset by peer]
ulfdoz has joined #ocaml
execve has quit [Ping timeout: 276 seconds]
DaveS has joined #ocaml
yakischloba has quit [Quit: Leaving.]
Yoric has joined #ocaml
derdon has joined #ocaml
nop has quit [Ping timeout: 252 seconds]
ccasin has joined #ocaml
ccasin has quit [Remote host closed the connection]
ccasin has joined #ocaml
nop has joined #ocaml
seanmcl has quit [Quit: seanmcl]
seanmcl has joined #ocaml
nop has quit [Ping timeout: 246 seconds]
jao has joined #ocaml
yakischloba has joined #ocaml
<derdon> yay, made it with List.iter finally: http://paste.pocoo.org/show/179420/
execve has joined #ocaml
ikaros has joined #ocaml
execve has quit [Ping timeout: 264 seconds]
<thelema> nice. I like the data-driven solution.
munga has quit [Ping timeout: 245 seconds]
thelema has quit [Remote host closed the connection]
jao has quit [Read error: Connection reset by peer]
jao has joined #ocaml
Drk-Sd has joined #ocaml
Drk-Sd has quit [Client Quit]
execve has joined #ocaml
Dawrk-Side has joined #ocaml
Dawrk-Side has quit [Client Quit]
execve has quit [Ping timeout: 246 seconds]
Yoric has quit [Quit: Yoric]
execve has joined #ocaml
nop has joined #ocaml
<derdon> search for ":>" in ocaml-tutorial.org
nop has quit [Ping timeout: 264 seconds]
nop has joined #ocaml
dark has joined #ocaml
nop has quit [Ping timeout: 240 seconds]
seanmcl has quit [Quit: seanmcl]
ulfdoz has quit [Ping timeout: 252 seconds]
ccasin has quit [Quit: Leaving]
execve has quit [Ping timeout: 260 seconds]
Drk-Sd has joined #ocaml
derdon has quit [Quit: derdon]
_zack has quit [Quit: Leaving.]
ikaros has quit [Quit: Leave the magic to Houdini]
BigJ has quit [Ping timeout: 245 seconds]
threeve has quit [Quit: threeve]
Amorphous has quit [Ping timeout: 264 seconds]
BigJ has joined #ocaml
BigJ has quit [Ping timeout: 246 seconds]
Drk-Sd has quit [Quit: foo]
tmaedaZ is now known as tmaeda
Amorphous has joined #ocaml
slash_ has quit [Quit: leaving]
seanmcl has joined #ocaml