-
Notifications
You must be signed in to change notification settings - Fork 7.8k
PDO OCI segfault in statement GC #18494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I recognize this type of issue I think based on the trace, I fixed some crap like this before: 2ae897f |
Thanks. The issue is reproducible at least with the bundled pdo_oci and https://github.com/atk4/data/blob/6.0.0/.github/workflows/test-unit.yml#L115-L118 docker Oracle server. @nielsdos do you think we can somehow work around this in php code? |
Only if you disable GC. |
Are you able to do a build of PHP yourself with this patch applied? diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index f3be69f9c32..f91b27975e8 100644
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -98,14 +98,21 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
S->einfo.errmsg = NULL;
}
+ /* TODO: There's php_pdo_stmt_valid_db_obj_handle in PHP-8.5-dev that does these checks. */
+ bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
+ && IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
+ && !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
+
if (S->cols) {
for (i = 0; i < stmt->column_count; i++) {
if (S->cols[i].data) {
switch (S->cols[i].dtype) {
case SQLT_BLOB:
case SQLT_CLOB:
- OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
- (OCILobLocator *) S->cols[i].data);
+ if (server_obj_usable) {
+ OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
+ (OCILobLocator *) S->cols[i].data);
+ }
OCIDescriptorFree(S->cols[i].data, OCI_DTYPE_LOB);
break;
default:
|
I am trying to test this on my side. I need to tweak our php image build process first. Is it only a coincidence that this issue is present for PHP 8.3+ only or is it present also for PHP 8.2? |
🏆 I can confirm the issue is gone with the patch above! |
Thanks for testing, I'll make a PR, I'm not going to isolate a test however as that'll take me too long and I only have the OCI setup for building. Besides, it's similar to the other patches. |
This is the same issue that was fixed in 2ae897f, but now for OCI.
I believe this also applies on 8.2. |
* PHP-8.3: Fix GH-18494: PDO OCI segfault in statement GC
* PHP-8.4: Fix GH-18494: PDO OCI segfault in statement GC
This is the same issue that was fixed in 2ae897fff7af3a794a31a8aeeeeb4f21f6a41393, but now for OCI. Fixed at php-src on 8.3 in php/php-src#18495
Description
Backtrace:
Full repro code: https://github.com/atk4/data/tree/repro_oracle_83_segfault
Notes:
I tried to isolate the reproducer into a single file /wo phpunit, but it seems even merging the 2 tests into 1 prevent this bug.
Also this issue seems to be present with PDO OCI driver only. OCI8 and other PDO drivers are unaffected.
PHP Version
Operating System
Alpine
The text was updated successfully, but these errors were encountered: