Illegal Instruction, possible causes?

Started by
4 comments, last by SimonForsman 10 years, 5 months ago

I am getting an Illegal Instruction exception for OpenGL, and I'm wondering what are common causes of this are and how I should go about tracking them down.

  • It only happens on my desktop, but code works fine when I develop on my laptop. Games and other graphics accelerated applications work fine on the box.
  • I am 99.9% sure a context is current. I use GLEW in multi-threaded mode, and the context wrapper class sets a thread local GLEWContext to NULL when not current, so OpenGL API functions would not de-reference otherwise.
  • This happens on a call to glClearColor(). This is the first API call I make, but if I put it after my glEnable()/glDisable() initialization, it still fails on glClearColor()
  • I am using a version 4.2 context in compatibility mode.

Thank you for any assistance.

Advertisement

Illegal instructions are operating system generated exceptions that (outside of errors caused by bad programming - ie referencing a function pointer to some garbage space in memory) are generally machine-specific. I'm not familiar with OpenGL, but perhaps you have it or your compiler configured for a different machine setup. Are you compiling on your laptop and trying to run on your desktop? Since it happens on your first API call I can only imagine OpenGL is configured to your laptop machine, and it's likely that the compiler is generating a system call that isn't available or isn't the same on your desktop The glEnable()/glDisable() functions probably don't generate the same system call, so they won't cause the exception (assuming this is the real reason). Try re-configuring and recompiling on your desktop.

Hello PixelArtist,

For each machine, I am compiling in VS2012 with the same properties files, except for paths to supporting libraries. I am also compiling on the machine that is running the program. Difference would be that my laptop has a Geforce 700 level card. My desktop has a 400 level card hooked up to the monitors, and a 200 level card so games can offload Physx, Cuda, etc. Both sould support OpenGL 4.2, which my program targets. I can do a simple program that just sets the clear color and clears the screen each frame with the same API calls that crash my bigger program with the same supporting boilerplate libraries without it complaining.

What kind of configuration would be the most likely candidate?

Thanks for any continued assistance.

A function pointer into garbage memory, as pixelartist suggests, seems the most likely cause: from your description, you seem to be compiling the program properly.

Can you detail the difference between a test program that runs and a test program that crashes? Do you link to different libraries? Do the two development environments on your two computers produce different programs? (They shouldn't.)

Omae Wa Mou Shindeiru

I think I found the issue. My compilation settings for Enhanced Instruction Set was "AVX". I changed this and I don't get any illegal instructions on the desktop anymore. I suspect my laptop supports it, while my desktop does not.

I think I found the issue. My compilation settings for Enhanced Instruction Set was "AVX". I changed this and I don't get any illegal instructions on the desktop anymore. I suspect my laptop supports it, while my desktop does not.

IIRC the oldest CPUs that support AVX is intels Sandy Bridge and AMDs Bulldozer (both from 2011), so yeah, it is quite likely that your desktop lacks AVX support.

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement