Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

[.net] Disadvantages of unsafe code?

This topic is 4763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Assuming that your code works perfectly, what downsides are there to using unsafe code? I vaguely remember something like 'if an assembly uses unsafe code then it won't be trusted by other assemblies' and that Windows Vista would give a warning about the app being potentially unsafe. I know that the IL becomes unverifiable when you use unsafe code - might that be a problem? Many thanks

Share this post


Link to post
Share on other sites
Advertisement
umm, random crashes and/or security problems...

if you say the code is unsafe then there is obviously a reason for it

fix that, and noone can complain...

Share this post


Link to post
Share on other sites
Quote:
Original post by DrGUI
Assuming that your code works perfectly.


Having perfectly working code is much different than thinking you have perfectly working code.

PS. I understand how you ment to use the word assuming, but short of a mathematically prove of correctness (and I don't know how great these are) you shouldn't think it's completely bug free.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Arild Fines
An assembly with unsafe code won't run (by default - it's tweakable) from a network share or from the internet. They require full trust.
True. Alos, in a corporate environment, it's likely that the administrator has locked the possibility to run unsafe assemblies. This will likely also be the case if you're running code on a hosted web farm.

Share this post


Link to post
Share on other sites
Thanks for the replies.

My app's a game, which I wouldn't expect to be run over a network share and definately not the internet.

I got the base encoding code from the new managed HDRFormats sample (after already porting some of it) so we have to assume the DirectX programmers know better than me haha. It looks like pointers are necessary in encoding RGB16.

Thanks again!

EDIT: unsafe as in using pointers, not unsafe as in unsafe, rip-off :P

Share this post


Link to post
Share on other sites
Quote:
Original post by DrGUI
My app's a game

In that case, you need full trust anyway. I'm fairly sure the MDX assemblies are mixed-mode, which are just as "unsafe" as using pointers in C#.

Share this post


Link to post
Share on other sites
It is my understanding that an assembly can be explicitly configured as "trusted" by the OS even if it contains unsafe code. It is likely that the MDX assemblies would be trusted by Windows, and thus also your app assuming it doesn't use any unsafe code.

Share this post


Link to post
Share on other sites
Quote:
Original post by Holy Fuzz
It is my understanding that an assembly can be explicitly configured as "trusted" by the OS even if it contains unsafe code. It is likely that the MDX assemblies would be trusted by Windows, and thus also your app assuming it doesn't use any unsafe code.
Assemblies in the GAC (Global Assembly Cache, located at c:\windows\assembly) are granted full trust, and most likely MDX is installed there together with assemblies such as System.Windows.Forms. The GAC is basically a computer-wide repository of assemblies.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!