1. Vista users: machine level exception when calling external functions

I started getting this weird error a few days ago on my Vista machine. Whenever a program uses c_func()/c_proc()/call() it causes a machine level exception. It's not my code that's the problem, because this happens in programs written by others as well (like DEMO\WIN32\winwire.exw). I've tried both Euphoria 3.1.1 and 4.0 and it makes no difference. I don't recall having installed any Windows updates in the time between when things were last working and when they started not working. Has anyone else here seen this error? And if so, (how) were you able to fix it?

new topic     » topic index » view message » categorize

2. Re: Vista users: machine level exception when calling external functions

mic said...

I started getting this weird error a few days ago on my Vista machine. Whenever a program uses c_func()/c_proc()/call() it causes a machine level exception. It's not my code that's the problem, because this happens in programs written by others as well (like DEMO\WIN32\winwire.exw). I've tried both Euphoria 3.1.1 and 4.0 and it makes no difference. I don't recall having installed any Windows updates in the time between when things were last working and when they started not working. Has anyone else here seen this error? And if so, (how) were you able to fix it?

There was a contribution about enabling DEP in the archive, http://www.rapideuphoria.com/dep.zip

I would certainly try it out, as your problem has been reported before, and reported to be cured by this I don't have Vista myself, and disabled DEP under XP as much I could.

CChris

new topic     » goto parent     » topic index » view message » categorize

3. Re: Vista users: machine level exception when calling external functions

Hi

Does this mean that if you want a distribution, then all users that use your program have to enable DEP?

If so, imho, this is not a good thing. Can we ask MS to rewrite windows for us?

Chris

new topic     » goto parent     » topic index » view message » categorize

4. Re: Vista users: machine level exception when calling external functions

ChrisB said...

Hi

Does this mean that if you want a distribution, then all users that use your program have to enable DEP?

If so, imho, this is not a good thing. Can we ask MS to rewrite windows for us?

Chris

With Shawn Pringle code integrated in your application, the application itself
will unlock DEP so the end user won't have to disable DEP.
The only problem is that you must recompile exw.exe with the modified machine.c
I think this should be added to 4.0.

Jacques d.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Vista users: machine level exception when calling external functions

CChris said...

There was a contribution about enabling DEP in the archive, http://www.rapideuphoria.com/dep.zip

I would certainly try it out, as your problem has been reported before, and reported to be cured by this I don't have Vista myself, and disabled DEP under XP as much I could.

I call external procedures and those external procedures call my internal procedures (call_back) all the time on Vista and 4.0. What is different? I must admit I am DEP ignorant.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

6. Re: Vista users: machine level exception when calling external functions

jeremy said...
CChris said...

There was a contribution about enabling DEP in the archive, http://www.rapideuphoria.com/dep.zip

I would certainly try it out, as your problem has been reported before, and reported to be cured by this I don't have Vista myself, and disabled DEP under XP as much I could.

I call external procedures and those external procedures call my internal procedures (call_back) all the time on Vista and 4.0. What is different? I must admit I am DEP ignorant.

Jeremy

It boils down to executing code in a memory area Windows didn't assume oto hold executable code. This is supposed to defend against various virii. The memory allocate() returns a pointter to is not marked as executable, and this is why call() may fail with a machine level exception.

DEP can be restricted to only affect Windows base services, not user pps. That way, Euphoria apps with machine code an run. I am les sure why a call to c_func() would fail, but the reason is very likely close, if not identical.

I second the motion to inclue the fix in Eu 4.0. I'd do it if not for the lasting lack of svn access.

CChris

new topic     » goto parent     » topic index » view message » categorize

7. Re: Vista users: machine level exception when calling external functions

CChris said...

It boils down to executing code in a memory area Windows didn't assume oto hold executable code. This is supposed to defend against various virii. The memory allocate() returns a pointter to is not marked as executable, and this is why call() may fail with a machine level exception.

DEP can be restricted to only affect Windows base services, not user pps. That way, Euphoria apps with machine code an run. I am les sure why a call to c_func() would fail, but the reason is very likely close, if not identical.

I second the motion to inclue the fix in Eu 4.0. I'd do it if not for the lasting lack of svn access.

Why does it work for some people and not others? i.e. I've never had a problem here. I am not suggesting it is not a problem or should not be part of 4.0, I am just trying to better understand the situation.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

8. Re: Vista users: machine level exception when calling external functions

jeremy said...
CChris said...

It boils down to executing code in a memory area Windows didn't assume oto hold executable code. This is supposed to defend against various virii. The memory allocate() returns a pointter to is not marked as executable, and this is why call() may fail with a machine level exception.

DEP can be restricted to only affect Windows base services, not user pps. That way, Euphoria apps with machine code an run. I am les sure why a call to c_func() would fail, but the reason is very likely close, if not identical.

I second the motion to inclue the fix in Eu 4.0. I'd do it if not for the lasting lack of svn access.

Why does it work for some people and not others? i.e. I've never had a problem here. I am not suggesting it is not a problem or should not be part of 4.0, I am just trying to better understand the situation.

Jeremy

DEP is activated only in Vista and XP SP2 and later. People with older versions/service packs are not affected. Some older processors may not support it either.

How DEP is configured depends on various things. To check how your settings are, go to Configuration Panel -> System -> Advanced. Then, two courses are available:

  1. Check which programs DEP applies to: Go to Performances -> Data Execution Prevention and see which radios are checked, and whether there is an exclusion list.
  2. (what I did) instead, go to Boot and Recovery options, click Modify to access the boot options, go to the line that says
    /noexecute=<various possibilities>.
    Change it to
    /noexecute=AlwaysOff .

Then save and OK out. Change effective on next reboot, call() no longer crashes.

I remember that Rob wrote something in the foum a while ago, but you can probably find the post, even if we still cannot.

M$ says it is part of a defensve strategy. Since DEP relies on simple mechanisms that have existed since the 80386 CPUs were released, I think the defense is more against competition than against hackers. Just my opiniion. Virii makers have known for a long time that they had to mark their hot memory pages as executable and tweak the paging system, so they don't care about DEP anyway, they tunnel beneath it.

CChris

new topic     » goto parent     » topic index » view message » categorize

9. Re: Vista users: machine level exception when calling external functions

CChris said...

DEP is activated only in Vista and XP SP2 and later. People with older versions/service packs are not affected. Some older processors may not support it either.

Is it something you specifically have to enable? I have Windows Vista Home Premium, Intel Quad Core2 Q6600 processor. SP1. Windows update does not say I have anything more to do. But on my install, I use C libraries just fine and also those C libraries use routines I give to them via call_back(). Would this not trigger DEP protection?

CChris said...

How DEP is configured depends on various things. To check how your settings are, go to Configuration Panel -> System -> Advanced. Then, two courses are available:

  1. Check which programs DEP applies to: Go to Performances -> Data Execution Prevention and see which radios are checked, and whether there is an exclusion list.

Ok, my DEP settings are: "Turn on DEP for essential Windows programs and services only". Now, is this for call() only or also call_back() type functions? Is there some sort of little test program I can try? I can patch Euphoria and then make sure it all works as it should?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

10. Re: Vista users: machine level exception when calling external functions

[quote jeremy]

CChris said...

DEP is activated only in Vista and XP SP2 and later. People with older versions/service packs are not affected. Some older processors may not support it either.

jeremy said...

Is it something you specifically have to enable? I have Windows Vista Home Premium, Intel Quad Core2 Q6600 processor. SP1. Windows update does not say I have anything more to do. But on my install, I use C libraries just fine and also those C libraries use routines I give to them via call_back(). Would this not trigger DEP protection?

No, it's rather something you have to do something to disable rather...

CChris said...

How DEP is configured depends on various things. To check how your settings are, go to Configuration Panel -> System -> Advanced. Then, two courses are available:

  1. Check which programs DEP applies to: Go to Performances -> Data Execution Prevention and see which radios are checked, and whether there is an exclusion list.
jeremy said...

Ok, my DEP settings are: "Turn on DEP for essential Windows programs and services only". Now, is this for call() only or also call_back() type functions? Is there some sort of little test program I can try? I can patch Euphoria and then make sure it all works as it should?

Jeremy

demo/callmach.ex is said to be a good test to see if there is a problem with DEP wrt call(). I didn't reenable DEP to test this. Your setting should - crossing fingers - be enough to avoid the annoyance.

When you use call_back(), you get an address from a routine id. A routine id may come either from define_c_proc() or routine_id().

  • In the latter case, the routine is in executable memory area, and DEP does not interfere.
  • Inn the former case, it all depends on how the dll was compiled. And if you used the "" special dll entry point in order to get a routine id from machine code in RAM, Intel knows what state the code page it is in has. If the page doesn't have the PAGE_EXECUTE flag, DEP may terminate the offending process thru a page fault exception.

Also remember you can get an external routine address using define_c_var(). Same here: who knows how cleanly the thing was compiled? Older code didn't need to deal with DEP, as it was not enabled by the OS.

I'd suggest any reader with failing c_func() calls or similar that can be traced without a doubt to DEP interference to email Jeremy so as to provide him with some test code. Again, if demo/callmach.ex passes, there may <cough> be no problem at all.

CChris

new topic     » goto parent     » topic index » view message » categorize

11. Re: Vista users: machine level exception when calling external functions

ChrisB said...

Hi

Does this mean that if you want a distribution, then all users that use your program have to enable DEP?

Chris

No, it doesn't.

You can include xalloc.e. If you use allocate_code() instead of allocate() and poke() for allocating x86 hex-instructions and use xcall_back() rather than call_back() for passing your EUPHORIA routines to C then programs will function the same with or without DEP.

Shawn Pringle

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu