effekt-lang / effekt-lang/effekt

Segfault (139) when filling a list with 1M entries

Open
#836 5 comments 0 reactions 0 assignees View on GitHub
area:llvm bug
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

The following program segfaults in our LLVM backend:
```scala
def main() = {
val l1 = fill(1000000, 1)
println(l1.sum)
}
```
with

```
terminated by signal SIGSEGV (Address boundary error)
```

The example can be further simplified to

```scala
def main() = {
def go(i: Int, acc: List[Int]): List[Int] =
if (i < 1000000) {
go(i + 1, Cons(1, acc))
} else acc

val l = go(0, Nil())

()
}
```
which does not have any other stdlib function calls and results in the following machine:

```scala
def main_123750() = {
def go_123752(i_123749 : Int, acc_123751 : Positive) = {
let longLiteral_123829 = 1000000;
let pureApp_123828 = infixLt_16465(i_123749, longLiteral_123829);
tmp_123827 := pureApp_123828;
switch tmp_123827
0 : { () =>
return acc_123751
}
1 : { () =>
let longLiteral_123831 = 1;
let pureApp_123830 = infixAdd_16383(i_123749, longLiteral_123831);
tmp_123823 := pureApp_123830;
let longLiteral_123833 = 1;
let pureApp_123832 = boxInt_16591(longLiteral_123833);
tmp_123824 := pureApp_123832;
let make_123834 = 1(tmp_123824, acc_123751);
tmp_123825 := make_123834;
i_123749 := tmp_123823, acc_123751 := tmp_123825;
jump go_123752
}
};
let make_123835 = 0();
tmp_123826 := make_123835;
val (l_123753 : Positive) = {
let longLiteral_123837 = 0;
i_123749 := longLiteral_123837, acc_123751 := tmp_123826;
jump go_123752
};
let unitLiteral_123836 = 0();
return unitLiteral_123836
};
jump main_123750
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.