From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 761C57EE20 for ; Mon, 19 Nov 2012 22:01:08 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of monnier.florent@gmail.com) identity=pra; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of monnier.florent@gmail.com designates 209.85.210.54 as permitted sender) identity=mailfrom; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-da0-f54.google.com) identity=helo; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="postmaster@mail-da0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsCAHudqlDRVdI2jWdsb2JhbABFwkkIIwEBAQEJCQsJEgYjgkwZARseAxIQXQERAQUBIogNAQMPC55sgm+MM4J4hHYKGScNWYh1AQUMjlmCXAOVfI5iFimEBA4 X-IronPort-AV: E=Sophos;i="4.83,280,1352070000"; d="scan'208";a="182230119" Received: from mail-da0-f54.google.com ([209.85.210.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 19 Nov 2012 22:01:07 +0100 Received: by mail-da0-f54.google.com with SMTP id n2so246693dad.27 for ; Mon, 19 Nov 2012 13:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=V/JN7bCLkAMMsQ1G4e9ZFZ/+kgXcZhQU+Wo0PjTjnCQ=; b=Z0PwIqTyFtnhbF7aMZ+zRD3rUs3r2wvs6mWe5X2IyXJRIGvoiVej8s1OfH2h8zLwb2 50U2EU+4uuXxwzKjJoy3DSQ43QAGkbMr+6PmOYSw0JTyjT00j5inVImlCpsBNvTA+Vlg u3GTB5628nvHG+Lci49f1Pg6NWTLUCkVoBBu7Oz5Xm5gLFEEvIWSm6UODTnb8mKBYU0Y TIU5/2MnXT31xKR1oltynJp15kmbYlM1eG0yub3d1JRzHvvLCdb1Yek/jkFvbHau6YM6 i+58tRq3h0bNxFunfYpCZYrrSXdJfWe2FI2OlTMjmbvGGwAE7+9SrFXEMcnhmy7OpEeG 8Kqg== MIME-Version: 1.0 Received: by 10.68.189.233 with SMTP id gl9mr41705563pbc.166.1353358866286; Mon, 19 Nov 2012 13:01:06 -0800 (PST) Received: by 10.68.16.197 with HTTP; Mon, 19 Nov 2012 13:01:06 -0800 (PST) Date: Mon, 19 Nov 2012 22:01:06 +0100 Message-ID: From: Florent Monnier To: Caml List Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: monnier.florent@gmail.com Subject: [Caml-list] segfault with native compilation, but not in bytecode Hi, My program runs fine with opencv in bytecode, but I don't succeed to run it with opencv in native code. Here is minimal code to reproduce the error: here is a test in C: $ cat err_c.c #include #include int main() { CvCapture *capture = cvCreateCameraCapture(0); if (!capture) exit(1); cvReleaseCapture(&capture); return 0; } $ gcc -lopencv_core -lopencv_highgui -lm err_c.c -o err_c $ ./err_c ##OK Now trying to do the same in ocaml, in native code: $ cat err.ml external test : unit -> unit = "my_cv_test" let () = test () $ cat err_stub.c #include #include #define CAML_NAME_SPACE #include CAMLprim value my_cv_test(value unit) { CvCapture *capture = cvCreateCameraCapture(0); if (!capture) exit(1); cvReleaseCapture(&capture); return Val_unit; } $ ocamlopt -o err.opt err.ml err_stub.c -cclib "-lopencv_core -lopencv_highgui -lm" $ ./err.opt Segmentation fault $ gdb ./err.opt (gdb) run Program received signal SIGSEGV, Segmentation fault. 0xb7da204b in cvCreateCameraCapture () from /usr/lib/libopencv_highgui.so.2.3 (gdb) bt #0 0xb7da204b in cvCreateCameraCapture () from /usr/lib/libopencv_highgui.so.2.3 #1 0x0804c241 in my_cv_test () #2 0x08049ccc in camlErr__entry () #3 0x08049981 in caml_program () #4 0x0805990a in caml_start_program () #5 0x08059dad in caml_main () #6 0x0804c280 in main () There is no initialisation function that has to be called before this function, as you can see with this example sample: https://github.com/Itseez/opencv/blob/master/samples/c/fback_c.c I do NOT get this segfault in bytecode mode, and my program runs fine. It only segfaults in native code. What could be wrong? In case you don't know, would you have any advice how to search the origine of the problem? -- Cheers Florent