gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
drunK has quit [Remote host closed the connection]
hcube has quit [Ping timeout: 265 seconds]
zubeen has quit [Remote host closed the connection]
ftrvxmtrx has quit [Quit: Leaving]
deech has joined #ocaml
wuj has joined #ocaml
wuj has quit [Ping timeout: 245 seconds]
deech has quit [Ping timeout: 276 seconds]
__marius__ has quit [Quit: leaving]
joewilliams is now known as joewilliams_away
__marius__ has joined #ocaml
hcube has joined #ocaml
<__marius__> ls
<rwmjones> anyone using glade with lablgtk2? or want to suggest what tool I should be using with lablgtk2? (I think glade has been obsoleted)
<adrien> hi __marius__
<adrien> rwmjones: I'm not, I've tried it but in the end, you still have to install all the callbacks by hand and I find it harder to do when the code has been generated and isn't mine
<rwmjones> ok
<adrien> might be nice to sketch the interface in a stricter way than a paper and a pen however
<rwmjones> yeah I might use it for prototyping
* rwmjones hates doing gui interfaces ...
<adrien> I'm starting to like it :-)
<adrien> but I'm playing with react and several other things and _that_ is the fun part ;-)
<rwmjones> anyhow, glade is not obsolete, it seems
<rwmjones> nice, glade just segfaulted
<rwmjones> in the first ~ 1 minute of use
<adrien> heh
<adrien> I'm under the impression libglade is obsolete (functionnality seems to have been merged in gtk as GtkBuilder) but the glade tool itself isn't
Yoric has joined #ocaml
DimitryKakadu has joined #ocaml
lpereira has joined #ocaml
init1 has joined #ocaml
<hcube> hi! I'm trying to make an iphone app in ocaml. I've compiled every required lib to arm and i run a hello world fine on iphone compiled with ocamlopt.
<hcube> but for a complex example (json parser: yojson-0.8.1) it does not worked. the program ended with an exception. it could not parse ints
<hcube> after litle debug investigation i've found that max_int's value is -1
<hcube> when i print it with Printf.printf "maxint %u\n" max_int it prints 2147483647
<hcube> are int values only 30 bit wide in arm architectures?
<flux> yes
<flux> well, no actually
<flux> 31 bits
<flux> on any 32-bit architecture
<flux> but they are signed
<hcube> ok, and is max_int a signed type?
<flux> it's an integere, therefore it's signed :)
<hcube> so max_int value should be 2 ^ 30
<hcube> where is max_int defined? there are multiple definitions in stdlib: int32.ml int64.ml nativeint.ml pervasives.ml
<flux> pervasives.ml
<flux> Pervasives is the module that is automatically opened for all compliation units
<hcube> let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62)
<hcube> let max_int = min_int - 1
<hcube> that's the definition in pervasives (then pervasives is same to Prelude in haskell)
BiDOrD has quit [Quit: BiDOrD]
BiDOrD has joined #ocaml
<hcube> what do you think what's went wrong?
Tobu has quit [Quit: Leaving.]
rks has joined #ocaml
<mfp> hcube: arch detection not working, and OCaml believing it's a 64-bit platform?
EliasAmaral has joined #ocaml
EliasAmaral has quit [Client Quit]
dark has joined #ocaml
<dark> I have a long running program with a memory leak. I use some third-party libraries. I was suspecting of ocaml-imagemagick (it has some notes that warn against leaks) but, removing it from the program, the leak persists. How one could know _where_ in the code is the leak?
<kerneis> dark: with a C program I would use valgrind, but I don't know if it will give you anything useful (because of the GC)
<dark> i am suspecting that the leak is in some C code
<hcube> here is the configuer script output: http://pastebin.com/HKTS0vRV
<dark> kerneis, can valgrind, for C, point out where in source code the leak is?
<kerneis> dark: for sur, provided you compile in debug mode
<kerneis> once the program quit, it will list every location that has not been freed, and were it was allocated
<hcube> this is the right output: http://pastebin.com/WeAwiF7p
<kerneis> dark: note that you do not want to use cachegrind, but the default valgrind mode instead
<kerneis> (to find memory leaks)
<adrien> you are using other C libraries?
ikaros has joined #ocaml
<mfp> hcube: is min_int 0?
<mfp> hcube: what do you mean by "right output"? I noted that only one of them has got -m32
<mfp> if you're getting the error because you're using the one without -m32, you set the CC compiler manually by giving the -cc option to configure (see INSTALL)
<hcube> mfp: this is the right config output: http://pastebin.com/WeAwiF7p
<hcube> the difference is -m32
<mfp> OK then,
<mfp> you can try with ./configure -cc="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 -arch armv6 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk"
<mfp> uh, is it normal to have -arch armv6 -arch armv7 ?
<hcube> yes, it will produce an universal binary
<hcube> armv6 is for iphone3G and armv7 for iphone3GS and iphone4 both armv and armv7 are 32 bit architectures
<hcube> here is the result of this expression: Printf.printf "min_int %d %u max_int %d %u\n" min_int min_int max_int max_int;
<hcube> min_int 0 0 max_int -1 2147483647
<hcube> here is my build script: http://pastebin.com/QxnNiVyz
<hcube> but i had to modify
<hcube> the CC because compiled with the original command found in the tutorial it does not linked with my xcode iphone project
<mfp> not having access to any of this, I can't really help you any further, but it seems you're quite close. There's definitely some 32/64-bit issue with the compiler/assembler.
<hcube> ok, thank you anyway ;)
<dark> adrien, me? not sure, but I'm using PG'OCaml, ExtUnix, Batteries, ocaml-magic (for finding the mime type of a file), ..
<dark> two structure I keep the entire program is a ocaml-magic cookie (I think it is a file descr of the database) and a PG'OCaml db handler
<dark> structures
<adrien> sound like small objects
<dark> they should have constant size
<adrien> what's the rate of the leak?
<dark> after a day, I had 1.5gb
<dark> I was looking at top, in some minutes it had 3% of ram.. 3.1, 3.2.. I thought it was growing because the GC was delaying something
<adrien> and the best way to start is probably to try to create a reproducer (and valgrind can be a good tool to find out where to look at too :-) )
<dark> reproducer?
<adrien> there's one thing with C bindings: finalizers are only called ater a compaction I think (or a major?) but for your objects it shouldn't be a problem
<adrien> dark: reduced test-case
<mfp> dark: you could maybe patch the GC to collect stats (block kinds and sizes), those could help you find the culprit
<dark> can't Gc module of stdlib do this?
<mfp> not the stats that would help you
<dark> block kind? I thought type information was lost on runtime
<mfp> the type info is erased, but some info is needed by the GC: there are different kinds of blocks: strings, tuples/non-constant constructors, floats, custom blocks...
<mfp> see byterun/mlvalues.h
<mfp> you could also inspect the identifier in the custom_operations struct associated to custom blocks
<adrien> wasn't there an update of the memprof patch or 3.10 at least?
<mfp> had forgotten about memprof
<kaustuv> Isn't that subsumed by http://ocamlviz.forge.ocamlcore.org/ these days?
<mfp> IIRC ocamlviz gives higher-level (macroscopic) data
<mfp> you have to instrument hashtbls and the like manually
<mfp> or using a camlp4-extension; at any rate, it requires recompilation of the code
asmanur_ has quit [Ping timeout: 265 seconds]
cods has quit [Changing host]
cods has joined #ocaml
asmanur has joined #ocaml
Tobu has joined #ocaml
dark has quit [Ping timeout: 240 seconds]
SurfMaths has joined #ocaml
olosomedudepizza has joined #ocaml
olosomedudepizza has quit [Remote host closed the connection]
<hcube> i'm here again
<hcube> i think this definition of min_int is wrong: let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62)
<hcube> in 32 bit architecture
Amorphous has quit [Read error: Operation timed out]
<hcube> this should be the correct one: let min_int = 1 lsl (if 1 lsl 32 = 0 then 30 else 62)
<hcube> right?
<SurfMaths> hcube: OCaml integers have 31 or 63 bits. (the first bit is used as a mark for direct objects)
<hcube> i see, but is that expression is evaluated in cpu? in that case it is wrong
<hcube> (on 32 bit machines)
<SurfMaths> Yes, but the « = » operator only see the 31 last bits.
<SurfMaths> Because if the first is not 0, then it's a non direct objets, it should be dereferenced.
<SurfMaths> (it's a pointer)
<SurfMaths> And, when OCaml is making an integer operation, he apply a and-mask to be sure that the first bit is 0.
<hcube> ah, ok. the problem is that it's result is 0 on 32 bit arm cpu
<hcube> is it possible that the codegen is bad?
<SurfMaths> The result of what ?
<hcube> let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62)
<hcube> min_int = 0
<SurfMaths> And « let min_int = 1 lsl (if 1 lsl 63 = 0 then 62 else 30);; » ?
Amorphous has joined #ocaml
schmrkc has quit [Ping timeout: 264 seconds]
<SurfMaths> There is also a « min_int » constant already defined in pervasives.ml.
<SurfMaths> And, I think that « lnot (-1 lsr 1);; » is better.
<hcube> let min_int = 1 lsl (if 1 lsl 63 = 0 then 62 else 30);; gives 0 too
<hcube> i've tested this: let min_int2 = 1 lsl (if 1 lsl 63 = 0 then 62 else 30);;
<SurfMaths> Display all non-null power of two on your machine. To see where is the max_int.
<hcube> ok
<SurfMaths> But as I said, « lnot (-1 lsr 1);; » should work.
<SurfMaths> min_int = -1073741824 (on 32 bits architectures) -4611686018427387904 (on 64 bits ones)
<hcube> it seems we have only 30 bits?
<SurfMaths> Nop, you have 31 bits (due to OCaml), but the last one is a « sign » bit.
<SurfMaths> This was produced by an OCaml program ?
<hcube> yes
<hcube> running on iphone
<hcube> compiled wit ocamlopt
<hcube> *with
<SurfMaths> What is the result of « 1 lsl 30 » ?
Yoric has quit [Quit: Yoric]
<hcube> Printf.printf "1 lsl 30: %d %u\n" (1 lsl 30) (1 lsl 30);
<hcube> 1 lsl 30: -1073741824 1073741824
<SurfMaths> Huh, and « let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62) » return 0 ?!
<hcube> yes
<SurfMaths> What is the value of « 1 lsl 31 » ?
<SurfMaths> This is very strange…
<hcube> 1 lsl 31: 0 0
<hcube> maybe i sould check the equality operator
<SurfMaths> Yep.
<SurfMaths> if 1 lsl 31 = 0 then print_endline "Ok" else print_endline "WTF?!"
<SurfMaths> Do you compile with « ocamlopt » on the same architecture than the one you run the program ?
pikachuyann has joined #ocaml
<hcube> WTF?!
<SurfMaths> If you compile on a 64 bit architecture, ocamlopt optimize by calculating the value of 1 lsl 31, see that it's different of 0, and say to print 1 lsl 62.
<SurfMaths> Which is equal to 0 on 32 bits architectures.
<hcube> i had to apply a cross compile patch and an iphone specific patch
<hcube> as it is written in the tutorial
<hcube> i also compiled ocaml to the iphone simulator which is a 32 bit i386 architecture
<hcube> and on that platform ocamlopt worked and min_int has the right value
<SurfMaths> Yes but, I think it's a problem due to cross-compiling.
<hcube> but crosscompiling worked for the iphone simulator
<hcube> in that case i was on the same 64 bit machine
<SurfMaths> In the iphone simulator the value returned for min_int was -1073741824 ?
ztfw has joined #ocaml
<hcube> yes
<hcube> i alse put a guard to ocaml's config.h
<hcube> #if SIZEOF_INT == 4
<hcube> #warning " --- This is a 32 bit architecture ---"
<hcube> #else
<hcube> #error " --- This is not a 32 bit architecture ---"
<hcube> #endif
<hcube> should i compile arm ocamlopt with a 32 bit i386 ocamlopt/ocamlrun?
<SurfMaths> I think.
<hcube> then i'll try to compile with the iphone simulator's one
<SurfMaths> It should work for this optimization, but i'm not sure that there is not an other one that will fail.
Smerdyakov has joined #ocaml
<hcube> if this will work then i'll try to run the testsuite on iphone
<SurfMaths> I think you can post a bug-report about the cross-compiling patch to ARM.
<hcube> yep, goo idea :)
<hcube> good
Smerdyakov has quit [Quit: Leaving]
DimitryKakadu has quit [Remote host closed the connection]
yezariaely has joined #ocaml
yezariaely has left #ocaml []
Smerdyakov has joined #ocaml
EliasAmaral has joined #ocaml
EliasAmaral is now known as dark
SurfMaths has quit [Quit: Zzzz…]
ikaros has quit [Quit: Leave the magic to Houdini]
<dark> mfp, is there any chance to apply that patch on ocaml 3.12?
<mfp> it's unlikely to apply cleanly, but the conflicts should be easy to solve
<hcube> is anybody on mac? (and has iphone sdk installed)
<dark> hcube, I thought that apple banned non-mainstream programming languages
<Smerdyakov> dark, surprisingly, there wasn't nearly as much fuss when Apple removed that clause as when it was first discovered. :)
Smerdyakov has quit [Quit: Leaving]
<dark> oh, so software written using any programming language / any interpreter can be sold on iphone store?
<dark> they was very clear that they didn't want flash
<adrien> it was removed very recently iirc
<hcube> true
<gildor> rwmjones: hi
<gildor> rwmjones: where can I find the VCS of the packaging for Fedora's ocaml packages?
Indian-2010 has joined #ocaml
<hcube> yee! ocamlopt work fine on iphone. SurfMaths, you was right i had to compile arm ocaml with 32 bit i386 ocaml. :)
kaustuv has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<hcube> except unix module :( when i link it to the app it crashes: Program received signal: “EXC_BAD_INSTRUCTION”.
<hcube> does ocamlopt support gnu debugger?
<mfp> hcube: there's no support for symbolic debugging with gdb for native programs.
<adrien> you can get some infos from gdb but it's far from perfect and is probably better avoided for "regular" debugging
<hcube> oh, shit. then how can i solve the ocaml unix module's EXC_BAD_INSTRUCTION problem?
<hcube> any idea?
<hcube> :)
<mfp> hcube: you can still use gdb, without higher-level ("symbolic") features :) see where the program crashes and disassemble
<adrien> I saw something about different hardware, maybe try without a universal binary at first
<adrien> other things seem to mention plain old bugs, maybe because of api changes in the sdk
Modius has joined #ocaml
<hcube> this is the gdb message what i get after ocaml thread crash, other threads are still running:Program received signal: “EXC_BAD_INSTRUCTION”.
<hcube> Previous frame inner to this frame (gdb could not unwind past this frame)
<hcube> Previous frame inner to this frame (gdb could not unwind past this frame)
<hcube> ok, i think i'll drop llvm-gcc. google said that that's the problem
Indian-2010 has left #ocaml []
pikachuyann is now known as pika|physique
wuj has joined #ocaml
schme has joined #ocaml
<adrien> does sexplib allow defaults value for fields in a record: I want a default value when a field isn't provided (it can default to None but I couldn't find more)
lpereira has quit [Quit: Leaving.]
<flux> I don't think so
pkl has joined #ocaml
mjonsson has joined #ocaml
<hcube> i did a little debug and it camed up that the program crashes at caml_start_program call
<hcube> but only in threaded mode
<hcube> in non threaded (ocaml) mode i cant step into caml_start_program the debugger stepped through the function call
<hcube> where can i find info about ocaml runtime and ocamlopt internals?
wuj has quit [Ping timeout: 265 seconds]
init1 has quit [Quit: Quitte]
Yoric has joined #ocaml
pkl has quit [Quit: rcirc on GNU Emacs 24.0.50.1]
joewilliams_away is now known as joewilliams
fraggle_ has quit [Ping timeout: 276 seconds]
fraggle_ has joined #ocaml
fraggle_ has quit [Ping timeout: 240 seconds]
fraggle_ has joined #ocaml
<hcube> what's the difference between libthreadsnat.a and libthreads.a ?
<flux> no real idea, but perhaps one of them is used for native code, other for byte code?
<flux> s/idea/knowledge/
<hcube> probably you are right, because in native and threaded mode the project links only with threadsnat, otherwise linking fails.
joewilliams is now known as joewilliams_away
nimred has quit [Quit: leaving]
dom96 has joined #ocaml
dom96 has left #ocaml []
nimred has joined #ocaml
nimred has quit [Client Quit]
<hcube> ahhh, in bytecode mode there are float problems...
<hcube> let x = 1.00146962706651288;;
<hcube> Printf.printf "check float: %f \n" x;;
<hcube> this prints 0.0
<hcube> ocaml is for pc i think
<hcube> :)
<adrien> mldonkey is running on a very wide range of hardware
<adrien> apple doesn't make things easy
<adrien> it looks like you have bitness issues and maybe you're not getting the right target for the compilation too
<adrien> have you tried contacting the author of the patches?
nimred has joined #ocaml
<hcube> yep, jist wrote an email
<adrien> bah, Sexplib sometimes really wants you to "open Sexplib.{Sexp,Conv}"
<flux> hm, when?
<flux> I think I've gone quite far with module Sx = Sexplib.Sexp module Sc = Sexplib.Conv ;)
<adrien> using the "with sexp" extension along with 'sexp_list' in the type (makes a record field optional, defaulting to an empty list)
<adrien> and it complains: "Error: Unbound value sexp_of_list": this function is in Sexplib.Conv
<flux> "sexp_list", I haven't used that..
<flux> you can do: let sexp_of_list = Sexplib.Conv.sexp_of_list to work around that
<adrien> which is exactly what I did ;-)
schme is now known as schmx
<adrien> well, guess I won't use sexp_list either :-)
mjonsson has quit [Ping timeout: 265 seconds]
mjonsson has joined #ocaml
pika|physique has quit [Quit: Quitte]
Yoric has quit [Quit: Yoric]
rwmjones is now known as rwmjones_afk
thieusoai has joined #ocaml
ztfw has quit [Remote host closed the connection]