Skip to content

fix: check vaild frist when relative_pos_range close #94 #95

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

Conversation

yihong0618
Copy link
Contributor

as title, close #94

@Unparalleled-Calvin
Copy link
Contributor

Hi, yihong. Thank you for your contribution! The keyword unsafe is used here to notice users that there might be potential issues when using this API including:

  • The two spans may come from different source files which makes the result meaningless.
  • The overflow issues.

We can write code to check both issues and ensure that the program won't crash. However, the bugs from the caller function won't be detected. Considering that the bugs are conner cases, I think adding a visible notice will make sense?

@yihong0618
Copy link
Contributor Author

yihong0618 commented Jan 17, 2025

Hi, yihong. Thank you for your contribution! The keyword unsafe is used here to notice users that there might be potential issues when using this API including:

  • The two spans may come from different source files which makes the result meaningless.
  • The overflow issues.

We can write code to check both issues and ensure that the program won't crash. However, the bugs from the caller function won't be detected. Considering that the bugs are conner cases, I think adding a visible notice will make sense?

Hi thank you for the comments

IMO for this kind of error the better way is do not panic and stop the world?
a warning message and drop the unsafe maybe better?


can you try using RAPX for greptime, the error happens every time when using -ops for greptime, maybe there is a better solution for this issue

@Unparalleled-Calvin
Copy link
Contributor

Hi yihong. I have checked the code and figured out the reason that caused this bug. In short, the sub_span passed into the function locates at a macro code block which is outside the span.

An example:

macro_rules! foo{
    ... // the sub_span locates at here
}

fn bar() { // span
    foo!(...) // unfolded while compiling
}

Then the previous code computes relative_pos_range(span, sub_span) which causes an overflow bug.

Thank you for your contribution!

@yihong0618
Copy link
Contributor Author

Hi yihong. I have checked the code and figured out the reason that caused this bug. In short, the sub_span passed into the function locates at a macro code block which is outside the span.

An example:

macro_rules! foo{
    ... // the sub_span locates at here
}

fn bar() { // span
    foo!(...) // unfolded while compiling
}

Then the previous code computes relative_pos_range(span, sub_span) which causes an overflow bug.

Thank you for your contribution!

Thank you for the info, learned that

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.

failed to check some repos error byte index 4294800896 is out of bounds
2 participants