Bug 254616 - memcheck encounters unknown instruction and aborts on Mac OS X 10.6.4 when using OpenGL and GLUI
Summary: memcheck encounters unknown instruction and aborts on Mac OS X 10.6.4 when us...
Status: RESOLVED INTENTIONAL
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.6 SVN
Platform: Compiled Sources macOS
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 03:25 UTC by barbic2003
Modified: 2015-06-01 00:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description barbic2003 2010-10-19 03:25:36 UTC
Version:           3.6 SVN (using Devel) 
OS:                OS X

Memcheck encounters an unknown instructions and aborts when I use it with OpenGL and GLUI. This is on Mac OS X 10.6.4. I built Valgrind from sources which I downloaded via SVN on Sept 20, 2010 (revision 11369).

GLUI is a simple LGPL user-interface library built on top of GLUT, the standard utility toolkit for OpenGL. It is frequently used in computer graphics. I am attaching the tarball with the sources for this library -- but you can also download it (same file, latest version, 2.35) at:

http://glui.sourceforge.net/#download

The problem happens every time. Below is the output of valgrind. Note that valgrind first encounters some "Conditional jump or move depends on uninitialised value(s)" warnings-- but those don't cause it to abort. I get such warnings each time I run *any* OpenGL program with valgrind, even if not using GLUI. 

When using GLUI, however, valgrind aborts during the GLUI initialization. It seems that the offending instruction is inside OpenGL, "gleSetRasterPos". So, this issue is likely *not limited just to GLUI*. It would affect all Mac OS X OpenGL programs using that instruction.

==80760== Memcheck, a memory error detector
==80760== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==80760== Using Valgrind-3.6.0.SVN and LibVEX; rerun with -h for copyright info
==80760== Command: ./example1
==80760== 
==80760== Conditional jump or move depends on uninitialised value(s)
==80760==    at 0x101346EC: gleUpdateState (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x10131217: gleInitializeContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101302AA: gliCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x4B41D: CGLRestoreDispatchFunction (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x469EE: CGLCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x3C77E0B: -[NSOpenGLContext initWithFormat:shareContext:] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==80760==    by 0x3E00552C: -[GLUTView initWithFrame:pixelFormat:windowID:treatAsSingle:isSubwindow:isVBLSynced:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E002788: -[GLUTWindow initWithContentRect:pixelFormat:windowID:gameMode:treatAsSingle:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E019D0E: __glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E01A0E3: glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3310: main (in ./example1)
==80760== 
==80760== Conditional jump or move depends on uninitialised value(s)
==80760==    at 0x10134E18: gleUpdateLightColorChangeFunc (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101347C7: gleUpdateState (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x10131217: gleInitializeContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101302AA: gliCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x4B41D: CGLRestoreDispatchFunction (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x469EE: CGLCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x3C77E0B: -[NSOpenGLContext initWithFormat:shareContext:] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==80760==    by 0x3E00552C: -[GLUTView initWithFrame:pixelFormat:windowID:treatAsSingle:isSubwindow:isVBLSynced:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E002788: -[GLUTWindow initWithContentRect:pixelFormat:windowID:gameMode:treatAsSingle:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E019D0E: __glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E01A0E3: glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3310: main (in ./example1)
==80760== 
==80760== Conditional jump or move depends on uninitialised value(s)
==80760==    at 0x10135131: gleUpdateLightPosition (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101347F1: gleUpdateState (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x10131217: gleInitializeContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101302AA: gliCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x4B41D: CGLRestoreDispatchFunction (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x469EE: CGLCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x3C77E0B: -[NSOpenGLContext initWithFormat:shareContext:] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==80760==    by 0x3E00552C: -[GLUTView initWithFrame:pixelFormat:windowID:treatAsSingle:isSubwindow:isVBLSynced:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E002788: -[GLUTWindow initWithContentRect:pixelFormat:windowID:gameMode:treatAsSingle:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E019D0E: __glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E01A0E3: glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3310: main (in ./example1)
==80760== 
==80760== Conditional jump or move depends on uninitialised value(s)
==80760==    at 0x10135131: gleUpdateLightPosition (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x10134832: gleUpdateState (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x10131217: gleInitializeContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101302AA: gliCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x4B41D: CGLRestoreDispatchFunction (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x469EE: CGLCreateContext (in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL)
==80760==    by 0x3C77E0B: -[NSOpenGLContext initWithFormat:shareContext:] (in /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==80760==    by 0x3E00552C: -[GLUTView initWithFrame:pixelFormat:windowID:treatAsSingle:isSubwindow:isVBLSynced:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E002788: -[GLUTWindow initWithContentRect:pixelFormat:windowID:gameMode:treatAsSingle:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E019D0E: __glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3E01A0E3: glutCreateWindow (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
==80760==    by 0x3310: main (in ./example1)
==80760== 
vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x17
==80760== valgrind: Unrecognised instruction at address 0x11f66dfe.
==80760== Your program just tried to execute an instruction that Valgrind
==80760== did not recognise.  There are two possible reasons for this.
==80760== 1. Your program has a bug and erroneously jumped to a non-code
==80760==    location.  If you are running Memcheck and you just saw a
==80760==    warning about a bad jump, it's probably your program's fault.
==80760== 2. The instruction is legitimate but Valgrind doesn't handle it,
==80760==    i.e. it's Valgrind's fault.  If you think this is the case or
==80760==    you are not sure, please let us know and we'll try to fix it.
==80760== Either way, Valgrind will now raise a SIGILL signal which will
==80760== probably kill your program.
==80760== 
==80760== Process terminating with default action of signal 4 (SIGILL)
==80760==  Illegal opcode at address 0x11F66DFE
==80760==    at 0x11F66DFE: ??? (in /dev/ttys005)
==80760==    by 0x10149A18: gleSetRasterPos (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x101496F0: glRasterPos2i_Exec (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine)
==80760==    by 0x879693: glRasterPos2i (in /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib)
==80760==    by 0xEE88: GLUI_Control::draw_name(int, int) (in ./example1)
==80760==    by 0x93B1: GLUI_EditText::draw(int, int) (in ./example1)
==80760==    by 0xEAF7: GLUI_Control::draw_recursive(int, int) (in ./example1)
==80760==    by 0xEBC7: GLUI_Control::draw_recursive(int, int) (in ./example1)
==80760==    by 0xEBC7: GLUI_Control::draw_recursive(int, int) (in ./example1)
==80760==    by 0x6380: GLUI_Main::display() (in ./example1)
==80760==    by 0x63E0: glui_display_func() (in ./example1)
==80760==    by 0x3E0069E5: -[GLUTView drawRect:] (in /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT)
--80760:0:schedule VG_(sema_down): read returned -4
==80760== 
==80760== HEAP SUMMARY:
==80760==     in use at exit: 7,348,549 bytes in 10,444 blocks
==80760==   total heap usage: 25,805 allocs, 15,361 frees, 11,900,896 bytes allocated
==80760== 
==80760== LEAK SUMMARY:
==80760==    definitely lost: 236 bytes in 4 blocks
==80760==    indirectly lost: 0 bytes in 0 blocks
==80760==      possibly lost: 2,963,335 bytes in 1,201 blocks
==80760==    still reachable: 4,384,978 bytes in 9,239 blocks
==80760==         suppressed: 0 bytes in 0 blocks
==80760== Rerun with --leak-check=full to see details of leaked memory
==80760== 
==80760== For counts of detected and suppressed errors, rerun with: -v
==80760== Use --track-origins=yes to see where uninitialised values come from
==80760== ERROR SUMMARY: 20 errors from 4 contexts (suppressed: 1 from 1)


Reproducible: Always

Steps to Reproduce:
Unpack GLUI (attached, latest version 2.35, you can also download the same file at: http://glui.sourceforge.net/#download ).

Compile GLUI. Compile the examples in the "bin" subfolder. Run valgrind on "example1". Specifically, I used:

valgrind --dsymutil=yes ./example1

The program will run and abort within a few tens of milliseconds, as soon as the execution reaches the part where GLUI is initialized and gleSetRasterPosition from the OpenGL library is called.


Actual Results:  
Valgrind aborts as soon as the code reaches the part where GLUI is initialized. Therefore, programs using GLUI cannot be memcheck-ed.

vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x17
==80760== valgrind: Unrecognised instruction at address 0x11f66dfe.

See the "Summary" for a complete program printout.

Expected Results:  
Valgrind and the program should startup normally, and continue to run.

Valgrind is great software. I only took the time to write all this up because I like using it a lot. I hope Mac OS X support will continue to be improved.
Comment 1 Julian Seward 2010-10-19 10:42:34 UTC
Does adding --smc-check=all change the behaviour?
Comment 2 Rhys Kidd 2015-06-01 00:06:21 UTC
vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x17
^ this refers to the extractps SSE4.1 instruction.

Please refer to https://bugs.kde.org/show_bug.cgi?id=296577 where comment is made about the status of SSE4 and 32 bit. For ease, copied below:

"SSE4 isn't supported in 32 bit mode, only 64 bit mode.  32 bit mode supports only up to and including SSSE3.
http://www.valgrind.org/docs/manual/manual-core.html#manual-core.limits

There are no current plans to support SSE4 on 32-bit.  Please use 64-bit."