From: stephan Date: Sat, 26 Aug 2023 16:55:27 +0000 (+0000) Subject: Correct a potential duplicate xDestroy() being triggered for Java-side collations. X-Git-Tag: version-3.44.0~279 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a0dc4895b54d4aca1b77f6078fd1736eaefc965;p=thirdparty%2Fsqlite.git Correct a potential duplicate xDestroy() being triggered for Java-side collations. FossilOrigin-Name: 25331172f78544f7f23ad7821cbf065589f6d02706184d4c83fe3988452dac5d --- diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 980da3d9f2..50f0ffb252 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -981,7 +981,7 @@ static int s3jni_db_exception(JNIEnv * const env, S3JniDb * const ps, /* ** Extracts the (void xDestroy()) method from jObj and applies it to ** jObj. If jObj is NULL, this is a no-op. The lack of an xDestroy() -** method is silently ignored and any exceptions thrown by xDestroy() +** method is silently ignored. Any exceptions thrown by xDestroy() ** trigger a warning to stdout or stderr and then the exception is ** suppressed. */ @@ -1012,11 +1012,14 @@ static void s3jni_call_xDestroy(JNIEnv * const env, jobject jObj){ ** cleared. It is legal to call this when the object has no Java ** references. */ -static void S3JniHook_unref(JNIEnv * const env, S3JniHook * const s, int doXDestroy){ - if( doXDestroy && s->jObj ){ - s3jni_call_xDestroy(env, s->jObj); +static void S3JniHook_unref(JNIEnv * const env, S3JniHook * const s, + int doXDestroy){ + if( s->jObj ){ + if( doXDestroy ){ + s3jni_call_xDestroy(env, s->jObj); + } + S3JniUnrefGlobal(s->jObj); } - S3JniUnrefGlobal(s->jObj); memset(s, 0, sizeof(*s)); } @@ -1062,18 +1065,18 @@ static void S3JniDb_set_aside_unlocked(JNIEnv * env, S3JniDb * const s){ SJG.perDb.aHead = s->pNext; } sqlite3_free( s->zMainDbName ); -#define UNHOOK(MEMBER,XDESTROY) S3JniHook_unref(env, &s->hooks.MEMBER, XDESTROY) - UNHOOK(auth, 0); - UNHOOK(busyHandler, 0); - UNHOOK(collation, 1); - UNHOOK(collationNeeded, 0); - UNHOOK(commit, 0); - UNHOOK(progress, 0); - UNHOOK(rollback, 0); - UNHOOK(trace, 0); - UNHOOK(update, 0); +#define UNHOOK(MEMBER) S3JniHook_unref(env, &s->hooks.MEMBER, 0) + UNHOOK(auth); + UNHOOK(busyHandler); + UNHOOK(collation); + UNHOOK(collationNeeded); + UNHOOK(commit); + UNHOOK(progress); + UNHOOK(rollback); + UNHOOK(trace); + UNHOOK(update); #ifdef SQLITE_ENABLE_PREUPDATE_HOOK - UNHOOK(preUpdate, 0); + UNHOOK(preUpdate); #endif #undef UNHOOK S3JniUnrefGlobal(s->jDb); diff --git a/ext/jni/src/org/sqlite/jni/Tester1.java b/ext/jni/src/org/sqlite/jni/Tester1.java index 5f574045c2..9ac1396f4b 100644 --- a/ext/jni/src/org/sqlite/jni/Tester1.java +++ b/ext/jni/src/org/sqlite/jni/Tester1.java @@ -488,7 +488,7 @@ public class Tester1 implements Runnable { private void testCollation(){ final sqlite3 db = createNewDb(); execSql(db, "CREATE TABLE t(a); INSERT INTO t(a) VALUES('a'),('b'),('c')"); - final ValueHolder xDestroyCalled = new ValueHolder<>(false); + final ValueHolder xDestroyCalled = new ValueHolder<>(0); final CollationCallback myCollation = new CollationCallback() { private String myState = "this is local state. There is much like it, but this is mine."; @@ -510,7 +510,7 @@ public class Tester1 implements Runnable { @Override public void xDestroy() { // Just demonstrates that xDestroy is called. - xDestroyCalled.value = true; + ++xDestroyCalled.value; } }; final CollationNeededCallback collLoader = new CollationNeededCallback(){ @@ -552,12 +552,12 @@ public class Tester1 implements Runnable { } affirm(3 == counter); sqlite3_finalize(stmt); - affirm(!xDestroyCalled.value); + affirm( 0 == xDestroyCalled.value ); rc = sqlite3_collation_needed(db, null); affirm( 0 == rc ); sqlite3_close_v2(db); affirm( 0 == db.getNativePointer() ); - affirm(xDestroyCalled.value); + affirm( 1 == xDestroyCalled.value ); } @ManualTest /* because threading is meaningless here */ diff --git a/manifest b/manifest index 7e8b84cc87..81aaf952d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Recycle\sper-UDF\sJNI\sstate. -D 2023-08-26T16:29:48.809 +C Correct\sa\spotential\sduplicate\sxDestroy()\sbeing\striggered\sfor\sJava-side\scollations. +D 2023-08-26T16:55:27.685 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -236,7 +236,7 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile d9244b5addf58868343a74a94faa71f829e7f40c163486d053f4b4bbea173703 F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c ac4020f987abc0f3970119d279d26b74de8fb9b1b49da4046dd3e74a40f9a819 +F ext/jni/src/c/sqlite3-jni.c b2ddceed02600dfdaa3a0d876111b7ad2d4f247f8396f3c1b68bb9ea2e129a4a F ext/jni/src/c/sqlite3-jni.h 2745c4abd0933a4e8cc48989fffbad3936b4eaada64cce9ce11453dcd30e4184 F ext/jni/src/org/sqlite/jni/AggregateFunction.java e0aac6ccae05702f8ee779820570866a2760aaa57a73135c57c8d3580bef52d5 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java c374bb76409cce7a0bdba94877706b59ac6127fa5d9e6af3e8058c99ce99c030 @@ -264,7 +264,7 @@ F ext/jni/src/org/sqlite/jni/SQLFunction.java d060f302b2cc4cf7a4f5a6b2d36458a2e6 F ext/jni/src/org/sqlite/jni/SQLite3CallbackProxy.java 13c4ea6f35871261eba63fa4117715515e0beecbdebfb879ec5b1f340ed36904 F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 4be23360d93011d80676bebb1f21f7da0fc4ab637a6d138c8c35bbb2f764b19d F ext/jni/src/org/sqlite/jni/ScalarFunction.java 21301a947e49f0dd9c682dfe2cc8a6518226c837253dd791cd512f847eeca52c -F ext/jni/src/org/sqlite/jni/Tester1.java 929347853b4b6a1039d4878b629e2eaefa559ed4fee77af44f0667818cb0ce76 +F ext/jni/src/org/sqlite/jni/Tester1.java f5205a22f10de63298ede691ed2938ab39084d1ff13d6f53a54c5100f798b933 F ext/jni/src/org/sqlite/jni/TesterFts5.java 6f135c60e24c89e8eecb9fe61dde0f3bb2906de668ca6c9186bcf34bdaf94629 F ext/jni/src/org/sqlite/jni/TraceV2Callback.java 25a45e800b0c57f506c237d111bcfd09da584e936fee395d4bd802100ebeff8c F ext/jni/src/org/sqlite/jni/UpdateHookCallback.java f5eadfa44462c050658230884b41477274f34306accd85c8201a7afbc00d2429 @@ -2103,8 +2103,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d6b5ecd28740c2c5d21797fce9fe137c8a83f702f22901720cc6e8b1b42af001 -R b3a9fb323c6b84f48b5856006714684b +P cf406528eb86d8d0d55a468b2c4ec32a11a4947f45c4bbabdde8742ae199ce1f +R 5e283ad208dc4181e7491a5a1cc6002c U stephan -Z 9c33a91e895e4fc7c7f885475275408f +Z fd7fa811e5faceb76dda701b17b92b49 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f3a58cea1e..9422aa180e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf406528eb86d8d0d55a468b2c4ec32a11a4947f45c4bbabdde8742ae199ce1f \ No newline at end of file +25331172f78544f7f23ad7821cbf065589f6d02706184d4c83fe3988452dac5d \ No newline at end of file