Hi, As per title, using RM_DictSetC() segfaults but only when loading from rdb file on startup. The module implements a native datatype. The module works is able to create dict entries by calling this function. The segfault occurs only on a server restart once it tries to call the rdbLoad function. Let me know if there's any other information I can provide.

System information

 Linux 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5+deb10u1 (2019-07-19) x86_64 GNU/Linux

debugger stack trace

This is with redis compiled from source with "make noopt" command. Here's a full stack trace obtained by running the gnu debugger:

Thread 1 "redis-server" received signal SIGSEGV, Segmentation fault.
raxLowWalk (rax=0x7ffff7809838, s=0x7ffff7942028 "\226", len=8, stopnode=0x7fffffffd330, plink=0x7fffffffd328, 
    splitpos=0x7fffffffd33c, ts=0x0) at rax.c:486
warning: Source file is more recent than executable.
486             memcpy(&h,children+j,sizeof(h));
(gdb) bt
#0  raxLowWalk (rax=0x7ffff7809838, s=0x7ffff7942028 "\226", len=8, stopnode=0x7fffffffd330, plink=0x7fffffffd328, 
    splitpos=0x7fffffffd33c, ts=0x0) at rax.c:486
#1  0x0000555555626dd0 in raxGenericInsert (rax=0x7ffff7809838, s=0x7ffff7942028 "\226", len=8, data=0x7ffff7942000, 
    old=0x0, overwrite=0) at rax.c:516
#2  0x00005555556280c0 in raxTryInsert (rax=0x7ffff7809838, s=0x7ffff7942028 "\226", len=8, data=0x7ffff7942000, 
    old=0x0) at rax.c:910
#3  0x000055555561c5ea in RM_DictSetC (d=0x7ffff7809838, key=0x7ffff7942028, keylen=8, ptr=0x7ffff7942000)
    at module.c:4469
#4  0x00007ffff7c25e73 in rbtree_insert (tree=0x7ffff7809830, node=0x0, s=..., val=..., level=0)
    at /home/david/projects/reventis/rbtree_redis.cpp:281
#5  0x00007ffff7c2613d in RBTreeInsert (tree=0x7ffff7809830, s=..., val=...)
    at /home/david/projects/reventis/rbtree_redis.cpp:304
#6  0x00007ffff7c26cc4 in RBTreeTypeRdbLoad (rdb=0x7fffffffd680, encver=0)
    at /home/david/projects/reventis/rbtree_redis.cpp:477
#7  0x00005555555b9fad in rdbLoadObject (rdbtype=7, rdb=0x7fffffffdd70, key=0x7ffff78ba700) at rdb.c:1774
#8  0x00005555555ba8ff in rdbLoadRio (rdb=0x7fffffffdd70, rsi=0x7fffffffde00, loading_aof=0) at rdb.c:2009
#9  0x00005555555bab60 in rdbLoad (filename=0x7ffff780a000 "dump.rdb", rsi=0x7fffffffde00) at rdb.c:2077
#10 0x0000555555596bfd in loadDataFromDisk () at server.c:3862
#11 0x0000555555597808 in main (argc=2, argv=0x7fffffffdfa8) at server.c:4176

Full redis-server output log:

5239:C 21 Jan 2020 11:43:46.448 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5239:C 21 Jan 2020 11:43:46.448 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=5239, just started
5239:C 21 Jan 2020 11:43:46.448 # Configuration loaded
5239:M 21 Jan 2020 11:43:46.449 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 5239
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

5239:M 21 Jan 2020 11:43:46.450 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/
somaxconn is set to the lower value of 128.                                                                            
5239:M 21 Jan 2020 11:43:46.450 # Server initialized
5239:M 21 Jan 2020 11:43:46.450 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condi
tion. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm
.overcommit_memory=1' for this to take effect.                                                                         
5239:M 21 Jan 2020 11:43:46.450 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This wil
l create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/tran
sparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis
 must be restarted after THP is disabled.                                                                              
5239:M 21 Jan 2020 11:43:46.452 * Module 'reventis' loaded from /var/local/lib/reventis.so
5239:M 21 Jan 2020 11:43:46.452 . Unrecognized RDB AUX field: 'redis-ver'
5239:M 21 Jan 2020 11:43:46.452 . Unrecognized RDB AUX field: 'redis-bits'
5239:M 21 Jan 2020 11:43:46.452 . Unrecognized RDB AUX field: 'ctime'
5239:M 21 Jan 2020 11:43:46.452 . Unrecognized RDB AUX field: 'used-mem'
5239:M 21 Jan 2020 11:43:46.452 . Unrecognized RDB AUX field: 'aof-preamble'
5239:M 21 Jan 2020 11:43:46.452 . <reventis> no. items 19
5239:M 21 Jan 2020 11:43:46.452 . <reventis> rdbload: (0) seqn = 535298371 2857285978 2857285978, -48.231351/17.115051, 
150, 1620461640 to 1620478980, "Event ID # 4295328"                                                                    
add node to dictionary (level=0) key 0x7f2ebeb42028 150
new node 0x7f2ebeb42000 count = 1dict 0x7f2ebea09838 key 0x7f2ebeb42028 sizeofkey 8 value 0x7f2ebeb42000

=== REDIS BUG REPORT START: Cut & paste starting from here ===
5239:M 21 Jan 2020 11:43:46.452 # Redis 5.0.5 crashed by signal: 11
5239:M 21 Jan 2020 11:43:46.452 # Crashed running the instruction at: 0x55bccb113cc4
5239:M 21 Jan 2020 11:43:46.452 # Accessing address: 0x7f2ed679da30
5239:M 21 Jan 2020 11:43:46.452 # Failed assertion: <no assertion failed> (<no file>:0)

------ STACK TRACE ------
EIP:
./redis-server 127.0.0.1:6379(+0xd2cc4)[0x55bccb113cc4]

Backtrace:
./redis-server 127.0.0.1:6379(logStackTrace+0x43)[0x55bccb0cf735]
./redis-server 127.0.0.1:6379(sigsegvHandler+0x10e)[0x55bccb0cfebc]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f2ebf102730]
./redis-server 127.0.0.1:6379(+0xd2cc4)[0x55bccb113cc4]
./redis-server 127.0.0.1:6379(raxGenericInsert+0x7d)[0x55bccb113dd0]
./redis-server 127.0.0.1:6379(raxTryInsert+0x41)[0x55bccb1150c0]
./redis-server 127.0.0.1:6379(RM_DictSetC+0x39)[0x55bccb1095ea]
/var/local/lib/reventis.so(_Z13rbtree_insertP8rbtree_tP8rbnode_t7point_t7value_ti+0x195)[0x7f2ebef16e73]
/var/local/lib/reventis.so(_Z12RBTreeInsertP8rbtree_t7point_t7value_t+0x67)[0x7f2ebef1713d]
/var/local/lib/reventis.so(RBTreeTypeRdbLoad+0x2c4)[0x7f2ebef17cc4]
./redis-server 127.0.0.1:6379(rdbLoadObject+0x1342)[0x55bccb0a6fad]
./redis-server 127.0.0.1:6379(rdbLoadRio+0x6af)[0x55bccb0a78ff]
./redis-server 127.0.0.1:6379(rdbLoad+0x7b)[0x55bccb0a7b60]
./redis-server 127.0.0.1:6379(loadDataFromDisk+0xdc)[0x55bccb083bfd]
./redis-server 127.0.0.1:6379(main+0x704)[0x55bccb084808]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f2ebef5309b]
./redis-server 127.0.0.1:6379(_start+0x2a)[0x55bccb07310a]

------ INFO OUTPUT ------
# Server
redis_version:5.0.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:5ff64da67bf646f9
redis_mode:standalone
os:Linux 4.19.0-5-amd64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:8.3.0
process_id:5239
run_id:4faf46bfd72eac2b0e5979b74d81135534522aff
tcp_port:6379
uptime_in_seconds:0
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:2566722
executable:/data/Downloads/redis-5.0.5/src/./redis-server
config_file:/data/Downloads/redis-5.0.5/redis.conf

# Clients
connected_clients:0
client_recent_max_input_buffer:0
client_recent_max_output_buffer:0
blocked_clients:0

# Memory
used_memory:793408
used_memory_human:774.81K
used_memory_rss:0
used_memory_rss_human:0B
used_memory_peak:793408
used_memory_peak_human:774.81K
used_memory_peak_perc:inf%
used_memory_overhead:791640
used_memory_startup:791536
used_memory_dataset:1768
used_memory_dataset_perc:94.44%
allocator_allocated:0
allocator_active:0
allocator_resident:0
total_system_memory:14700425216
total_system_memory_human:13.69G
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.1.0
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:1
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1579625026
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
loading_start_time:1579625026
loading_total_bytes:1525
loading_loaded_bytes:0
loading_loaded_perc:0.00
loading_eta_seconds:1

# Stats
total_connections_received:0
total_commands_processed:0
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
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec: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

# Replication
role:master
connected_slaves:0
master_replid:f74ea37ba05ed0d5662abb2c8c01637ea91ab464
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.010611
used_cpu_user:0.000000
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000

# Commandstats

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=1,expires=0,avg_ttl=0

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

------ REGISTERS ------
5239:M 21 Jan 2020 11:43:46.454 # 
RAX:00007f2ed679da30 RBX:000055bccb107d76
RCX:0000000017d41307 RDX:0000000000052ee8
RDI:00007f2ebea09838 RSI:00007f2ebeb42028
RBP:00007fffdf93d4d0 RSP:00007fffdf93d470
R8 :00007fffdf93d568 R9 :00007fffdf93d57c
R10:0000000000000000 R11:00007f2ebeb42000
R12:0000000000001477 R13:00007fffdf93e1e0
R14:0000000000000000 R15:0000000000000000
RIP:000055bccb113cc4 EFL:0000000000010216
CSGSFS:002b000000000033
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47f) -> 0064333025002e53
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47e) -> 0000000000000000
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47d) -> 000055bccb113dd0
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47c) -> 00007fffdf93d620
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47b) -> 00007f2ebea09838
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d47a) -> 0000000000000001
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d479) -> 000000000000a5dd
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d478) -> 00007f2ebea0983c
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d477) -> 00007f2ed674ab48
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d476) -> 00007f2ebea09838
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d475) -> 00007f2ebea09838
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d474) -> 00007f2ebeb42028
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d473) -> 0000000000000008
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d472) -> 00007fffdf93d570
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d471) -> 00007fffdf93d568
5239:M 21 Jan 2020 11:43:46.454 # (00007fffdf93d470) -> 00007fffdf93d57c

------ FAST MEMORY TEST ------
5239:M 21 Jan 2020 11:43:46.454 # Bio thread for job type #0 terminated
5239:M 21 Jan 2020 11:43:46.454 # Bio thread for job type #1 terminated
5239:M 21 Jan 2020 11:43:46.454 # Bio thread for job type #2 terminated
*** Preparing to test memory region 55bccb208000 (2248704 bytes)
*** Preparing to test memory region 55bcccc9d000 (286720 bytes)
*** Preparing to test memory region 7f2ebc664000 (16384 bytes)
*** Preparing to test memory region 7f2ebc669000 (10027008 bytes)
*** Preparing to test memory region 7f2ebcffa000 (10027008 bytes)
*** Preparing to test memory region 7f2ebd98b000 (10027008 bytes)
*** Preparing to test memory region 7f2ebe600000 (8388608 bytes)
*** Preparing to test memory region 7f2ebef29000 (24576 bytes)
*** Preparing to test memory region 7f2ebf0ec000 (16384 bytes)
*** Preparing to test memory region 7f2ebf10d000 (16384 bytes)
*** Preparing to test memory region 7f2ebf2a3000 (8192 bytes)
*** Preparing to test memory region 7f2ebf2ea000 (4096 bytes)
.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: ./redis-server 127.0.0.1:6379 (base 0x55bccb041000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=(nil) -D -b binary -m i386:x86-64 /tmp/dump.bin
------

=== REDIS BUG REPORT END. Make sure to include from START to END. ===

       Please report the crash by opening an issue on github:

           http://github.com/antirez/redis/issues

  Suspect RAM error? Use redis-server --test-memory to verify it.

Segmentation fault