Skip to content
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

Handle infinite recursion in attribute methods #3221

Merged
merged 1 commit into from
Jan 23, 2019

Conversation

ChrisJefferson
Copy link
Contributor

@ChrisJefferson ChrisJefferson commented Jan 23, 2019

The main purpose of this patch is to fix tst/testspecial/stack-depth-func.g.
Rather than handle that specially, move where we handle stack
depth, to consistently handle all problems.

Fixes #1286

If anyone can think of another way we could cause a stack overflow, let me know here and I'll add it as a test.

@fingolfin fingolfin added kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) topic: kernel release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Jan 23, 2019
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Seems plausible to me.

src/funcs.c Outdated

#define CHECK_RECURSION_AFTER \
DecRecursionDepth(); \
HookedLineOutFunction(func);
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but: the names of those macros now are kinda wrong...

@fingolfin
Copy link
Member

Of course this probably introduces a small performance penalty, but I think that not crashing by accident in the middle of a long a and complicated computation beats that.

Though I do wonder how bad the overhead is in practice? It should only affect non-GAP functions, i.e., kernel functions. Perhaps we can do some micro benchmarking to test it? Hopefully that would show it is negligible. (I'm not insisting on this, I already approved the PR; just wondering out loud).

@ChrisJefferson
Copy link
Contributor Author

I did some very basic benchmarking and couldn't measure it. If we wanted to speed things up, it would probably be worth pulling the functions I'm calling into a header, so they can be inlined.

The main purpose of this patch is to fix stack-depth-operation.g.
Rather than handle that specially, move where we handle stack
depth, to consistently handle all problems
@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #3221 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3221      +/-   ##
==========================================
+ Coverage   84.77%   84.77%   +<.01%     
==========================================
  Files         688      688              
  Lines      335887   336415     +528     
==========================================
+ Hits       284738   285198     +460     
- Misses      51149    51217      +68
Impacted Files Coverage Δ
src/funcs.c 97.85% <ø> (ø) ⬆️
src/calls.h 98.62% <100%> (+0.68%) ⬆️
src/hpc/c_type1.c 87.62% <0%> (-1.02%) ⬇️
src/hpc/c_oper1.c 92.64% <0%> (-0.18%) ⬇️
src/hpc/serialize.c 81.46% <0%> (-0.11%) ⬇️
src/hpc/aobjects.c 71% <0%> (-0.05%) ⬇️
src/objects.c 81.36% <0%> (+0.13%) ⬆️
src/hpc/threadapi.c 46.85% <0%> (+0.14%) ⬆️
src/io.c 74.04% <0%> (+0.21%) ⬆️

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 84.648% when pulling ec00a88 on ChrisJefferson:stack-overflow into f27cff4 on gap-system:master.

@ChrisJefferson ChrisJefferson merged commit 579456e into gap-system:master Jan 23, 2019
@ChrisJefferson ChrisJefferson deleted the stack-overflow branch February 27, 2019 18:02
@fingolfin fingolfin added the kind: bug Issues describing general bugs, and PRs fixing them label Mar 21, 2019
@fingolfin fingolfin changed the title Handle stack overflow in Attributes Handle infinite recursion in attribute methods Apr 15, 2019
@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Apr 15, 2019
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.11.0 milestone Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) kind: bug Issues describing general bugs, and PRs fixing them release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with perverse method
4 participants