Bug 332577 - exp-sgcheck: sg_main.c:560 (add_blocks_to_StackTree): Assertion '!already_present' failed.
Summary: exp-sgcheck: sg_main.c:560 (add_blocks_to_StackTree): Assertion '!already_pre...
Status: RESOLVED DUPLICATE of bug 255603
Alias: None
Product: valgrind
Classification: Developer tools
Component: sgcheck (show other bugs)
Version: 3.9.0
Platform: Debian stable Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL: http://bugs.debian.org/cgi-bin/bugrep...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-25 11:38 UTC by Mathieu Malaterre
Modified: 2017-09-10 10:51 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Malaterre 2014-03-25 11:38:30 UTC
I have extracted a section of code from openjpeg which seems to be
driving valgrind/exp-sgcheck nuts. See attached demo.c file.

Steps (dwarf-4 and stack-protector are important):

$ gcc  -gdwarf-4      -fstack-protector   demo.c
$ valgrind --tool=exp-sgcheck  ./a.out
==17451== exp-sgcheck, a stack and global array overrun detector
==17451== NOTE: This is an Experimental-Class Valgrind Tool
==17451== Copyright (C) 2003-2013, and GNU GPL'd, by OpenWorks Ltd et al.
==17451== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==17451== Command: ./a.out
==17451==

exp-sgcheck: sg_main.c:560 (add_blocks_to_StackTree): Assertion
'!already_present' failed.
==17451==    at 0x380278CC: report_and_quit (m_libcassert.c:260)
==17451==    by 0x38027A26: vgPlain_assert_fail (m_libcassert.c:340)
==17451==    by 0x3801EE00: add_blocks_to_StackTree (sg_main.c:560)
==17451==    by 0x38020321: shadowStack_new_frame.isra.12 (sg_main.c:1875)
==17451==    by 0x806427FDC: ???
==17451==    by 0x8034DBECF: ???

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable
==17451==    at 0x4005B7: main (demo.c:39)


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.


Where:

$ gcc --version
gcc (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ uname -a
Linux larcenet 3.12-0.bpo.1-amd64 #1 SMP Debian 3.12.6-2~bpo70+1
(2014-01-07) x86_64 GNU/Linux

Reproducible: Always

Steps to Reproduce:
Where:

$ cat demo.c
#include <stdint.h>
#include <string.h>

typedef uint32_t OPJ_UINT32;
typedef int OPJ_COLOR_SPACE;
typedef void opj_image_comp_t;
typedef uint8_t OPJ_BYTE;

typedef struct opj_image_comptparm {
	OPJ_UINT32 dx;
	OPJ_UINT32 dy;
	OPJ_UINT32 w;
	OPJ_UINT32 h;
	OPJ_UINT32 x0;
	OPJ_UINT32 y0;
	OPJ_UINT32 prec;
	OPJ_UINT32 bpp;
	OPJ_UINT32 sgnd;
} opj_image_cmptparm_t;

typedef struct opj_image {
	OPJ_UINT32 x0;
	OPJ_UINT32 y0;
	OPJ_UINT32 x1;
	OPJ_UINT32 y1;
	OPJ_UINT32 numcomps;
	OPJ_COLOR_SPACE color_space;
	opj_image_comp_t *comps;
	OPJ_BYTE *icc_profile_buf;
	OPJ_UINT32 icc_profile_len;
} opj_image_t;

int main(int argc, char *argv[])
{
  opj_image_t *image;
  opj_image_cmptparm_t cmptparm[4];
  unsigned char sigbuf[8];

  memset(cmptparm, 0, sizeof(cmptparm));

  return 0;
}
Comment 1 Greg Hazel 2014-12-27 23:47:33 UTC
Same problem here.
Comment 2 Nick Shaforostoff 2015-01-15 23:44:58 UTC
is this a duplicate of #255603 ?
Comment 3 Ilya Bizyaev 2015-08-04 08:20:59 UTC
Same problem.
Ubuntu 15.04, GCC 4.9.2.
Comment 4 Ivo Raisr 2017-07-10 21:36:56 UTC
This problem manifests even on simple programs such as /bin/true on my Ubuntu 17.04, amd64/Linux. This means that sgcheck is unusable for me.


$ ./vg-in-place --version -v
valgrind-3.14.0.SVN-16458-vex-3398

$ gcc --version
gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406

$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.24-9ubuntu2.2) stable release version 2.24, by Roland McGrath et al.
Comment 5 Ivo Raisr 2017-09-10 10:51:29 UTC

*** This bug has been marked as a duplicate of bug 255603 ***