Back to top

memory errors in libdatrie when building trie dictionary

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2404 of /usr/share/drupal7/includes/menu.inc).

I noticed strange crashes while trying to build libthai on Windows. These crashes were a result of attempting to build the trie dictionary. Switching back to Linux, I ran trietool through valgrind:

$ valgrind ../../libdatrie/bin/trietool thbrk add-list tdict.txt

Invalid read of size 1
   at 0x33F7E6FFB0: strcpy (in /lib64/tls/libc-2.3.4.so)
   by 0x4A0BCF0: tail_set_suffix (tail.c:189)
   by 0x4A0C68B: trie_branch_in_tail (trie.c:229)
   by 0x4A0C4BD: trie_store (trie.c:172)
   by 0x4A0D286: sb_trie_store (sb-trie.c:153)
   by 0x401248: command_add_list (trietool.c:182)
   by 0x400E27: decode_command (trietool.c:107)
   by 0x400B4C: main (trietool.c:58)
 Address 0x4B1F209 is 0 bytes after a block of size 1 alloc'd
   at 0x490641D: realloc (vg_replace_malloc.c:306)
   by 0x4A0BCC9: tail_set_suffix (tail.c:188)
   by 0x4A0C68B: trie_branch_in_tail (trie.c:229)
   by 0x4A0C4BD: trie_store (trie.c:172)
   by 0x4A0D286: sb_trie_store (sb-trie.c:153)
   by 0x401248: command_add_list (trietool.c:182)
   by 0x400E27: decode_command (trietool.c:107)
   by 0x400B4C: main (trietool.c:58)

Source and destination overlap in strcpy(0x4B1F948, 0x4B1F948)
   at 0x4906DC3: strcpy (mc_replace_strmem.c:106)
   by 0x4A0BCF0: tail_set_suffix (tail.c:189)
   by 0x4A0C68B: trie_branch_in_tail (trie.c:229)
   by 0x4A0C4BD: trie_store (trie.c:172)
   by 0x4A0D286: sb_trie_store (sb-trie.c:153)
   by 0x401248: command_add_list (trietool.c:182)
   by 0x400E27: decode_command (trietool.c:107)
   by 0x400B4C: main (trietool.c:58)

Invalid read of size 1
   at 0x4906D28: strcpy (mc_replace_strmem.c:272)
   by 0x4A0BCF0: tail_set_suffix (tail.c:189)
   by 0x4A0C68B: trie_branch_in_tail (trie.c:229)
   by 0x4A0C4BD: trie_store (trie.c:172)
   by 0x4A0D286: sb_trie_store (sb-trie.c:153)
   by 0x401248: command_add_list (trietool.c:182)
   by 0x400E27: decode_command (trietool.c:107)
   by 0x400B4C: main (trietool.c:58)
 Address 0x4B1FB72 is 0 bytes after a block of size 2 alloc'd
   at 0x490641D: realloc (vg_replace_malloc.c:306)
   by 0x4A0BCC9: tail_set_suffix (tail.c:188)
   by 0x4A0C68B: trie_branch_in_tail (trie.c:229)
   by 0x4A0C4BD: trie_store (trie.c:172)
   by 0x4A0D286: sb_trie_store (sb-trie.c:153)
   by 0x401248: command_add_list (trietool.c:182)
   by 0x400E27: decode_command (trietool.c:107)
   by 0x400B4C: main (trietool.c:58)

ERROR SUMMARY: 10254 errors from 3 contexts (suppressed: 9 from 4)

I am working on a fix, but I do not understand the code well enough to do so yet. Any help would be appreciated.

Taxonomy upgrade extras: