jfrimmel/cargo-valgrind

Deserialization error when there are both errors while running and errors detected after program finishes

TheWastl opened this issue · 0 comments

Minimal example:

use std::alloc::{Layout, alloc};

fn main() {
        unsafe {
                let ptr = alloc(Layout::new::<u8>());
                if *ptr == 0 { println!("dummy"); }
        }
}

Version info:

  • cargo-valgrind: 2.0.3
  • valgrind: 3.18.1

The problem seems to be that other XML elements (<status>) appear between <error> elements.

XML format mismatch between valgrind and cargo valgrind: custom: duplicate field error
XML output of valgrind:

<?xml version="1.0"?>

<valgrindoutput>

<protocolversion>4</protocolversion>
<protocoltool>memcheck</protocoltool>

<preamble>
  <line>Memcheck, a memory error detector</line>
  <line>Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.</line>
  <line>Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info</line>
  <line>Command: target/debug/break-valgrind</line>
</preamble>

<pid>78245</pid>
<ppid>78243</ppid>
<tool>memcheck</tool>

<args>
  <vargv>
    <exe>/usr/bin/valgrind.bin</exe>
    <arg>--xml=yes</arg>
    <arg>--xml-socket=127.0.0.1:43083</arg>
  </vargv>
  <argv>
    <exe>target/debug/break-valgrind</exe>
  </argv>
</args>

<status>
  <state>RUNNING</state>
  <time>00:00:00:00.315 </time>
</status>

<error>
  <unique>0x0</unique>
  <tid>1</tid>
  <kind>UninitCondition</kind>
  <what>Conditional jump or move depends on uninitialised value(s)</what>
  <stack>
    <frame>
      <ip>0x110992</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>break_valgrind::main</fn>
      <dir>/home/wastl/break-valgrind/src</dir>
      <file>main.rs</file>
      <line>7</line>
    </frame>
    <frame>
      <ip>0x1107EA</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>core::ops::function::FnOnce::call_once</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops</dir>
      <file>function.rs</file>
      <line>227</line>
    </frame>
    <frame>
      <ip>0x1106BD</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::sys_common::backtrace::__rust_begin_short_backtrace</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/sys_common</dir>
      <file>backtrace.rs</file>
      <line>123</line>
    </frame>
    <frame>
      <ip>0x110750</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start::{{closure}}</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src</dir>
      <file>rt.rs</file>
      <line>145</line>
    </frame>
    <frame>
      <ip>0x125ABA</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start_internal</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops</dir>
      <file>function.rs</file>
      <line>259</line>
    </frame>
    <frame>
      <ip>0x11071F</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src</dir>
      <file>rt.rs</file>
      <line>144</line>
    </frame>
    <frame>
      <ip>0x1109EB</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>main</fn>
    </frame>
  </stack>
</error>


<status>
  <state>FINISHED</state>
  <time>00:00:00:01.350 </time>
</status>

<error>
  <unique>0x1</unique>
  <tid>1</tid>
  <kind>Leak_DefinitelyLost</kind>
  <xwhat>
    <text>1 bytes in 1 blocks are definitely lost in loss record 1 of 1</text>
    <leakedbytes>1</leakedbytes>
    <leakedblocks>1</leakedblocks>
  </xwhat>
  <stack>
    <frame>
      <ip>0x483F7B5</ip>
      <obj>/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
      <fn>malloc</fn>
      <dir>./coregrind/m_replacemalloc</dir>
      <file>vg_replace_malloc.c</file>
      <line>381</line>
    </frame>
    <frame>
      <ip>0x1107AB</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>alloc::alloc::alloc</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/alloc/src</dir>
      <file>alloc.rs</file>
      <line>87</line>
    </frame>
    <frame>
      <ip>0x110981</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>break_valgrind::main</fn>
      <dir>/home/wastl/break-valgrind/src</dir>
      <file>main.rs</file>
      <line>6</line>
    </frame>
    <frame>
      <ip>0x1107EA</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>core::ops::function::FnOnce::call_once</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops</dir>
      <file>function.rs</file>
      <line>227</line>
    </frame>
    <frame>
      <ip>0x1106BD</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::sys_common::backtrace::__rust_begin_short_backtrace</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/sys_common</dir>
      <file>backtrace.rs</file>
      <line>123</line>
    </frame>
    <frame>
      <ip>0x110750</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start::{{closure}}</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src</dir>
      <file>rt.rs</file>
      <line>145</line>
    </frame>
    <frame>
      <ip>0x125ABA</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start_internal</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops</dir>
      <file>function.rs</file>
      <line>259</line>
    </frame>
    <frame>
      <ip>0x11071F</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>std::rt::lang_start</fn>
      <dir>/rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src</dir>
      <file>rt.rs</file>
      <line>144</line>
    </frame>
    <frame>
      <ip>0x1109EB</ip>
      <obj>/home/wastl/break-valgrind/target/debug/break-valgrind</obj>
      <fn>main</fn>
    </frame>
  </stack>
</error>

<errorcounts>
  <pair>
    <count>1</count>
    <unique>0x0</unique>
  </pair>
</errorcounts>

<suppcounts>
</suppcounts>

</valgrindoutput>