Skip to content

Commit

Permalink
Fix a possible cause of UB and add a check for join output sizes that…
Browse files Browse the repository at this point in the history
… exceed cudf limits.
  • Loading branch information
vyasr committed Jul 20, 2021
1 parent 1328e16 commit 2d25a71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpp/include/cudf/ast/detail/expression_evaluator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ struct value_expression_result
/**
* @brief Returns the underlying data.
*
* @throws thrust::bad_optional_access if the underlying data is not valid.
* If the underlying data is not valid, behavior is undefined. Callers should
* use is_valid to check for validity before accessing the value.
*/
__device__ T value() const
{
// Using two separate constexprs silences compiler warnings, whereas an
// if/else does not. An unconditional return is not ignored by the compiler
// when has_nulls is true and therefore raises a compiler error.
if constexpr (has_nulls) { return _obj.value(); }
if constexpr (has_nulls) { return *_obj; }
if constexpr (!has_nulls) { return _obj; }
}

Expand Down
3 changes: 3 additions & 0 deletions cpp/src/join/conditional_join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <rmm/cuda_stream_view.hpp>

#include <limits>

namespace cudf {
namespace detail {

Expand Down Expand Up @@ -109,6 +111,7 @@ conditional_join(table_view const& left,
CHECK_CUDA(stream.value());

size_type const join_size = size.value(stream);
CUDF_EXPECTS(join_size < std::numeric_limits<size_type>::max(), "The result of this join is too large for a cudf column.");

// If the output size will be zero, we can return immediately.
if (join_size == 0) {
Expand Down

0 comments on commit 2d25a71

Please sign in to comment.