You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/17 05:58:23 UTC

[GitHub] [doris] HappenLee opened a new pull request, #13408: [Bug](funciton) fix repeat coredump when step is to long

HappenLee opened a new pull request, #13408:
URL: https://github.com/apache/doris/pull/13408

   # Proposed changes
   
   Fix repeat("abc", 2147483647) core dump in ASAN
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [x] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [x] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [x] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [x] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [x] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] HappenLee merged pull request #13408: [Bug](funciton) fix repeat coredump when step is to long

Posted by GitBox <gi...@apache.org>.
HappenLee merged PR #13408:
URL: https://github.com/apache/doris/pull/13408


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13408: [Bug](funciton) fix repeat coredump when step is to long

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13408:
URL: https://github.com/apache/doris/pull/13408#issuecomment-1280336394

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] BiteTheDDDDt commented on a diff in pull request #13408: [Bug](funciton) fix repeat coredump when step is to long

Posted by GitBox <gi...@apache.org>.
BiteTheDDDDt commented on code in PR #13408:
URL: https://github.com/apache/doris/pull/13408#discussion_r996643820


##########
be/src/vec/functions/function_string.h:
##########
@@ -758,51 +758,100 @@ class FunctionStringRepeat : public IFunction {
     size_t get_number_of_arguments() const override { return 2; }
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
-        return std::make_shared<DataTypeString>();
+        return make_nullable(std::make_shared<DataTypeString>());
     }
     bool use_default_implementation_for_constants() const override { return true; }
     Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) override {
         DCHECK_EQ(arguments.size(), 2);
         auto res = ColumnString::create();
+        auto null_map = ColumnUInt8::create();
 
         ColumnPtr argument_ptr[2];
         argument_ptr[0] =
                 block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
-        argument_ptr[1] =
-                block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        argument_ptr[1] = block.get_by_position(arguments[1]).column;
 
         if (auto* col1 = check_and_get_column<ColumnString>(*argument_ptr[0])) {
             if (auto* col2 = check_and_get_column<ColumnInt32>(*argument_ptr[1])) {
                 vector_vector(col1->get_chars(), col1->get_offsets(), col2->get_data(),
-                              res->get_chars(), res->get_offsets());
-                block.replace_by_position(result, std::move(res));
+                              res->get_chars(), res->get_offsets(), null_map->get_data());
+                block.replace_by_position(
+                        result, ColumnNullable::create(std::move(res), std::move(null_map)));
+                return Status::OK();
+            } else if (auto* col2_const = check_and_get_column<ColumnConst>(*argument_ptr[1])) {
+                DCHECK(check_and_get_column<ColumnInt32>(col2_const->get_data_column()));
+                int repeat = col2_const->get_int(0);
+                if (repeat <= 0) {
+                    null_map->get_data().resize_fill(input_rows_count, 0);
+                    res->insert_many_defaults(input_rows_count);
+                } else {
+                    vector_const(col1->get_chars(), col1->get_offsets(), repeat, res->get_chars(),
+                                 res->get_offsets(), null_map->get_data());
+                }
+                block.replace_by_position(
+                        result, ColumnNullable::create(std::move(res), std::move(null_map)));
                 return Status::OK();
             }
         }
 
-        return Status::RuntimeError("not support {}", get_name());
+        return Status::RuntimeError("repeat function get error param: {}, {}",
+                                    argument_ptr[0]->get_name(), argument_ptr[1]->get_name());
     }
 
     void vector_vector(const ColumnString::Chars& data, const ColumnString::Offsets& offsets,
                        const ColumnInt32::Container& repeats, ColumnString::Chars& res_data,
-                       ColumnString::Offsets& res_offsets) {
+                       ColumnString::Offsets& res_offsets, ColumnUInt8::Container& null_map) {
         size_t input_row_size = offsets.size();
-        //
+
         fmt::memory_buffer buffer;
         res_offsets.resize(input_row_size);
+        null_map.resize_fill(input_row_size, 0);
         for (ssize_t i = 0; i < input_row_size; ++i) {
             buffer.clear();
             const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
             int size = offsets[i] - offsets[i - 1];
             int repeat = repeats[i];
-            // assert size * repeat won't exceed
-            DCHECK_LE(static_cast<int64_t>(size) * repeat, std::numeric_limits<int32_t>::max());
-            for (int i = 0; i < repeat; ++i) {
-                buffer.append(raw_str, raw_str + size);
+
+            if (repeat <= 0) {
+                StringOP::push_empty_string(i, res_data, res_offsets);
+            } else if (repeat * size > DEFAULT_MAX_STRING_SIZE) {

Review Comment:
   Maybe we need to handle the case of overflowing INT_MAX



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13408: [Bug](funciton) fix repeat coredump when step is to long

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13408:
URL: https://github.com/apache/doris/pull/13408#issuecomment-1280336355

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org