Skip to content

Commit

Permalink
don't perform allocations in php_warning if script allocator is disab…
Browse files Browse the repository at this point in the history
…led (VKCOM#636)
  • Loading branch information
DrDet authored Oct 3, 2022
1 parent 01582fa commit 238c8c1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions runtime/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ memory_resource::Dealer &get_memory_dealer() noexcept {
return dealer;
}

volatile bool script_allocator_enabled = false;

} // namespace

bool script_allocator_enabled = false;
long long query_num = 0;

memory_resource::unsynchronized_pool_resource &get_default_script_allocator() noexcept {
Expand Down
1 change: 1 addition & 0 deletions runtime/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class unsynchronized_pool_resource;

namespace dl {

extern bool script_allocator_enabled;
extern long long query_num; // engine query number. query_num == 0 before first query

memory_resource::unsynchronized_pool_resource &get_default_script_allocator() noexcept;
Expand Down
2 changes: 1 addition & 1 deletion runtime/php_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void php_warning_impl(bool out_of_memory, int error_type, char const *mes
return;
}

const bool allocations_allowed = !out_of_memory && !dl::in_critical_section;
const bool allocations_allowed = dl::script_allocator_enabled && !out_of_memory && !dl::in_critical_section;
dl::enter_critical_section();//OK

vsnprintf(buf, BUF_SIZE, message, args);
Expand Down

0 comments on commit 238c8c1

Please sign in to comment.