SQLite Forum

launch backup_malloc.test error
Login

launch backup_malloc.test error

(1) By liziqi on 2021-09-23 09:20:54 [link]

Hi all. We're currently on SQLite 3.32.2, and we've been noticed that testcase mallocAll.test would fail because of backup_malloc.test doesn't close db.

backup_malloc.test did not close all files: 1

In the latest version of backup_malloc.test, the problem still exist. So is it correct that close db and db2 when finalize the backup. 

origin testcase backup_malloc.test : 

do_faultsim_test 3 -faults oom* -prep {
  catch { db close }
  catch { db2 close }

  forcedelete test2.db
  sqlite3 db2 test2.db
  sqlite3 db test.db
  sqlite3_backup B db2 main db main
} -body {

  set rc [B step 50]
  if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
    error "out of memory"
  }

} -test {
  faultsim_test_result {0 {}} 
  faultsim_integrity_check
  
  # Finalize the backup.
  catch { B finish }
}

modified testcase backup_malloc.test : 
do_faultsim_test 3 -faults oom* -prep {
  catch { db close }
  catch { db2 close }

  forcedelete test2.db
  sqlite3 db2 test2.db
  sqlite3 db test.db
  sqlite3_backup B db2 main db main
} -body {

  set rc [B step 50]
  if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
    error "out of memory"
  }

} -test {
  faultsim_test_result {0 {}} 
  faultsim_integrity_check
  
  # Finalize the backup.
  catch { B finish }
  catch {db close}
  catch {db2 close}
}

Thank you!

Liziqi

(2) By Larry Brasfield (larrybr) on 2021-09-23 13:29:56 in reply to 1 [link]

The issue you report does not appear to exist with v3.37.0 (in alpha now.)

Furthermore, the test/backup_malloc.test has not been modified as you suggest for that coming release, and I do not think it should be. Among the "features" tested is not leaking memory in the face of unusual OOM situations.

(3) By liziqi on 2021-09-24 02:07:25 in reply to 2

Which testcase do you execute ? backup_malloc.test or mallocAll.test ? If only execute backup_malloc.test, it wolud be ok because it doesn't check that fd is closed. 

If not encounter OOM situations in the backup_malloc.test, the testcase also is ok, But the fd is not closed, it would affect the result of other testcases, such as malloc.test malloc-1.X etc. if so, the relation of tesecases exists coupling. This scenario is also right ?