Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in regress test_libchewing_googlecode_issue_473 #80

Closed
czchen opened this issue Sep 19, 2013 · 2 comments
Closed

Memory leak in regress test_libchewing_googlecode_issue_473 #80

czchen opened this issue Sep 19, 2013 · 2 comments
Labels
Milestone

Comments

@czchen
Copy link
Member

czchen commented Sep 19, 2013

See this. It happens after fixing #79.

@czchen
Copy link
Member Author

czchen commented Sep 19, 2013

The following is valgrind log

czchen@kelemvor:~/src/chewing/build-libchewing/test% valgrind --leak-check=full ./test-regression
==27913== Memcheck, a memory error detector
==27913== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==27913== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==27913== Command: ./test-regression
==27913== 
ok 1 check function returned `1' shall be `1'
ok 2 get length function returned `2' shall be `2'
ok 3 string function returned `趕走' shall be `趕走'
ok 4 cursor position `2' shall be `2'
ok 5 chewing_cand_TotalChoice() returns `3' shall greater than 0
==27913== 
==27913== HEAP SUMMARY:
==27913==     in use at exit: 8 bytes in 2 blocks
==27913==   total heap usage: 2,192 allocs, 2,190 frees, 1,104,450 bytes allocated
==27913== 
==27913== 4 bytes in 1 blocks are definitely lost in loss record 1 of 2
==27913==    at 0x4C2C494: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==27913==    by 0x40CAAE: AlcUserPhraseSeq (hash.c:30)
==27913==    by 0x413095: UserUpdatePhrase (userphrase.c:146)
==27913==    by 0x40865D: ReleaseChiSymbolBuf (chewingutil.c:557)
==27913==    by 0x407040: chewing_handle_Numlock (chewingio.c:1381)
==27913==    by 0x403545: type_single_keystroke (testhelper.c:217)
==27913==    by 0x403585: type_keystroke (testhelper.c:229)
==27913==    by 0x4037B6: type_keystroke_by_string (testhelper.c:276)
==27913==    by 0x402DB1: test_libchewing_googlecode_issue_473 (test-regression.c:68)
==27913==    by 0x402FF3: main (test-regression.c:136)
==27913== 
==27913== 4 bytes in 1 blocks are definitely lost in loss record 2 of 2
==27913==    at 0x4C2C494: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==27913==    by 0x40CADB: AlcUserPhraseSeq (hash.c:33)
==27913==    by 0x413095: UserUpdatePhrase (userphrase.c:146)
==27913==    by 0x40865D: ReleaseChiSymbolBuf (chewingutil.c:557)
==27913==    by 0x407040: chewing_handle_Numlock (chewingio.c:1381)
==27913==    by 0x403545: type_single_keystroke (testhelper.c:217)
==27913==    by 0x403585: type_keystroke (testhelper.c:229)
==27913==    by 0x4037B6: type_keystroke_by_string (testhelper.c:276)
==27913==    by 0x402DB1: test_libchewing_googlecode_issue_473 (test-regression.c:68)
==27913==    by 0x402FF3: main (test-regression.c:136)
==27913== 
==27913== LEAK SUMMARY:
==27913==    definitely lost: 8 bytes in 2 blocks
==27913==    indirectly lost: 0 bytes in 0 blocks
==27913==      possibly lost: 0 bytes in 0 blocks
==27913==    still reachable: 0 bytes in 0 blocks
==27913==         suppressed: 0 bytes in 0 blocks
==27913== 
==27913== For counts of detected and suppressed errors, rerun with: -v
==27913== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

@czchen
Copy link
Member Author

czchen commented Sep 19, 2013

The problem in phoneSeq and wordSeq mismatch in UserUpdatePhrase.

(gdb) f 0
#0  UserUpdatePhrase (pgdata=0x7ffff7f9c010, phoneSeq=0x7fffffffcef0, 
    wordSeq=0x7fffffffcf60 "呰")
    at /home/czchen/src/chewing/libchewing/src/userphrase.c:138
138 {
(gdb) p *phoneSeq@10
$8 = {9731, 9731, 0, 0, 0, 0, 0, 0, 0, 0}
(gdb) bt
#0  UserUpdatePhrase (pgdata=0x7ffff7f9c010, phoneSeq=0x7fffffffcef0, 
    wordSeq=0x7fffffffcf60 "呰")
    at /home/czchen/src/chewing/libchewing/src/userphrase.c:138
#1  0x000000000040862a in ReleaseChiSymbolBuf (pgdata=0x7ffff7f9c010, 
    pgo=0x622410) at /home/czchen/src/chewing/libchewing/src/chewingutil.c:557
#2  0x000000000040700d in chewing_handle_Numlock (ctx=0x6223e0, key=42)
    at /home/czchen/src/chewing/libchewing/src/chewingio.c:1381
#3  0x0000000000403512 in type_single_keystroke (ctx=0x6223e0, ch=1142)
    at /home/czchen/src/chewing/libchewing/test/testhelper.c:217
#4  0x0000000000403552 in type_keystroke (ctx=0x6223e0, 
    get_char=0x403573 <get_char_by_string>, param=0x7fffffffd100)
    at /home/czchen/src/chewing/libchewing/test/testhelper.c:229
#5  0x0000000000403783 in type_keystroke_by_string (ctx=0x6223e0, 
    keystroke=0x41593f "<B>l<C3><N6>W<N*> $<SR><N.><N1><E><E><N0><N6>Y")
    at /home/czchen/src/chewing/libchewing/test/testhelper.c:276
#6  0x0000000000402da6 in test_libchewing_googlecode_issue_473 ()
    at /home/czchen/src/chewing/libchewing/test/test-regression.c:68
#7  0x0000000000402fc0 in main ()
    at /home/czchen/src/chewing/libchewing/test/test-regression.c:136

@czchen czchen closed this as completed in 79ba8da Sep 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant