Evan Martin (evan) wrote in evan_tech,
Evan Martin

whimper / practical set reconciliation

Probably only raevnos will understand this, so let's hope he reads it:OCaml, being a theoretically pure language (they write papers first and then implement the ideas as features), has the corresponding lack of attention to the small details that make popular languages like Python and Perl nice: the standard library is pretty weak, there's no standardized way for programs to configure/install themselves, and there's no standardized way for installing/registering/linking libraries (though findlib is pretty popular).

These SQLite bindings are broken in that they don't install the .so stub library. I modified the makefile to fix that and now they link ok, but then they segfault if I ever do anything wrong.
After some digging:
(gdb) r
Starting program: /home/martine/oc/ocaml-sqlite/a.out 

Program received signal SIGSEGV, Segmentation fault.
0x10004a00 in raise_sqlite_error (zErrmsg=0x1005af60 "") at sqlite_stubs.c:171
171       raise_with_arg(*caml_named_value("sqlite error"), msg); \

it appears that the exceptions are not getting registered before the C stub tries to use them.
The library includes a .ml file that defines and registers the exceptions:
exception Sqlite_error of string
let _ = Callback.register_exception "sqlite error" (Sqlite_error "Registering Callback")

So maybe that code isn't getting ran?

If I use their toplevel, it properly runs my test program and raises an exception.
The .cmxa is linked like this:
ocamlmklib -o sqlite sqlite.cmx sqlite_stubs.o -lsqlite -oc sqlite_stubs -cclib -L.
So I want to think that the .cmx is getting linked in "first", whatever that may mean.
To reproduce this I'm linking with ocamlopt sqlite.cmxa test2.ml, but doing it the "right" way with findlib is equally broken.

Looking around at database wrappers led me to SKS, a PGP keyserver (one of the authors is the guy who did the OCaml Berkeley database wrappers) and to their paper Practical Set Reconciliation, which was tonight's reading. The original paper that provided BASIC-RECON would probably be worth reading, too.

  • your vcs sucks

    I've been hacking on some Haskell stuff lately that's all managed in darcs and it's reminded me of an observation I made over two years ago now (see…

  • perl people, explain your language to me

    Every time I use perl I feel mildly positive about it right up until I encounter CPAN. I've never managed to make CPAN work, despite the multitude of…

  • dns attack of doom

    If I've learned anything from the new Kaminsky DNS attack, it's that if you want to keep something a secret while disclosing to a trusted subset of…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment