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

Handle empty array inputs carefully, to avoid undefined behavior #314

Merged
merged 1 commit into from
Oct 28, 2021

Conversation

hcho3
Copy link
Collaborator

@hcho3 hcho3 commented Sep 18, 2021

Undefined behavior was detected by memory sanitizer. When (de)serializing empty arrays, Treelite calls std::fwrite / std::fread / std::memcpy with nullptr as the first argument. We must check for zero size prior to calling these functions.

I will follow up with another PR to add option to build with sanitizer.

@codecov
Copy link

codecov bot commented Sep 18, 2021

Codecov Report

Merging #314 (09a15dd) into mainline (80a7410) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff               @@
##             mainline     #314      +/-   ##
==============================================
- Coverage       85.15%   85.12%   -0.03%     
  Complexity         46       46              
==============================================
  Files             108      108              
  Lines            8264     8270       +6     
  Branches          471      471              
==============================================
+ Hits             7037     7040       +3     
- Misses           1202     1205       +3     
  Partials           25       25              
Impacted Files Coverage Δ
include/treelite/tree_impl.h 90.81% <100.00%> (+0.11%) ⬆️
include/treelite/typeinfo.h 86.66% <0.00%> (-3.34%) ⬇️
src/threading_utils/parallel_for.h 97.61% <0.00%> (-2.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80a7410...09a15dd. Read the comment docs.

@hcho3 hcho3 merged commit 9acfa21 into dmlc:mainline Oct 28, 2021
@hcho3 hcho3 deleted the fix_empty_array_handling branch October 28, 2021 10:13
This was referenced Jan 13, 2022
rapids-bot bot pushed a commit to rapidsai/cuml that referenced this pull request Jan 25, 2022
The 2.2.0 version of Treelite incorporates the following major improvements:

* dmlc/treelite#314
* dmlc/treelite#322, dmlc/treelite#327
* dmlc/treelite#325
* dmlc/treelite#332
* dmlc/treelite#330
* dmlc/treelite#333
* dmlc/treelite#334
* dmlc/treelite#304
* dmlc/treelite#335

In particular, dmlc/treelite#332, dmlc/treelite#330, dmlc/treelite#333 are required for #4447.

Requires rapidsai/integration#412.

EDIT. Using 2.2.1 patch release, to incorporate a hotfix (dmlc/treelite#340).

Authors:
  - Philip Hyunsu Cho (https://github.com/hcho3)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #4484
vimarsh6739 pushed a commit to vimarsh6739/cuml that referenced this pull request Oct 9, 2023
The 2.2.0 version of Treelite incorporates the following major improvements:

* dmlc/treelite#314
* dmlc/treelite#322, dmlc/treelite#327
* dmlc/treelite#325
* dmlc/treelite#332
* dmlc/treelite#330
* dmlc/treelite#333
* dmlc/treelite#334
* dmlc/treelite#304
* dmlc/treelite#335

In particular, dmlc/treelite#332, dmlc/treelite#330, dmlc/treelite#333 are required for rapidsai#4447.

Requires rapidsai/integration#412.

EDIT. Using 2.2.1 patch release, to incorporate a hotfix (dmlc/treelite#340).

Authors:
  - Philip Hyunsu Cho (https://github.com/hcho3)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#4484
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.

1 participant