c-Hash Map实现在相同的valgrind错误上停留了4天(通过不协调的屏幕共享进行帮助吗?)[重复]

问题描述 投票:-1回答:1

我几天来一直在遇到相同的错误,这是我要上学的作业,因此,非常感谢您的帮助。将我的代码发布到这里并没有什么好处,但是一些发布者说他们希望我所有的文件都可以自己调试程序。如果您愿意查看我的代码/自己运行文件,请在不一致的地方添加我:Sheeplie#7492

非常感谢您的帮助!

我不会在这里发布代码,因为最后两次都无法解决。

感谢您阅读

valgrind --leak-check=full ./Unit 6
==28769== Memcheck, a memory error detector
==28769== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==28769== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==28769== Command: ./Unit 6
==28769==
keys[9999]: word9999
keys[10000]: word10000
n: 1000000
Helloz!
Helloz!
Helloz!
Helloz!
==28769== Invalid read of size 8
==28769==    at 0x402638: smap_contains_key (smap.c:231)
==28769==    by 0x40253D: smap_put (smap.c:178)
==28769==    by 0x401908: test_large_map (smap_unit.c:287)
==28769==    by 0x401288: main (smap_unit.c:66)
==28769==  Address 0xf6bb4a8 is 8 bytes before a block of size 24 free'd
==28769==    at 0x4839A0C: free (vg_replace_malloc.c:540)
==28769==    by 0x4029B7: smap_destroy (smap.c:389)
==28769==    by 0x402B0C: grow (smap.c:456)
==28769==    by 0x4025BA: smap_put (smap.c:199)
==28769==    by 0x401908: test_large_map (smap_unit.c:287)
==28769==    by 0x401288: main (smap_unit.c:66)
==28769==  Block was alloc'd at
==28769==    at 0x483880B: malloc (vg_replace_malloc.c:309)
==28769==    by 0x4024AC: smap_put (smap.c:148)
==28769==    by 0x401908: test_large_map (smap_unit.c:287)
==28769==    by 0x401288: main (smap_unit.c:66)
c dictionary hash
1个回答
-1
投票

无效读取大小8表示您正在尝试从非8字节的内容读取8字节的值。它似乎在第231行上。错误消息中的“ at”是错误起源。我的假设是您的第一个错误导致了接下来的两个错误消息。

© www.soinside.com 2019 - 2024. All rights reserved.