//examples/kuka_iiwa_arm:kuka_simulation
violates ODR due to :iiwa_common
and :iiwa_lcm
#8908
Labels
//examples/kuka_iiwa_arm:kuka_simulation
violates ODR due to :iiwa_common
and :iiwa_lcm
#8908
At present,
iiwa_common
andiiwa_lcm
depend on static libraries within Drake (e.g.//multibody:rigid_body_tree
), butkuka_simulation
also links againstlibdrake.so
viadrake_example_cc_binary
.In drafting #8906, I realized this when digging into an issue captured by the following comments:
https://github.com/EricCousineau-TRI/drake/blob/59d9d37d8d6a5fb427b5872a8d85ed03698e756e/tools/skylark/drake_cc.bzl#L611-L617
With @sammy-tri's help, we found that when the example binary has
srcs = ["//tools/install/libdrake:libdrake.so", ...]
, Bazel or the linker somehow magically realize that there are some duplications in the object code, and culls duplicate code from the resultant binarykuka_simulation
.To see the symbols:
However, when moving
libdrake.so
to be indrake_shared_library
'ssrcs
, it seems that Bazel or the linker do not catch this case, and ends up duplicating globals such asstd::set<int> RigidBodyTreeConstants::default_model_instance_id_set
(which is a GSG violation, as it is not trivially destructible).This manifests itself when the binary is running its exit handlers, and it ends up double-freeing memory within
default_model_instance_id_set
.Potential solutions:
iiwa_common
andiiwa_lcm
do not double-declare their dependencies.default_model_instance_id_set
tonever_destroyed<>
as a stop-gap. This should be done regardless, but won't solve the issue since there will be other violations.Ultimately, this seems to be pointing towards the pains of trying to offer both static and dynamically linked libraries from Bazel without a concrete plan (that I know of?) for offering both types of targets at the same level of granularity and with compatibility. (Bazel has plans for doing this hopefully well, but it seems to be stalled at the moment.)
@fbudin69500 This was the issue that we had discussed earlier, which we weren't sure if it was due to
FindResource
logic or not. This tends to indicate that it is not.@jwnimmer-tri @jamiesnape Can I ask if y'all know what linker or Bazel magic is presently preventing this from being a problem on the current
master
?EDIT: Reproduction commit:
EricCousineau-TRI@cf55503
The text was updated successfully, but these errors were encountered: