Loading ...
Sorry, an error occurred while loading the content.

Problem in Bigarray-Module under Intel64-Bit?

Expand Messages
  • Romeyke, Andreas
    Hello, my team mate is triggered in a possible bug by compiling an ocaml-program under ocaml 11.1 using Bigarray-module. The ocaml-package is self-compiled
    Message 1 of 4 , Dec 1, 2009
    • 0 Attachment
      Hello,

      my team mate is triggered in a possible bug by compiling an
      ocaml-program under ocaml 11.1 using Bigarray-module.

      The ocaml-package is self-compiled with configure with standard options,
      downloaded from http://caml.inria.fr directly.

      The program could be compiled and runs stable with ocaml 3.10.2 (debian)
      and 3.11.1 (selfcompiled) under AMD Sempron(tm) Processor LE-1150
      (32bit).

      In both cases the same input files are used.

      I have attached the output of "ocamlopt -v", the output of
      Linux /proc/cpuinfo and the first lines of GDB backtrace.

      The ocamlopt is called with this compile-options: '-g -pp
      "camlp4o"' (camlp4 is not really used, only used for better error
      reports)

      Do you have any hints to fix this problem or do you know a workaround?
      Do you need additional information?

      Bye Andreas

      ---- 8>< ---- 8>< ---- 8>< ---- 8>< ----
      ocamlopt -v
      The Objective Caml native-code compiler, version 3.11.1
      Standard library directory: /usr/local/lib/ocaml
      ---- ><8 ---- ><8 ---- ><8 ---- ><8 ----


      ---- 8>< ---- 8>< ---- 8>< ---- 8>< ----
      /proc/cpuinfo
      processor : 0
      vendor_id : GenuineIntel
      cpu family : 6
      model : 23
      model name : Intel(R) Core(TM)2 Duo CPU E8600 @ 3.33GHz
      stepping : 10
      cpu MHz : 2000.000
      cache size : 6144 KB
      physical id : 0
      siblings : 2
      core id : 0
      cpu cores : 2
      apicid : 0
      initial apicid : 0
      fpu : yes
      fpu_exception : yes
      cpuid level : 13
      wp : yes
      flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
      mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2ss ht tm pbe
      syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl pni
      monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
      bogomips : 6665.88
      clflush size : 64
      cache_alignment : 64
      address sizes : 36 bits physical, 48 bits virtual
      power management:

      processor : 1
      vendor_id : GenuineIntel
      cpu family : 6
      model : 23
      model name : Intel(R) Core(TM)2 Duo CPU E8600 @ 3.33GHz
      stepping : 10
      cpu MHz : 2000.000
      cache size : 6144 KB
      physical id : 0
      siblings : 2
      core id : 1
      cpu cores : 2
      apicid : 1
      initial apicid : 1
      fpu : yes
      fpu_exception : yes
      cpuid level : 13
      wp : yes
      flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
      mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2ss ht tm pbe
      syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl pni
      monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm
      bogomips : 6665.90
      clflush size : 64
      cache_alignment : 64
      address sizes : 36 bits physical, 48 bits virtual
      power management:
      ---- ><8 ---- ><8 ---- ><8 ---- ><8 ----






      ---- 8>< ---- 8>< ---- 8>< ---- 8>< ----
      Program received signal SIGSEGV, Segmentation
      fault.
      0x0000000000443fb2 in caml_ba_get_N
      ()
      Current language: auto; currently
      asm
      (gdb)
      bt
      #0 0x0000000000443fb2 in caml_ba_get_N ()
      #1 0x0000000000444113 in caml_ba_get_2 ()
      #2 0x0000000000454e00 in caml_c_call ()
      #3 0x00007ffff7fd3fb8 in ?? ()
      #4 0x000000000041419a in camlSpeedseg__flood_368 ()
      #5 0x0000000000000141 in ?? ()
      #6 0x000000000000013f in ?? ()
      #7 0x0000000000000689 in ?? ()
      #8 0x00007ffff7fd3ea8 in ?? ()
      #9 0x0000000000000009 in ?? ()
      #10 0x0000000000414237 in camlSpeedseg__flood_368 ()
      #11 0x0000000000000001 in ?? ()
      #12 0x0000000000000141 in ?? ()
      #13 0x0000000000000689 in ?? ()
      #14 0x00007ffff7fd3ea8 in ?? ()
      #15 0x0000000000000009 in ?? ()
      #16 0x000000000041424f in camlSpeedseg__flood_368 ()
      #17 0x0000000000000001 in ?? ()
      #18 0x000000000000013f in ?? ()
      #19 0x0000000000000689 in ?? ()
      #20 0x00007ffff7fd3ea8 in ?? ()
      #21 0x0000000000000009 in ?? ()
      #22 0x000000000041424f in camlSpeedseg__flood_368 ()
      #23 0x0000000000000001 in ?? ()
      #24 0x000000000000013d in ?? ()
      #25 0x0000000000000689 in ?? ()
      #26 0x00007ffff7fd3ea8 in ?? ()
      #27 0x0000000000000009 in ?? ()
      #28 0x000000000041424f in camlSpeedseg__flood_368 ()
      #29 0x0000000000000001 in ?? ()
      #30 0x000000000000013b in ?? ()
      #31 0x0000000000000689 in ?? ()
      #32 0x00007ffff7fd3ea8 in ?? ()
      #33 0x0000000000000009 in ?? ()
      #34 0x000000000041424f in camlSpeedseg__flood_368 ()
      #35 0x0000000000000001 in ?? ()
      #36 0x0000000000000139 in ?? ()
      #37 0x0000000000000689 in ?? ()
      #38 0x00007ffff7fd3ea8 in ?? ()
      #39 0x0000000000000009 in ?? ()
      ---- ><8 ---- ><8 ---- ><8 ---- ><8 ----
      --
      Andreas Romeyke
      - Abteilung Blindenschrift -
      Deutsche Zentralbücherei für Blinde zu Leipzig (DZB)
      Gustav-Adolf-Straße 7, 04105 Leipzig
      Tel: +49 341 7113-..., Fax: +49 341 7113-125
      Internet: www.dzb.de
      E-Mail: andreas.romeyke@...


      [Non-text portions of this message have been removed]
    • Richard Jones
      ... [...] ... There s not much to go on. At the very least we d want to see the contents of registers when it segfaults. However it s not likely that anyone
      Message 2 of 4 , Dec 2, 2009
      • 0 Attachment
        On Tue, Dec 01, 2009 at 09:06:35AM +0100, Romeyke, Andreas wrote:
        > my team mate is triggered in a possible bug by compiling an
        > ocaml-program under ocaml 11.1 using Bigarray-module.
        [...]
        > Do you have any hints to fix this problem or do you know a workaround?
        > Do you need additional information?

        There's not much to go on. At the very least we'd want to see the
        contents of registers when it segfaults. However it's not likely that
        anyone can fix the problem unless you can write a small reproducer
        program (and/or release your program's source code).

        Rich.

        --
        Richard Jones
        Red Hat
      • Romeyke, Andreas
        Hello, ... Hmm, ok. ... I will try to reduce the program as small as possible. There was an additional fact found, if we start the compiled program on a clean
        Message 3 of 4 , Dec 3, 2009
        • 0 Attachment
          Hello,

          Am Mittwoch, den 02.12.2009, 16:53 +0000 schrieb Richard Jones:

          > There's not much to go on. At the very least we'd want to see the
          > contents of registers when it segfaults. However it's not likely that

          Hmm, ok.

          > anyone can fix the problem unless you can write a small reproducer
          > program (and/or release your program's source code).

          I will try to reduce the program as small as possible.

          There was an additional fact found, if we start the compiled program on
          a clean system (fresh booted linux), the program will be died as
          described.

          But if you run the program twice, it will be run without segfaults.

          Because the same effect does not occur on an AMD-32bit system (fresh
          compiled), it could have something to do with loading a library into the
          memory, I think.

          The problem is hard to trigger down, I will sent more information as
          soon as possible.

          Bye Andreas

          --
          Andreas Romeyke
          - Abteilung Blindenschrift -
          Deutsche Zentralbücherei für Blinde zu Leipzig (DZB)
          Gustav-Adolf-Straße 7, 04105 Leipzig
          Tel: +49 341 7113-..., Fax: +49 341 7113-125
          Internet: www.dzb.de
          E-Mail: andreas.romeyke@...


          [Non-text portions of this message have been removed]
        • Romeyke, Andreas
          Hello, ... I have tried it. But the error only occurs in a more complex environment. The following tests will be passed, the original code will be attached,
          Message 4 of 4 , Jan 15, 2010
          • 0 Attachment
            Hello,

            Am Mittwoch, den 02.12.2009, 16:53 +0000 schrieb Richard Jones:

            > On Tue, Dec 01, 2009 at 09:06:35AM +0100, Romeyke, Andreas wrote:
            > > my team mate is triggered in a possible bug by compiling an
            > > ocaml-program under ocaml 11.1 using Bigarray-module.
            > [...]
            > > Do you have any hints to fix this problem or do you know a
            > workaround?
            > > Do you need additional information?
            >
            > There's not much to go on. At the very least we'd want to see the
            > contents of registers when it segfaults. However it's not likely that
            > anyone can fix the problem unless you can write a small reproducer
            > program (and/or release your program's source code).

            I have tried it. But the error only occurs in a more complex
            environment. The following tests will be passed, the original code will
            be attached, too.

            And, the bug *only* occurs if profiling-switch will be set.

            This will be passed in 32 and 64 bit:
            ---- 8>< ---- 8>< ---- 8>< ----
            * testcase to trigger 64bit compiler bug?
            * compile with
            * ocamlopt -I +bigarray bigarray.cmxa -p -g -o 64bit_compiler_bug 64bit_compiler_bug.ml
            * run with
            * OCAMLRUNPARAM=b ./64bit_compiler_bug
            *)
            let w = 10;;
            let h = 10;;
            let ba = Bigarray.Array2.create Bigarray.int Bigarray.c_layout w h in
            (* clean array *)
            let init () =
            for i = 0 to w-1 do
            for j = 0 to h-1 do
            Bigarray.Array2.set ba i j 0
            done
            done
            in
            (* test for-loop *)
            for i = 0 to w do
            for j = 0 to h do
            if i >= 0 && j >= 0 && i < w && j < h &&
            (Bigarray.Array2.get ba i j) == 0 then
            begin
            Bigarray.Array2.set ba i j 2;
            Printf.printf "%i %i -> ok\n" i j;
            end
            done
            done;
            Printf.printf "kein Bug in for-loop\n";
            (* rec loop *)
            let rec _evaluate x y =
            if x >= 0 && y >= 0 && x < w && y < h &&
            (Bigarray.Array2.get ba x y) == 0 then
            begin
            Bigarray.Array2.set ba x y 2;
            _evaluate (x+1) y ;
            _evaluate x (y+1) ;
            _evaluate (x-1) y ;
            _evaluate x (y-1)
            end
            in
            (* test rec loop for every value *)
            for i = 0 to w do
            for j = 0 to h do
            init ();
            _evaluate i j;
            Printf.printf "kein Bug in rec-loop %i %i \n" i j;
            done
            done
            ---- ><8 ---- ><8 ---- ><8 ----

            This will failed with Segfault in bigarray.cmxa if compiled with ocamlopt and profiling is switched on on a 64bit system. The problem occurs with ocaml 10.1 and with the latest prerelease.

            ---- 8>< ---- 8>< ---- 8>< ----
            let evaluate img shadow x y v =
            let (width, height) = Img.dims img in
            Img.lock img;
            let rec _evaluate x y =
            if x >= 0 && y >= 0 && x < width && y < height &&
            (Bigarray.Array2.get shadow x y) == 2 then (* HERE THE PROGRAM DIES WITH SEGFAULT! *)
            begin
            Bigarray.Array2.set shadow x y 0 ;
            let (r,g,b) = v in
            let v' = Img.int_of_color r g b in
            Img.set img x y v';
            _evaluate (x+1) y ;
            _evaluate x (y+1) ;
            _evaluate (x-1) y ;
            _evaluate x (y-1)
            end
            in
            let _ = _evaluate x y in
            Img.unlock img;
            ()
            ---- ><8 ---- ><8 ---- ><8 ----

            The evaluate-routine will be called with x and y iterating 0..width-1 and 0..height-1, v is the initial color-value.

            Do you have any hints?

            Bye Andreas


            --
            Andreas Romeyke
            - Abteilung Blindenschrift -
            Deutsche Zentralbücherei für Blinde zu Leipzig (DZB)
            Gustav-Adolf-Straße 7, 04105 Leipzig
            Tel: +49 341 7113-..., Fax: +49 341 7113-125
            Internet: www.dzb.de
            E-Mail: andreas.romeyke@...


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.