这是一些Valgrind日志的一部分:
== 1652 ==条件跳转或移动取决于未初始化的值
== 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 ==通过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 ==由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 / layer / layer / type / ard_ard / dflv_produced() aoi-asserts-valg / dfm / Isrc / dfm_db_hdb_io.C:2362)
== 1652 ==通过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&,const,&Lafyer_db: 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 ==通过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 ==通过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 ==通过0x85937B8:Dfm_db::Database::save_revision(bool)(/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/dfm_database.C:2082)
== 1652 ==通过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 ==通过0x4C15153:cockpit_save_revision(/home/lvardany/tmp_IWA/ic/lv/aoi-asserts-valg/dfm/Isrc/cockpit_db_hier_rev_cmds.C:529)
== 1652 ==通过0xD8BAC67:TclEvalObjvInternal(在/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 ==通过0xD8E3255:TclExecuteByteCode(在/amy/ic_wg_server/CACHED_WG_SERVER/ic/comp/exports.v0-0_6_6-19-2015_engr-aoi/mgc_home/pkgs/icv_lib.aoi/lib64/libcalibre_utils.so)
== 1652 == by 0xD8E7280:TclCompEvalObj(在/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 ==未初始化的值是由堆栈分配创建的
== 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-orgins 选项的结果,该选项精确显示了在哪个函数中创建了未初始化的值。对我而言,此输出的唯一神奇之处在于,最后一个函数没有出现在调用堆栈中。还为 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
的调用堆栈中。您的想法太线性了。