-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Initialize Fiber
with an explicit stack
#15409
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
Merged
ysbaddaden
merged 7 commits into
crystal-lang:master
from
ysbaddaden:feature/specify-fiber-stack
Feb 11, 2025
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a185f4a
Initialize `Fiber` with an explicit stack
ysbaddaden 9d9d079
Add Fiber::Stack
ysbaddaden aae3498
Keep StackPool as main interface (now storing Fiber::Stack)
ysbaddaden b5f90fb
Fix: stack allocated by stack pool is reusable
ysbaddaden 1f8eac0
Update src/crystal/system/unix/signal.cr
ysbaddaden 876434c
Fix: revert change to keep bytesize in stack
ysbaddaden 729cbbb
fixup! Fix: revert change to keep bytesize in stack
ysbaddaden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,8 +183,8 @@ module Crystal::System::Signal | |
|
||
is_stack_overflow = | ||
begin | ||
stack_top = Pointer(Void).new(::[email protected] - 4096) | ||
stack_bottom = ::Fiber.current.@stack_bottom | ||
stack_top = Pointer(Void).new(::Fiber.current.@stack.pointer.address - 4096) | ||
stack_bottom = ::Fiber.current.@stack.bottom | ||
stack_top <= addr < stack_bottom | ||
rescue e | ||
Crystal::System.print_error "Error while trying to determine if a stack overflow has occurred. Probable memory corruption\n" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Fiber | ||
# :nodoc: | ||
struct Stack | ||
getter pointer : Void* | ||
getter bytesize : Int32 | ||
getter? reusable : Bool | ||
|
||
def initialize(@pointer, bottom : Void*, *, @reusable = false) | ||
@bytesize = (bottom - @pointer).to_i32 | ||
end | ||
|
||
def initialize(@pointer, @bytesize, *, @reusable = false) | ||
end | ||
|
||
def bottom : Void* | ||
@pointer + @bytesize | ||
end | ||
|
||
def first_addressable_pointer : Void** | ||
ptr = bottom # stacks grow down | ||
ptr -= sizeof(Void*) # point to first addressable pointer | ||
Pointer(Void*).new(ptr.address & ~15_u64) # align to 16 bytes | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.