uwplse / herbgrind

A Valgrind tool for Herbie
GNU General Public License v3.0
90 stars 7 forks source link

herbgrind crashes while running #27

Closed sangeeta0201 closed 6 years ago

sangeeta0201 commented 6 years ago

Hi,

Most of the time herbgrind crashes with this error

Herbgrind: instrument/floattypes.c:1264 (typeMeet): Assertion 'type2 == Vt_Unknown || type2 == Vt_NonFloat || type2 == Vt_SingleOrNonFloat' failed.
Herbgrind: Cannot meet types Vt_NonFloat and Vt_Double!

host stacktrace:
==29117==    at 0x380715B8: show_sched_status_wrk (m_libcassert.c:343)
==29117==    by 0x380716D4: report_and_quit (m_libcassert.c:415)
==29117==    by 0x38071861: vgPlain_assert_fail (m_libcassert.c:481)
==29117==    by 0x3806C2A3: typeMeet (floattypes.c:1262)
==29117==    by 0x3806C519: refineTempBlockType (floattypes.c:111)
==29117==    by 0x3806D325: inferTypes (floattypes.c:126)
==29117==    by 0x38063AFC: hg_instrument (instrument.c:63)
==29117==    by 0x3808C8CF: tool_instrument_then_gdbserver_if_needed (m_translate.c:238)
==29117==    by 0x38137C4C: LibVEX_Translate (main_main.c:934)
==29117==    by 0x3808F1A5: vgPlain_translate (m_translate.c:1765)
==29117==    by 0x380BFF5B: handle_chain_me (scheduler.c:1076)
==29117==    by 0x380C1ACF: vgPlain_scheduler (scheduler.c:1420)
==29117==    by 0x380D0EC6: run_a_thread_NORETURN (syswrap-linux.c:102)

I got this error while running spec2006 fp benchmark sphinx. This is the configuration I have used to build this benchmark

C: CC="/usr/bin/gcc -g"
C: COBJOPT="-c -o options"
P: CPUFLAGS="-DSPEC_CPU -DNDEBUG"
P: BENCH_FLAGS="-I. -DSPEC_CPU -DHAVE_CONFIG_H -I. -Ilibutil "
P: BENCH_CFLAGS=""
O: OPTIMIZE=""
O: COPTIMIZE="-O2 -fno-strict-aliasing -ffast-math"
P: PORTABILITY="-DSPEC_CPU_LP64"
P: CPORTABILITY=""
O: EXTRA_CFLAGS=""
O: EXTRA_OPTIMIZE=""
O: EXTRA_COPTIMIZE=""
P: EXTRA_PORTABILITY=""
P: EXTRA_CPORTABILITY=""
LINK: /usr/bin/gcc -g   -O2 -fno-strict-aliasing -ffast-math  -DSPEC_CPU_LP64        <objects>   -lm        -o options
C: LD="/usr/bin/gcc -g"
O: COPTIMIZE="-O2 -fno-strict-aliasing -ffast-math"
P: PORTABILITY="-DSPEC_CPU_LP64"
C: MATH_LIBS="-lm"
C: LDOUT="-o options"

Please let me know if you have fix for this error.

HazardousPeach commented 6 years ago

Hmm, looks like our type checker is seeing an inconsistency. Could be because of the use of -ffast-math? I'll try to reproduce and see if I can find the problem.

sangeeta0201 commented 6 years ago

I have tried same benchmark with O0, O1,O2,O3. It won't crash for O2 but crashes for all other cases.

On Thu, Jun 28, 2018, 2:15 PM Alex Sanchez-Stern notifications@github.com wrote:

Hmm, looks like our type checker is seeing an inconsistency. Could be because of the use of -ffast-math? I'll try to reproduce and see if I can find the problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uwplse/herbgrind/issues/27#issuecomment-401126209, or mute the thread https://github.com/notifications/unsubscribe-auth/AgT1SMtAz46XliRVJcffI_VDOtd88vngks5uBR1dgaJpZM4U469B .

HazardousPeach commented 6 years ago

As far as I can tell, at that optimization level gcc is generating calls to __log_finite, which Herbgrind is failing to intercept for some reason. This causes the instrumentation to dive into libm internals, and see an arithmetic bit shift being run on a floating point value. This triggers an assert in the type-checker. I'll need to fix the interception mechanism to properly intercept __log_finite so that we never descend that far into libm. If you want a temporary fix, you can go into src/instrument/instrument-op.c and uncomment lines 314-316. This will treat bit shifts as "special" operations that are allowed to take floats as input, so that Herbgrind won't complain when you descend into libm. Unfortunately, this will cause the real shadow values to be lost in the libm call (probably), so correctness will be compromised for those values.

HazardousPeach commented 6 years ago

This has been fixed in PR #30