Skip to content

Fix mantis PR 7168 by creating a safety margin in the bytecode stack.#510

Closed
jhjourdan wants to merge 1 commit intoocaml:4.03from
jhjourdan:stack_safety_margin
Closed

Fix mantis PR 7168 by creating a safety margin in the bytecode stack.#510
jhjourdan wants to merge 1 commit intoocaml:4.03from
jhjourdan:stack_safety_margin

Conversation

@jhjourdan
Copy link
Copy Markdown
Contributor

I use a safety margin of 60 words, which is enough for the event handler and the apply instructions.

@damiendoligez
Copy link
Copy Markdown
Member

Minor nitpick: I'm not sure the constant should be defined in config.mlp, as I see no reason to believe that it will change with the underlying system.

@jhjourdan
Copy link
Copy Markdown
Contributor Author

Indeed, it will not change with the underlying system. But nor does stack_threshold, and it may change if someone implements an instructions necessitating more space on the stack.

@damiendoligez damiendoligez added this to the 4.03.0 milestone Mar 31, 2016
@damiendoligez
Copy link
Copy Markdown
Member

@xavierleroy Could you review this patch?


let _ =
try f 1
with Stack_overflow -> Printf.printf "OK\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please ensure that this test runs only in bytecode? On some platforms, strange things can happen when ocamlopt-compiled code overflows the stack.

@xavierleroy
Copy link
Copy Markdown
Contributor

Looks good to me, provided the test is run in bytecode mode only.

@damiendoligez damiendoligez self-assigned this Apr 15, 2016
@damiendoligez
Copy link
Copy Markdown
Member

Fixed according to @xavierleroy 's remarks and merged into 4.03 (commit eda1b39) and trunk (commit 1915e20).

@jhjourdan
Copy link
Copy Markdown
Contributor Author

Thanks, @damiendoligez !

EduardoRFS pushed a commit to esy-ocaml/ocaml that referenced this pull request May 17, 2021
…t-principality-and-gadts

Update a testcase in principality-and-gadts.ml to reflect changes in ocaml#9584
mshinwell added a commit to mshinwell/ocaml that referenced this pull request Jun 30, 2021
@xavierleroy
Copy link
Copy Markdown
Contributor

@jhjourdan: this PR is attracting new attention because of #11062. I have one question: why 60 for the safety margin ? My analysis (below) suggests 6.

APPLY[123] +3
Setup_for_gc +3
Setup_for_c_call +2
Setup_for_event +6
Setup_for_debugger +4

@jhjourdan
Copy link
Copy Markdown
Contributor Author

@xavierleroy : I don't have clear memories, but it really seems like it was based on nothing concrete. It just felt good to use a margin 10 times larger than what was empirically needed, since it was not clear to me which part of the interpreter could allocate out-of-the-limit stack slots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants