Skip to content

Implement Fiber#to_s method#6105

Merged
matz merged 1 commit intomruby:masterfrom
dearblue:fiber.to_s
Dec 8, 2023
Merged

Implement Fiber#to_s method#6105
matz merged 1 commit intomruby:masterfrom
dearblue:fiber.to_s

Conversation

@dearblue
Copy link
Contributor

@dearblue dearblue commented Dec 1, 2023

If the filename and line number cannot be obtained, "(unknown):1" is used instead.

Also, the file name information of the terminated fiber cannot be retrieved and will be replaced as well. This limitation is due to the fact that cibase->proc of the terminated fiber is collected by the GC.

% bin/mruby -e 'p Fiber.new { p Fiber.current }.resume'
#<Fiber:0x82423bef0 -e:1 (resumed)>
#<Fiber:0x82423bef0 (unknown):1 (terminated)>

If the filename and line number cannot be obtained, "(unknown):1" is used instead.

Also, the file name information of the terminated fiber cannot be retrieved and will be replaced as well.
This limitation is due to the fact that `cibase->proc` of the terminated fiber is collected by the GC.

```console
% bin/mruby -e 'p Fiber.new { p Fiber.current }.resume'
#<Fiber:0x82423bef0 -e:1 (resumed)>
#<Fiber:0x82423bef0 (unknown):1 (terminated)>
```
@dearblue dearblue requested a review from matz as a code owner December 1, 2023 12:37
@matz matz merged commit cb54138 into mruby:master Dec 8, 2023
matz added a commit that referenced this pull request Dec 8, 2023
…6105

Since `cxt->ci` points to the last active callinfo, `cxt->ci == cxt->cibase`
does not mean it does not have correct `proc` information, so we have
removed the `f->cxt->ci > f->cxt->cibase` check. Instead, just in case
`proc` does not have `irep` information, we try to confirm `proc` does not
point to `CFUNC` nor is not an alias.
dearblue added a commit to dearblue/mruby that referenced this pull request Dec 9, 2023
When fiber is terminated, the pointer indicated by f->cxt->cibase->proc is not protected from GC.
I should have done this patch way as of commit ca9e8d9 (mruby#6105).
dearblue added a commit to dearblue/mruby that referenced this pull request Dec 9, 2023
When fiber is terminated, the pointer indicated by `f->cxt->cibase->proc` is not protected from GC.
I should have done this patch way as of commit 9af6264 (mruby#6105).
matz added a commit that referenced this pull request Dec 15, 2023
Since Fiber#to_s did not include location information before #6105,
when location information cannot be retrieved for terminated fibers,
instead of meaningless information such as "(unknown):0", we omit
positional information altogether for terminated fibers; ref #6111
@dearblue dearblue deleted the fiber.to_s branch December 15, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants