Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented Feb 8, 2023

We must not instantiate the object prior to checking error conditions.

Moreover, we need to release the HUGE amount of memory for files which are over 4GB when throwing a ValueError.

RETURN_THROWS();
}

tidy_instanciate(tidy_ce_doc, return_value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good but are you fixing just a bit more than memory leak here ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind, just saw the rest of your commit message.

Comment on lines 18 to 25
const MIN_FILE_SIZE = 4_294_967_295;
$total_bytes = 0;
$s = str_repeat("a", 10_000);
while ($total_bytes < MIN_FILE_SIZE) {
$bytes_written = fwrite($file, $s);
if ($bytes_written === false) {
echo "Didn't write bytes\n";
}
$total_bytes += $bytes_written;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a sparse file sufficient to reproduce the issue? You should be able to create one by seeking to a large offset and then writing something. This should be much faster and take up less disk storage when running the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about sparse files until now. Let me try that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test LGTM now. I trust you tested that it still does what you expect it to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did :)

We must not instantiate the object prior checking error conditions
Moreover, we need to release the HUGE amount of memory for files which are over 4GB when throwing a ValueError
@Girgias Girgias force-pushed the tidy-memory-leak-fixes branch from 19c1e20 to ccc21ec Compare February 9, 2023 14:30
@Girgias Girgias force-pushed the tidy-memory-leak-fixes branch from ca67517 to 54b5d61 Compare February 9, 2023 15:59
@Girgias Girgias closed this in 704aadd Feb 10, 2023
@Girgias Girgias deleted the tidy-memory-leak-fixes branch February 10, 2023 14:17
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this test? It causes issues in CI. We should at least disable it for ASAN/UBSAN/MSAN.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have such a test, but skiping it for ASAN/UBSAN/MSAN can make sense, as this what caught by ZMM anyway.

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.

4 participants