Opened 3 years ago

Closed 3 years ago

#286 closed ожидается проверка (задача сдана)

Petryakov Ivan HA#5

Reported by: Иван Owned by: rutsky,grabovoy.philipp
Priority: проверка Milestone: ha5-deadline
Component: HA#5 lazy_string Version:
Keywords: Cc:

Description


Change History (29)

comment:1 Changed 3 years ago by cpptester

Type: ожидается проверкаожидаются исправления

Tested revision 612 by petryakov.ivan.

Smoke tests

test

stage

result

info

log

run_smoke_test.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_smoke_test-valgrind.log

SUCCESS
FAILURE

exit code 1

run_smoke_test-asan.log

SUCCESS
FAILURE

exit code 1

run_smoke_test-san.log

Common header used in some tests: common.h

comment:3 Changed 3 years ago by cpptester

Tested revision 730 by petryakov.ivan.

Main tests

test

stage

result

info

log

comp_aug_assign_lazy_string.cpp

FAILURE

comp_aug_assign_lazy_string-gcc62.log

comp_char_traits_custom.cpp

FAILURE

comp_char_traits_custom-gcc62.log

comp_include_guard.cpp

FAILURE

comp_include_guard-gcc62.log

comp_index_const.cpp

FAILURE

comp_index_const-gcc62.log

run_assign_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_assign_c_str_char_traits_length-run.log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-san.log

run_aug_plus_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-san.log

run_aug_plus_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_aug_plus_c_str_char_traits_length-run.log

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-san.log

Common header used in some tests: common.h

comment:4 Changed 3 years ago by cpptester

Tested revision 731 by petryakov.ivan.

Main tests

test

stage

result

info

log

comp_char_traits_custom.cpp

FAILURE

comp_char_traits_custom-gcc62.log

comp_include_guard.cpp

FAILURE

comp_include_guard-gcc62.log

comp_index_const.cpp

FAILURE

comp_index_const-gcc62.log

run_assign_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_assign_c_str_char_traits_length-run.log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-san.log

run_aug_plus_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-san.log

run_aug_plus_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_aug_plus_c_str_char_traits_length-run.log

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-san.log

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-san.log

Common header used in some tests: common.h

comment:5 Changed 3 years ago by cpptester

Tested revision 732 by petryakov.ivan.

Main tests

test

stage

result

info

log

comp_char_traits_custom.cpp

FAILURE

comp_char_traits_custom-gcc62.log

comp_include_guard.cpp

FAILURE

comp_include_guard-gcc62.log

comp_index_const.cpp

FAILURE

comp_index_const-gcc62.log

run_assign_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_assign_c_str_char_traits_length-run.log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-san.log

run_aug_plus_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-san.log

run_aug_plus_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_aug_plus_c_str_char_traits_length-run.log

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-san.log

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-san.log

Common header used in some tests: common.h

comment:6 Changed 3 years ago by cpptester

Tested revision 733 by petryakov.ivan.

Main tests

test

stage

result

info

log

comp_char_traits_custom.cpp

FAILURE

comp_char_traits_custom-gcc62.log

run_assign_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_assign_c_str_char_traits_length-run.log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-san.log

run_aug_plus_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-san.log

run_aug_plus_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_aug_plus_c_str_char_traits_length-run.log

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-san.log

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-san.log

run_aug_plus_c_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

Common header used in some tests: common.h

comment:7 Changed 3 years ago by Vladimir Rutsky

Иван, исправьте, пожалуйста, ваше решение, чтобы оно проходило автотесты.

Если есть проблемы с отладкой почему тот или иной тест не работает (или почему он должен работать) --- пишите, поможем разобраться.

comment:8 Changed 3 years ago by cpptester

Tested revision 792 by petryakov.ivan.

Main tests

test

stage

result

info

log

comp_char_traits_custom.cpp

FAILURE

comp_char_traits_custom-gcc62.log

run_assign_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_assign_c_str_char_traits_length-run.log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus-san.log

run_aug_plus_aug_plus.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_aug_plus-san.log

run_aug_plus_c_str_char_traits_length.cpp

SUCCESS
FAILURE

exit code 139

run_aug_plus_c_str_char_traits_length-run.log

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-san.log

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-san.log

run_aug_plus_c_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

Common header used in some tests: common.h

comment:9 Changed 3 years ago by cpptester

Tested revision 793 by petryakov.ivan.

Main tests

test

stage

result

info

log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_shared_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_shared_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_shared_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_wstr_no_mem-asan.log

SUCCESS
SUCCESS

Common header used in some tests: common.h

comment:10 Changed 3 years ago by Иван

Добрый день. Не могли бы Вы помочь мне со случаем, когда не хватает памяти. Я не до конца понимаю что требуется в таких тестах и как справляться с этим. Спасибо.

comment:11 Changed 3 years ago by Vladimir Rutsky

Добрый день!

Тесты *no_mem* проверяют, что решение удовлетворяет строгой гарантии безопасности исключений, т.е. в случае, если во время выполнения операции будет брошено исключение (например, std::bad_alloc), то прерванная операция оставит lazy_string в неизменном состоянии и не будет side effect-ов (вроде утечек памяти).

В вашем решении наблюдаются утечки памяти при возникновении исключений.
В тесте run_assign_c_str_no_mem.cpp в приведённом логе Valgrind:

==1== 4 bytes in 1 blocks are definitely lost in loss record 1 of 2
==1==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1==    by 0x4015DB: ch::allocate(unsigned long) (common.h:28)
==1==    by 0x401191: operator new[](unsigned long) (common.h:326)
==1==    by 0x40179C: std_utils::lazy_basic_string<char, std::char_traits<char> >::lazy_basic_string(char const*) (lazy_string.hpp:101)
==1==    by 0x40126B: main (run_assign_c_str_no_mem.cpp:19)

память, выделенная в lazy_string.hpp:101 с помощью new не освобождается. Вот в этом коде:

        lazy_basic_string(const _CharT * _cstr)
        {
            size_t len_c = _Traits::length(_cstr);
            if (len_c != 0)
            {
                _CharT *temp = new _CharT[len_c+1];  // <- memory leak here 
                _Traits::copy(temp, _cstr, len_c);
                _Traits::assign(temp[len_c],_CharT());
                _buffer = std::make_shared<details::buffer<_CharT>>(temp, len_c);
            }
            else 
            {
                _buffer = std::make_shared<details::buffer<_CharT>>(nullptr, 0);
            }
        }

В тесте воспроизводится случай, когда в 101 строке выделение памяти с помощью new[] произошло успешно, но несколькими строками ниже в std::make_shared памяти "не хватило" и было брошено исключение. Исключение привело к раскручиванию стека и память от new[] никто не освободил.

Наивный подход к решению данной проблемы обернуть второе выделение памяти (std::make_shared) в try/catch, но тогда придётся либо ловить все исключения catch (...), либо детально разбираться, какие исключения будут брошены. Плюс будет необходимо обернуть в try/catch все места, которые потенциально бросить исключения, что сложно в реализации и поддержки.
Рекомендуемый подход --- это использовать RAII, и обернуть выделения памяти в контейнеры, которые будут освобождать память, при их уничтожения (а все объекты на стеке будут корректно уничтожены при пробросе исключения).

Вы можете, например, обернуть выделение памяти в std::unique_ptr:

                std::unique_ptr<_CharT[]> temp(new _CharT[len_c + 1]); // or auto temp = std::make_unique<...
                _Traits::copy(temp.get(), _cstr, len_c);
                _Traits::assign(temp[len_c],_CharT());
                _buffer = std::make_shared<details::buffer<_CharT>>(temp.release(), len_c);

comment:13 Changed 3 years ago by Vladimir Rutsky

Иван, вам требуется помощь в отладке вашего решения?

comment:14 Changed 3 years ago by cpptester

comment:15 Changed 3 years ago by cpptester

Tested revision 830 by petryakov.ivan.

Main tests

test

stage

result

info

log

run_clear_no_mem.cpp

SUCCESS
FAILURE

exit code 139

run_clear_no_mem-run.log

run_ctor_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_ctor_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_ctor_c_str_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_ctor_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_ctor_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_ctor_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_ctor_c_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_ctor_c_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_ctor_c_wstr_no_mem-asan.log

SUCCESS
SUCCESS

run_ctor_repeat_char_traits_assign_count.cpp

SUCCESS
FAILURE

exit code 139

run_ctor_repeat_char_traits_assign_count-run.log

run_index_assign_copy_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-san.log

run_less.cpp

SUCCESS
FAILURE

exit code 139

run_less-run.log

run_less_lazy_str.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-san.log

run_less_lazy_str_rev.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str_rev-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-san.log

run_less_rev.cpp

SUCCESS
FAILURE

exit code 139

run_less_rev-run.log

Common header used in some tests: common.h

comment:16 Changed 3 years ago by cpptester

Tested revision 831 by petryakov.ivan.

Main tests

test

stage

result

info

log

run_clear_no_mem.cpp

SUCCESS
FAILURE

exit code 139

run_clear_no_mem-run.log

run_index_assign_copy_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-asan.log

SUCCESS
FAILURE

exit code 1

run_index_assign_copy_no_mem-san.log

run_less.cpp

SUCCESS
FAILURE

exit code 139

run_less-run.log

run_less_lazy_str.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-san.log

run_less_lazy_str_rev.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str_rev-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-san.log

run_less_rev.cpp

SUCCESS
FAILURE

exit code 139

run_less_rev-run.log

run_plus.cpp

FAILURE

run_plus-gcc62.log

run_plus_c_str_no_mem_rev.cpp

SUCCESS
FAILURE

exit code 139

run_plus_c_str_no_mem_rev-run.log

run_plus_char_no_mem_rev.cpp

SUCCESS
FAILURE

exit code 139

run_plus_char_no_mem_rev-run.log

run_plus_const.cpp

FAILURE

run_plus_const-gcc62.log

Common header used in some tests: common.h

comment:17 Changed 3 years ago by cpptester

Tested revision 832 by petryakov.ivan.

Main tests

test

stage

result

info

log

run_less.cpp

SUCCESS
SUCCESS
SUCCESS

run_less-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less-asan.log

SUCCESS
FAILURE

exit code 1

run_less-san.log

run_less_lazy_str.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str-san.log

run_less_lazy_str_rev.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_lazy_str_rev-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-asan.log

SUCCESS
FAILURE

exit code 1

run_less_lazy_str_rev-san.log

run_less_rev.cpp

SUCCESS
SUCCESS
SUCCESS

run_less_rev-valgrind.log

SUCCESS
FAILURE

exit code 1

run_less_rev-asan.log

SUCCESS
FAILURE

exit code 1

run_less_rev-san.log

run_plus.cpp

FAILURE

run_plus-gcc62.log

run_plus_c_str_no_mem_rev.cpp

SUCCESS
FAILURE

exit code 139

run_plus_c_str_no_mem_rev-run.log

run_plus_char_no_mem_rev.cpp

SUCCESS
FAILURE

exit code 139

run_plus_char_no_mem_rev-run.log

run_plus_const.cpp

FAILURE

run_plus_const-gcc62.log

Common header used in some tests: common.h

comment:18 Changed 3 years ago by cpptester

Tested revision 833 by petryakov.ivan.

All tests passed. Good job!

comment:19 Changed 3 years ago by Иван

Type: ожидаются исправленияожидается проверка

Добрый день. Проверьте, пожалуйста, мою реализацию.

comment:20 Changed 3 years ago by Vladimir Rutsky

Milestone: ha5-milestone2ha5-deadline
Type: ожидается проверкаожидаются исправления

Замечания:

  1. Включайте системный заголовочные файлы используя <>: #include <memory>.
  1. Не используйте try/catch для реализации строгой гарантии безопасности исключений.

Оберните выделяемую память с помощью new в std::unique_ptr, как я указал в комментарии раньше, например, здесь:

     lazy_basic_string()
     {
         _CharT* t = nullptr;
         try {
             t = new _CharT[1];
             _Traits::assign(t[0], _CharT());
             _buffer = std::make_shared<details::buffer<_CharT> >(t, 0);
         }
         catch (std::bad_alloc e)
         {
             delete[] t;
             throw e;
         }
     }

comment:21 Changed 3 years ago by cpptester

Tested revision 840 by petryakov.ivan.

Main tests

test

stage

result

info

log

run_assign_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_assign_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_c_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_c_wstr_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_char_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_char_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_char_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_char_traits_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_char_traits_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_char_traits_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_str_shared_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_shared_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_str_shared_no_mem-asan.log

SUCCESS
SUCCESS

run_aug_plus_lazy_wstr_no_mem.cpp

SUCCESS
SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_wstr_no_mem-valgrind.log

SUCCESS
FAILURE

exit code 1

run_aug_plus_lazy_wstr_no_mem-asan.log

SUCCESS
SUCCESS

Common header used in some tests: common.h

comment:22 Changed 3 years ago by Иван

Добрый день! Теперь я обернул указатели в unique_ptr, но все равно наблюдаются проблемы с утечкой памяти. Посоветуйте, пожалуйста, что можно исправить или добавить?

comment:23 Changed 3 years ago by Иван

Type: ожидаются исправленияожидается проверка

comment:24 Changed 3 years ago by Vladimir Rutsky

Это я вам неправильно написал, про

_buffer = std::make_shared<details::buffer<_CharT>>(temp.release(), len_c);

После temp.release() unique_ptr уже не будет владеть памятью и она утечет, если make_shared бросит исключение.

Добавьте в buffer конструктор от unique_ptr (или измените текущий), и move-айте его внутрь:

_buffer = std::make_shared<details::buffer<_CharT>>(std::move(temp), len_c);

comment:25 Changed 3 years ago by Vladimir Rutsky

Type: ожидается проверкаожидаются исправления

comment:26 Changed 3 years ago by Vladimir Rutsky

Иван, исправьте, пожалуйста, до конца воскресенья.

comment:27 Changed 3 years ago by cpptester

Tested revision 846 by petryakov.ivan.

All tests passed. Good job!

comment:28 Changed 3 years ago by Иван

Type: ожидаются исправленияожидается проверка

Спасибо за помощь, теперь все работает.

comment:29 Changed 3 years ago by Vladimir Rutsky

Resolution: задача сдана
Status: newclosed

Замечания: операторы сравнения стоило определить в std_utils --- они будут находиться по argument dependent lookup во время выбора перегрузки.

Решение зачтено.

Note: See TracTickets for help on using tickets.