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

Fix access violation exception that can occur during invocation of loop lambda function when inner_start >= inner_end in 'For' template. #3936

Merged
merged 17 commits into from
Feb 13, 2021

Conversation

mjmckp
Copy link
Contributor

@mjmckp mjmckp commented Feb 10, 2021

In particular, this can occur in Tree::AddPredictionToScore on line 291 of src\io\tree.cpp where the loop lambda function body (created by the PredictionFun macro) dereferences used_data_indices[start].

For reference, the particular case which triggered this exception in my case was:

  • start = 0
  • end = 93,203
  • min_block_size = 512
    for which the BlockInfo method gave:
  • n_block = 56
  • num_inner = 1,696
    and so, for the case i=55 (i.e., the last case in the loop), we get
  • inner_start = start + num_inner * i = 93,280
    which is greater than 'end' and hence triggers the exception.

matthew-peacock and others added 16 commits November 2, 2018 13:07
…datasets.

Prior to this change, the line "score_t threshold = tmp_gradients[top_k - 1];" would generate an exception, since tmp_gradients would be empty when the cnt input value to the function is zero.
…data set given as of array of pointers to rows (as opposed to existing method LGBM_BoosterPredictForMat which requires data given as contiguous array)
…op lambda function when inner_start >= inner_end in 'For' template.

In particular, this can occur in Tree::AddPredictionToScore on line 291 where the loop lambda function body (created by the PredictionFun macro) dereferences used_data_indices[start].

For reference, the particular case which triggered this exception in my case was:
  * start = 0
  * end = 93,203
  * n_block = 56
  * min_block_size = 512
for which the BlockInfo method gave:
  * n_block = 56
  * num_inner = 1,696
and so, for the case i=55 (i.e., the last case in the loop), we get
  * inner_start = start + num_inner * i
                = 93,280
which is greater than 'end' and hence triggers the exception.
@guolinke
Copy link
Collaborator

cc @shiyu1994
I think there are multiple places could have this problem, could you check them carefully?

Copy link
Collaborator

@guolinke guolinke left a comment

Choose a reason for hiding this comment

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

Thank you!

@StrikerRUS StrikerRUS merged commit 5abf8bb into microsoft:master Feb 13, 2021
@shiyu1994
Copy link
Collaborator

I've checked all the #pragma omp directives. I think this is the only place with such problem. In other cases even when inner_start is no less than inner_end, there'll be no problem.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants