Skip to content

R3 stack limits too low #1252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 2 comments
Closed

R3 stack limits too low #1252

Siskin-Bot opened this issue Feb 15, 2020 · 2 comments
Labels
CC.resolved Issue with CureCode status built, tested or complete

Comments

@Siskin-Bot
Copy link
Collaborator

Submitted by: pekr

While we were told R3 stack limits are user settable, they are too low by default, and should be imo adjusted to some more usefull level:

REBOL level recursion:

>> cnt: 0 recursion: does [++ cnt recursion] recursion
** Internal error: stack overflow
>> cnt
== 4004

Parse level recursion:

>> cnt: 0 rule: [(++ cnt) rule] parse "123" [some rule]
** Internal error: internal limit reached: parse
>> cnt
== 512

Imported from: CureCode [ Version: alpha 86 Type: Issue Platform: Windows Category: Unspecified Reproduce: Always Fixed-in:alpha 87 ]
Imported from: metaeducation#1252

Comments:

Rebolbot commented on Oct 6, 2009:

Submitted by: Carl

The stack size needs to be balanced against the memory footprint you want.

Currently, it's set for a small footprint. However, it can be expanded in A87 with this:

secure none
evoke [stack-size 1000000]
>> cnt: 0 recursion: does [++ cnt recursion] recursion
>> cnt
== 42664

The limit here is imposed by the C stack, which in A87 reserves about 4MB.

The PARSE function is now limited only by the C stack, not by a depth counter.

cnt: 0 rule: [(++ cnt) rule] parse "123" [some rule]
>> cnt
== 42660

Rebolbot commented on Oct 8, 2009:

Submitted by: pekr

It is nice we can set the stack higher, but I thought that we will make it so (at least to R2 level) by default. Is there really a reason, why R3 default stack setting is nearly 1/4 of the R2 value? Also disabling entire security in order to raise the stack value is surely not a good idea (more in #1259 )


Rebolbot mentioned this issue on Jan 12, 2016:
Need secure 'stack keyword


@Oldes
Copy link
Owner

Oldes commented Apr 1, 2020

@carls I'm quite puzzled with this one. It is working as expected (throwing the error) when I compile using mingw compiler on Windows, but crashes, when I use clang or msvc (Visual Studio 15.9.8)

@Oldes
Copy link
Owner

Oldes commented Apr 1, 2020

Ok... I found it... the reason is, that the binary stack is overflowed sooner than the one checked in Rebol. The difference is, that my gcc build is using linker option -Wl,--stack=4194300 while by default, Visual Studio is by using stack of size 1MB. When I use /STACK:4194300 in my VS build, than the stack overflow is detected at runtime before crash as expected.

With clang I must use something like: -Wl,-stack:0x03E8000

Setting limit using mentioned evoke is not much useful, because the stack size must be in bounds defined with above linker switches during compilation and also there are hard-coded limits in the code. Like here .

Anyway.. In my 64bit builds I'm getting cnt = 12184 with clang and 15052 with msvc, which is more than 4004.

@Oldes Oldes closed this as completed Apr 1, 2020
Oldes added a commit to Oldes/Rebol3 that referenced this issue Apr 3, 2020
1. Using `Trap_Stack` instead of `Trap0(RE_STACK_OVERFLOW)` as the second one displays `near` information, which may not be good to show.

2. Don't try to expand stack over limit.

Related to: Oldes/Rebol-issues#1252
@Siskin-Bot Siskin-Bot added the CC.resolved Issue with CureCode status built, tested or complete label May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CC.resolved Issue with CureCode status built, tested or complete
Projects
None yet
Development

No branches or pull requests

2 participants