Skip to content

Segmentation fault ./forsp examples/demo.fp #22

Description

@clvBerlin

The problem
Using gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0 under WSL of Windows11 with the forsp demo.fp I got a segmentation fault.

I'm quite sure, that lots of compiler versions and forsp programs will show the same problem.

The solution
I fixed read_list as follows:
...

  obj_t *evaluate_first = read();
  return make_pair(evaluate_first, read_list());
  // return make_pair(read(), read_list());

The reason
The order of evaluation is unspecified in C. So even the next compiler version on the same platform might decide to evaluate read_list before evaluating read. This leads to a stack overflow which in turn leads to undefined behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions