-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] FIX out of bounds array access in SAGA #9376
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
did you spot this by setting boundscheck=True? |
I did not. I found it by narrowing in using old-school diffs over printed debug output. |
Is there a way to disable the nogil feature for a compilation so that exceptions will be propagated? |
I commented on the boundscheck at #9351 (comment) |
I confirm that I don't get the error in the branch after running 10 times the test. It fails on master on my mac. |
I've tried it well over 10 times, if that adds any weight. :) And even disabling the nogil, I'm not getting an exception raised with boundscheck=True :\ |
To get the exceptions to propagate:
to:
and update the implementation to
with gil:
raise ValueError(the_msg) |
I also confirm that fixes the issue on my mac. The diff looks good, however I am not familiar enough with the algorithm to tell whether the fix is correct. @arthurmensch can you confirm? |
Well, I'm sure that the successful runs are those when |
If there's reason to believe @arthurmensch will take more than a day to
review, I'd consider merging this as a temporary fix and building the RC.
It does, after all, make saga equal liblinear.
|
I will be reviewing this in one hour
…On Mon, Jul 17, 2017, 1:40 AM Joel Nothman ***@***.***> wrote:
If there's reason to believe @arthurmensch will take more than a day to
review, I'd consider merging this as a temporary fix and building the RC.
It does, after all, make saga equal liblinear.
On 17 Jul 2017 5:37 am, "Olivier Grisel" ***@***.***> wrote:
I also confirm that fixes the issue on my mac. The diff looks good, however
I am not familiar enough with the algorithm to tell whether the fix is
correct. @arthurmensch <https://github.com/arthurmensch> can you confirm?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<
#9376 (comment)
>,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AAEz6yS7EsHt_SWILOwNqhE5ask1PCb3ks5sOmaLgaJpZM4OZTV_
>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9376 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD48YyXK3fsSKaGFbXLF9xvqow4hlPqoks5sOp91gaJpZM4OZTV_>
.
|
:D
…On 17 Jul 2017 3:14 pm, "Arthur Mensch" ***@***.***> wrote:
I will be reviewing this in one hour
On Mon, Jul 17, 2017, 1:40 AM Joel Nothman ***@***.***>
wrote:
> If there's reason to believe @arthurmensch will take more than a day to
> review, I'd consider merging this as a temporary fix and building the RC.
> It does, after all, make saga equal liblinear.
>
> On 17 Jul 2017 5:37 am, "Olivier Grisel" ***@***.***>
wrote:
>
> I also confirm that fixes the issue on my mac. The diff looks good,
however
> I am not familiar enough with the algorithm to tell whether the fix is
> correct. @arthurmensch <https://github.com/arthurmensch> can you
confirm?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <
> #9376#
issuecomment-315631765
> >,
> or mute the thread
> <
> https://github.com/notifications/unsubscribe-auth/AAEz6yS7EsHt_
SWILOwNqhE5ask1PCb3ks5sOmaLgaJpZM4OZTV_
> >
> .
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#9376#
issuecomment-315646390>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AD48YyXK3fsSKaGFbXLF9xvqow4hlPqoks5sOp91gaJpZM4OZTV_>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9376 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz62WY3X8aREydHX9GdtZ52AsqXLCBks5sOu2lgaJpZM4OZTV_>
.
|
sklearn/linear_model/sag_fast.pyx
Outdated
- cumulative_sums[lagged_ind - 1]) | ||
prox_step = (cumulative_sums_prox[lagged_ind] | ||
- cumulative_sums_prox[lagged_ind - 1]) | ||
if lagged_ind > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should read >= 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Whoops. I think we were all a bit too enthusiastic to fix this.
sklearn/linear_model/sag_fast.pyx
Outdated
- cumulative_sums[lagged_ind - 1]) | ||
prox_step = (cumulative_sums_prox[lagged_ind] | ||
- cumulative_sums_prox[lagged_ind - 1]) | ||
if lagged_ind > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise there was indeed a problem there, I wonder how it went silently although wraparound = False
, any idea ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right: those are pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wraparound, etc, flags do not apply at all to pointers.
But the basic issue is that O/Ses allocate memory on the heap differently. Most of it tends to be zero (if only because we use 64 bit int arrays to store small numbers). So this just worked when the array happened to be allocated next to a zero ... which always happened on Travis and AppVeyor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We choose pointers because apparently they're a little more efficient than memoryviews, and much better where we want to handle read-only memmaps. But they're much less safe!
Fixed. Good for you? |
LGTM. I hope there is no other errors like this... I wondered why we used pointer there in the first place, but it's true that it allows to handle read-only memmap. Thanks ! |
Thanks very much for the fix, merging. |
I will do the backport to 0.19.X. |
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
Done. |
Release 0.19b2 * tag '0.19b2': (808 commits) Preparing 0.19b2 [MRG+1] FIX out of bounds array access in SAGA (scikit-learn#9376) FIX make test_importances pass on 32 bit linux Release 0.19b1 DOC remove 'in dev' header in whats_new.rst DOC typos in whats_news.rst [ci skip] [MRG] DOC cleaning up what's new for 0.19 (scikit-learn#9252) FIX t-SNE memory usage and many other optimizer issues (scikit-learn#9032) FIX broken link in gallery and bad title rendering [MRG] DOC Replace \acute by prime (scikit-learn#9332) Fix typos (scikit-learn#9320) [MRG + 1 (rv) + 1 (alex) + 1] Add a check to test the docstring params and their order (scikit-learn#9206) DOC Residual sum vs. regression sum (scikit-learn#9314) [MRG] [HOTFIX] Fix capitalization in test and hence fix failing travis at master (scikit-learn#9317) More informative error message for classification metrics given regression output (scikit-learn#9275) [MRG] COSMIT Remove unused parameters in private functions (scikit-learn#9310) [MRG+1] Ridgecv normalize (scikit-learn#9302) [MRG + 2] ENH Allow `cross_val_score`, `GridSearchCV` et al. to evaluate on multiple metrics (scikit-learn#7388) Add data_home parameter to fetch_kddcup99 (scikit-learn#9289) FIX makedirs(..., exists_ok) not available in Python 2 (scikit-learn#9284) ...
* releases: (808 commits) Preparing 0.19b2 [MRG+1] FIX out of bounds array access in SAGA (scikit-learn#9376) FIX make test_importances pass on 32 bit linux Release 0.19b1 DOC remove 'in dev' header in whats_new.rst DOC typos in whats_news.rst [ci skip] [MRG] DOC cleaning up what's new for 0.19 (scikit-learn#9252) FIX t-SNE memory usage and many other optimizer issues (scikit-learn#9032) FIX broken link in gallery and bad title rendering [MRG] DOC Replace \acute by prime (scikit-learn#9332) Fix typos (scikit-learn#9320) [MRG + 1 (rv) + 1 (alex) + 1] Add a check to test the docstring params and their order (scikit-learn#9206) DOC Residual sum vs. regression sum (scikit-learn#9314) [MRG] [HOTFIX] Fix capitalization in test and hence fix failing travis at master (scikit-learn#9317) More informative error message for classification metrics given regression output (scikit-learn#9275) [MRG] COSMIT Remove unused parameters in private functions (scikit-learn#9310) [MRG+1] Ridgecv normalize (scikit-learn#9302) [MRG + 2] ENH Allow `cross_val_score`, `GridSearchCV` et al. to evaluate on multiple metrics (scikit-learn#7388) Add data_home parameter to fetch_kddcup99 (scikit-learn#9289) FIX makedirs(..., exists_ok) not available in Python 2 (scikit-learn#9284) ...
* dfsg: (808 commits) Preparing 0.19b2 [MRG+1] FIX out of bounds array access in SAGA (scikit-learn#9376) FIX make test_importances pass on 32 bit linux Release 0.19b1 DOC remove 'in dev' header in whats_new.rst DOC typos in whats_news.rst [ci skip] [MRG] DOC cleaning up what's new for 0.19 (scikit-learn#9252) FIX t-SNE memory usage and many other optimizer issues (scikit-learn#9032) FIX broken link in gallery and bad title rendering [MRG] DOC Replace \acute by prime (scikit-learn#9332) Fix typos (scikit-learn#9320) [MRG + 1 (rv) + 1 (alex) + 1] Add a check to test the docstring params and their order (scikit-learn#9206) DOC Residual sum vs. regression sum (scikit-learn#9314) [MRG] [HOTFIX] Fix capitalization in test and hence fix failing travis at master (scikit-learn#9317) More informative error message for classification metrics given regression output (scikit-learn#9275) [MRG] COSMIT Remove unused parameters in private functions (scikit-learn#9310) [MRG+1] Ridgecv normalize (scikit-learn#9302) [MRG + 2] ENH Allow `cross_val_score`, `GridSearchCV` et al. to evaluate on multiple metrics (scikit-learn#7388) Add data_home parameter to fetch_kddcup99 (scikit-learn#9289) FIX makedirs(..., exists_ok) not available in Python 2 (scikit-learn#9284) ...
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
* FIX out of bounds array access in SAGA * FIX Fix boundary for condition
Fixes #9351 (random inconsistencies between SAGA and liblinear LogisticRegression on OS X).
To hedge my bets that this is the right fix, I'll ping @TomDLT, @arthurmensch, @dsullivan7.