Skip to content

Accessing to a nested array causes segmentation fault #14

@uenoB

Description

@uenoB

When I write a parallel sorting program, I found that the following code causes segmentation fault both on my mac and linux.

fun copy a b e d j =
    if e < b then ()
    else let val v = Array.sub (Array.sub (a, 0), b)
         in Array.update (Array.sub (d, 0), j, v);
            copy a (b+1) e d (j+1)
         end

fun sort a b e =
    if e <= b then () else
    let val q = Int.quot (b + e, 2)
    in sort a b q;
       sort a (q+1) e;
       copy a b e a b
    end

val a = Array.array (1, Array.array (1024, 0))
val _ = sort a 0 1023

I checked out the repository and compiled the compiler as follows:

git clone https://github.com/ManticoreProject/manticore.git
git checkout 757fbcc4d   # to make clear which revision I used
autoconf -Iconfig
autoheader -Iconfig
./configure --prefix=$PWD/dest
mkdir -p dest/bin dest/lib
make install

I saved the above code in bug.pml and executed it as follows:

$ dest/bin/pmlc -o bug bug.pml
$ ./bug
Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions