Jump to content

  • Log In with Google      Sign In   
  • Create Account


Illegal Instruction, possible causes?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 AaronMK   Members   -  Reputation: 113

Like
0Likes
Like

Posted 11 October 2013 - 08:50 AM

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.



Sponsor:

#2 PeterF   Members   -  Reputation: 568

Like
1Likes
Like

Posted 11 October 2013 - 10:00 AM

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.



#3 AaronMK   Members   -  Reputation: 113

Like
0Likes
Like

Posted 13 October 2013 - 03:45 PM

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.



#4 LorenzoGatti   Crossbones+   -  Reputation: 2511

Like
1Likes
Like

Posted 14 October 2013 - 04:08 AM

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.)


Produci, consuma, crepa

#5 AaronMK   Members   -  Reputation: 113

Like
0Likes
Like

Posted 28 October 2013 - 12:47 AM

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.



#6 SimonForsman   Crossbones+   -  Reputation: 5753

Like
0Likes
Like

Posted 28 October 2013 - 01:05 AM

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.


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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS