gpt4 book ai didi

c++ - "Conditional jump or move depends on uninitialised value",但堆栈跟踪中未列出分配函数。如何?

转载 作者:行者123 更新时间:2023-11-30 03:46:51 26 4
gpt4 key购买 nike

这是一些 Valgrind 日志的一部分:

==1652== Conditional jump or move depends on uninitialised value(s)==1652==    at 0x868DBFC: Dfm_db::io::Layer_cell_writer::end_cell() (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_db_io_layer.C:224)==1652==    by 0x862C9FD: Dfm_db::Hdb_layer_writer::end_cell() (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/../Isrc/dfm/dfm_db_io_layer.h:916)==1652==    by 0x861197F: Dfm_db::Hdb_writer::save_layer_geometries(Dfm_db::Hdb_layer_writer&, Drc_Hierarchical_database&, unsigned long, Drc_Hierarchical_geometry_type, bool, bool, bool, bool, Dfm_produced_layer_type) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_db_hdb_io.C:2362)==1652==    by 0x8610755: Dfm_db::Hdb_writer::save_layer(Dfm_db::Database*, Drc_Hierarchical_database&, unsigned long, unsigned long, Dfm_db::Geometry_types, char const*, Dfm_db::Run_info&, Dfm_db::Layer_origin const&, char const*, bool, char const*, char const*, bool, Pdb_security*, bool, int, bool, bool, Dfm_db::must_be, Dfm_produced_layer_type) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_db_hdb_io.C:2102)==1652==    by 0x8595B1E: Dfm_db::Database::save_layer(char const*, unsigned long, bool) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_database.C:2490)==1652==    by 0x8594D39: Dfm_db::Database::save_layers(std::map, std::less, std::allocator > > >&) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_database.C:2317)==1652==    by 0x85937B8: Dfm_db::Database::save_revision(bool) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_database.C:2082)==1652==    by 0x4C6AE76: Cockpit_cli::save_revision(Dfm_db::must_be) (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/cockpit_db_rev_cli.C:520)==1652==    by 0x4C15153: cockpit_save_revision (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/cockpit_db_hier_rev_cmds.C:529)==1652==    by 0xD8BAC67: TclEvalObjvInternal (in /amy/ic_wg_server/CACHED_WG_SERVER/ic/comp/exports.v0-0_6-19-2015_engr-aoi/mgc_home/pkgs/icv_lib.aoi/lib64/libcalibre_utils.so)==1652==    by 0xD8E3255: TclExecuteByteCode (in /amy/ic_wg_server/CACHED_WG_SERVER/ic/comp/exports.v0-0_6-19-2015_engr-aoi/mgc_home/pkgs/icv_lib.aoi/lib64/libcalibre_utils.so)==1652==    by 0xD8E7280: TclCompEvalObj (in /amy/ic_wg_server/CACHED_WG_SERVER/ic/comp/exports.v0-0_6-19-2015_engr-aoi/mgc_home/pkgs/icv_lib.aoi/lib64/libcalibre_utils.so)==1652==  Uninitialised value was created by a stack allocation==1652==    at 0x859F6DC: Dfm_db::Database::get_pl_index_level() const (/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_database.C:4325)

最后一行是 --track-origins 选项的结果,它准确显示了在哪个函数中创建了未初始化的值。这个输出对我来说唯一神奇的部分是最后一个函数没有出现在调用堆栈中。还为 20 提供了 --num-callers 选项。

我的问题是最后一个函数怎么可能没有出现在调用堆栈中?

最佳答案

很容易。一个例子:

#include <functional>
#include <iostream>

std::function<void()> callback;

void foo()
{
int x;
callback = [&]() { if (x > 5) std::cout << "hi"; };
}

int main()
{
foo();
callback();
}

这里,foo不会出现在调用callback的调用栈中。

你的想法太线性了。

关于c++ - "Conditional jump or move depends on uninitialised value",但堆栈跟踪中未列出分配函数。如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33955857/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com