mirror of
				https://github.com/cldellow/sqlite-parquet-vtable.git
				synced 2025-11-04 02:39:56 +00:00 
			
		
		
		
	@@ -3,6 +3,9 @@ set -euo pipefail
 | 
			
		||||
 | 
			
		||||
# A harness that runs SQLite with the parquet extension in an environment where malloc randomly
 | 
			
		||||
# fails. "Success" is if the logs don't have any C++ exceptions that talk about std::bad_alloc
 | 
			
		||||
#
 | 
			
		||||
# The results can need a bit of interpretation; look at the log and see if it sniffs like
 | 
			
		||||
# the segfault came from Python or SQLite.
 | 
			
		||||
 | 
			
		||||
ensure_failmalloc() {
 | 
			
		||||
  if [ ! -d libfailmalloc ]; then
 | 
			
		||||
@@ -19,11 +22,16 @@ ensure_failmalloc() {
 | 
			
		||||
run_under_low_memory() {
 | 
			
		||||
  start=$(date +%s%3N)
 | 
			
		||||
  set +e
 | 
			
		||||
  env LD_PRELOAD="$here"/libfailmalloc/.libs/libfailmalloc.so FAILMALLOC_PROBABILITY=0.00001 ./test-random &> results.bad_alloc
 | 
			
		||||
  set -e
 | 
			
		||||
  env LD_PRELOAD="$here"/libfailmalloc/.libs/libfailmalloc.so FAILMALLOC_PROBABILITY=0.00001 ./test-random >results.bad_alloc 2>&1
 | 
			
		||||
  rv=$?
 | 
			
		||||
  now=$(date +%s%3N)
 | 
			
		||||
  echo "Bailed after $((now-start)) ms"
 | 
			
		||||
  ! grep std::bad_alloc results.bad_alloc
 | 
			
		||||
  set -e
 | 
			
		||||
  if [ "$rv" -gt 127 ]; then
 | 
			
		||||
    cat results.bad_alloc
 | 
			
		||||
    echo "Segfaulted with exit code: $rv"
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main() {
 | 
			
		||||
@@ -33,7 +41,7 @@ main() {
 | 
			
		||||
 | 
			
		||||
  ensure_failmalloc
 | 
			
		||||
  # Sometimes we'll exit due to a Python memory issue, so try a few times.
 | 
			
		||||
  for i in {0..10}; do
 | 
			
		||||
  for i in {0..100}; do
 | 
			
		||||
    run_under_low_memory
 | 
			
		||||
  done
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user