Skip to content

[CRASH] Keydb crashes with redisearch in KeyDB image created from main branch #708

Closed
@sapvs

Description

@sapvs

Keydb crashes with redisearch in KeyDB image created from main branch

Crash report
1:1:M 10 Aug 2023 11:16:53.790 # Server initialized
1:1:M 10 Aug 2023 11:16:53.794 * <search> Redis version found by RedisSearch : 255.255.255 - oss
1:1:M 10 Aug 2023 11:16:53.794 * <search> RediSearch version 2.8.1 (Git=HEAD-251cc55f)
1:1:M 10 Aug 2023 11:16:53.794 * <search> Low level api version 1 initialized successfully
1:1:M 10 Aug 2023 11:16:53.794 * <search> concurrent writes: OFF, gc: ON, prefix min length: 2, prefix max expansions: 200, query timeout (
ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search re
sults:  1000000, search pool size: 20, index pool size: 8,
1:1:M 10 Aug 2023 11:16:53.797 * <search> Initialized thread pools!
1:1:M 10 Aug 2023 11:16:53.797 * <search> Enabled diskless replication
1:1:M 10 Aug 2023 11:16:53.797 * <search> Enabled role change notification
1:1:M 10 Aug 2023 11:16:53.797 * Module 'search' loaded from /etc/libs/redisearch.so


=== KEYDB BUG REPORT START: Cut & paste starting from here ===
1:1:M 10 Aug 2023 11:16:53.797 # KeyDB 255.255.255 crashed by signal: 11, si_code: 1
1:1:M 10 Aug 2023 11:16:53.797 # Accessing address: 0x48
1:1:M 10 Aug 2023 11:16:53.797 # Crashed running the instruction at: 0x7efc64c908e6

------ STACK TRACE ------
EIP:
/etc/libs/redisearch.so(+0x1a78e6) [0x7efc64c908e6]

Backtrace:
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14420) [0x7efc67923420]
/etc/libs/redisearch.so(+0x1a78e6) [0x7efc64c908e6]
keydb-server *:6379(+0x26aef5) [0x55a6880eeef5]
keydb-server *:6379(InitServerLast()+0x6e) [0x55a6881c28de]
keydb-server *:6379(main+0x566) [0x55a68808f096]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7efc67741083]
keydb-server *:6379(_start+0x2e) [0x55a6880b467e]

------ REGISTERS ------
1:1:M 10 Aug 2023 11:16:53.798 #
RAX:0000000000000000 RBX:0000000000000003
RCX:0000000000000003 RDX:0000000000000001
RDI:00007ffff555a1c0 RSI:0000000000000003
RBP:00007ffff555a1c0 RSP:00007ffff555a120
R8 :0000000000000000 R9 :0000000000001000
R10:000055a688730b5d R11:0000000000000000
R12:00007efc64fff098 R13:000055a68888e8f8
R14:00007ffff555a1c0 R15:00007efc66495960
RIP:00007efc64c908e6 EFL:0000000000010246
CSGSFS:002b000000000033
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12f) -> 0000000000000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12e) -> 0000000000000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12d) -> 0000000000000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12c) -> 00007efc65dc0c00
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12b) -> 00007efc664684e0
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a12a) -> 000055a688102be0
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a129) -> 000055a6880f271d
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a128) -> 00007efc65d93900
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a127) -> 00007efc00000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a126) -> 0000000000000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a125) -> 010055a600000003
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a124) -> 0000000066480781
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a123) -> 000055a6880eeef5
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a122) -> 0000000000000000
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a121) -> 00007ffff555a150
1:1:M 10 Aug 2023 11:16:53.798 # (00007ffff555a120) -> 0000000000000003

------ INFO OUTPUT ------
# Server
redis_version:255.255.255
redis_git_sha1:441b74a9
redis_git_dirty:1
redis_build_id:e4a8c2954cbe3756
redis_mode:standalone
os:Linux 5.10.102.1-microsoft-standard-WSL2 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.4.0
process_id:1
process_supervised:no
run_id:5037c93d4dbb62b46a23b9139ccf4685e74e7718
tcp_port:6379
server_time_usec:1691666213042171
uptime_in_seconds:0
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:13944613
executable:/data/keydb-server
config_file:
availability_zone:

# Clients
connected_clients:0
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:0
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
current_client_thread:0
thread_0_clients:0

# Memory
used_memory:1662584
used_memory_human:1.59M
used_memory_rss:0
used_memory_rss_human:0B
used_memory_peak:1662584
used_memory_peak_human:1.59M
used_memory_peak_perc:101.74%
used_memory_overhead:0
used_memory_startup:0
used_memory_dataset:1662584
used_memory_dataset_perc:100.00%
allocator_allocated:0
allocator_active:0
allocator_resident:0
total_system_memory:4114530304
total_system_memory_human:3.83G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:-nan
allocator_frag_bytes:0
allocator_rss_ratio:-nan
allocator_rss_bytes:0
rss_overhead_ratio:-nan
rss_overhead_bytes:0
mem_fragmentation_ratio:-nan
mem_fragmentation_bytes:0
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.2.1
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0
storage_provider:none
available_system_memory:unavailable

# Persistence
loading:0
current_cow_size:0
current_cow_size_age:0
current_fork_perc:0.00
current_save_keys_processed:0
current_save_keys_total:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1691666213
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0

# Stats
total_connections_received:0
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:0
total_net_output_bytes:0
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
total_forks:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:0
dump_payload_sanitizations:0
total_reads_processed:0
total_writes_processed:0
instantaneous_lock_contention:1
avg_lock_contention:0.000000
storage_provider_read_hits:0
storage_provider_read_misses:0

# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:02d80df7bcf3ccb3426f03930fb7e993631fd29b
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.021010
used_cpu_user:0.021010
used_cpu_sys_children:0.000000
used_cpu_user_children:0.002751
server_threads:1
long_lock_waits:0
used_cpu_sys_main_thread:0.019326
used_cpu_user_main_thread:0.019326

# Modules
module:name=search,ver=20801,api=1,filters=0,usedby=[],using=[],options=[handle-io-errors]

# Commandstats
cmdstat_info:calls=1,usec=28,usec_per_call=28.00,rejected_calls=0,failed_calls=0

# Errorstats

# Cluster
cluster_enabled:0

# Keyspace

# KeyDB
mvcc_depth:0

------ CLIENT LIST OUTPUT ------

------ MODULES INFO OUTPUT ------
# search_version
search_version:2.8.1
search_redis_version:255.255.255 - oss

# search_index
search_number_of_indexes:0

# search_fields_statistics

# search_dialect_statistics
search_dialect_1:0
search_dialect_2:0
search_dialect_3:0

# search_runtime_configurations
search_concurrent_mode:OFF
search_enableGC:ON
search_minimal_term_prefix:2
search_maximal_prefix_expansions:200
search_query_timeout_ms:500
search_timeout_policy:return
search_cursor_read_size:1000
search_cursor_max_idle_time:300000
search_max_doc_table_size:1000000
search_max_search_results:1000000
search_max_aggregate_results:-1
search_search_pool_size:20
search_index_pool_size:8
search_gc_scan_size:100
search_min_phonetic_term_length:3

------ FAST MEMORY TEST ------
*** Preparing to test memory region 55a688876000 (2334720 bytes)
*** Preparing to test memory region 7efc642e9000 (8388608 bytes)
*** Preparing to test memory region 7efc64ff9000 (28672 bytes)
*** Preparing to test memory region 7efc65000000 (4194304 bytes)
*** Preparing to test memory region 7efc65580000 (8388608 bytes)
*** Preparing to test memory region 7efc65d80000 (11010048 bytes)
*** Preparing to test memory region 7efc668d8000 (69632 bytes)
*** Preparing to test memory region 7efc6691c000 (32768 bytes)
*** Preparing to test memory region 7efc66a9a000 (4096 bytes)
*** Preparing to test memory region 7efc66ad7000 (8192 bytes)
*** Preparing to test memory region 7efc66b35000 (4096 bytes)
*** Preparing to test memory region 7efc66c6e000 (4096 bytes)
*** Preparing to test memory region 7efc66c7b000 (8192 bytes)
*** Preparing to test memory region 7efc66e55000 (8192 bytes)
*** Preparing to test memory region 7efc66e71000 (8192 bytes)
*** Preparing to test memory region 7efc66eb9000 (4096 bytes)
*** Preparing to test memory region 7efc66f97000 (8192 bytes)
*** Preparing to test memory region 7efc67262000 (8192 bytes)
*** Preparing to test memory region 7efc673f4000 (8192 bytes)
*** Preparing to test memory region 7efc6745b000 (8192 bytes)
*** Preparing to test memory region 7efc6754b000 (8192 bytes)
*** Preparing to test memory region 7efc6763e000 (8192 bytes)
*** Preparing to test memory region 7efc6790b000 (16384 bytes)
*** Preparing to test memory region 7efc6792e000 (16384 bytes)
*** Preparing to test memory region 7efc6794d000 (8192 bytes)
*** Preparing to test memory region 7efc67c7d000 (12288 bytes)
*** Preparing to test memory region 7efc67f52000 (16384 bytes)
*** Preparing to test memory region 7efc6800b000 (8192 bytes)
*** Preparing to test memory region 7efc6803f000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.

------ DUMPING CODE AROUND EIP ------
Symbol: (null) (base: (nil))
Module: /etc/libs/redisearch.so (base 0x7efc64ae9000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=(nil) -D -b binary -m i386:x86-64 /tmp/dump.bin
------

Aditional information

  1. OS distribution and version
Ubuntu 20.04 docker image
KeyDB image created from main branch.
  1. Steps to reproduce (if any)
    Created KeyDB image using pkg/docker/Dockerfile
    docker build --build-arg BRANCH=main -t keydb_local .

Compiled RediSearch, copied binary to keydb image in above and started the container.

Dockerfile
FROM ubuntu:20.04 AS builder 

WORKDIR /keydb
RUN apt update
RUN apt install -y git make python3 build-essential make
RUN git clone -b v2.8.1 --recursive https://github.com/RediSearch/RediSearch.git
RUN cd RediSearch && make setup  && make build 

FROM keydb_local:latest AS prod 
COPY --from=builder /keydb/RediSearch/bin/linux-x64-release/search/redisearch.so /etc/libs/redisearch.so
CMD [ "--loadmodule", "/etc/libs/redisearch.so" ]

Running this image causes failure. However when CMD loadmodule is removed from the Dockerfile. And loading module from keydb-cli causes no crash.

Module is loaded and commands are available

127.0.0.1:6379> ft._list
(error) ERR unknown command `ft._list`, with args beginning with:
127.0.0.1:6379> module load /etc/libs/redisearch.so
OK
127.0.0.1:6379> ft._list
(empty array)
127.0.0.1:6379> ft._list
1) "idx:bonus"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions