Thread overview
'Privileged instruction'.
May 25, 2019
Amex
May 25, 2019
Amex
May 27, 2019
Rainer Schuetze
May 25, 2019
I'm having serious issues with this. I moved some code to a different directory and it's broke all over the place(even though I updated every occurrence of the paths). Somewhere something is not being loaded and it's producing a null reference somewhere which is propagating through the app in a very strange way(I think it has to do with the Orange SerDes.

The problem is that for any crash such as a range error or a null pointer reference, the debugger throws a 'Privileged instruction'. and then exists the program.

Hence I can't see the stack or anything and can't debug the program. I have to run it in the command prompt and have it crash then launch a new instance of VS and then it will show the line, but still say 'Privileged instruction' error. I can see the stack and eventually locate the error.  [There are lot's of windows/VS dialog boxes that slow the process down]

It's very slow doing it this way. Surely something can be done? Unfortunately I'm using x64 binaries with x64 GTK and others so it's a lot of trouble to switch to x86.

Could you look in to this when you get a chance?

Thanks.
May 25, 2019
First-chance exception: 0xc0000096: Privileged instruction
Unhandled exception: 0xc0000096: Privileged instruction

Since this error only occurs in VS and not when running the app from the command line, surely these is a VS/VD issue?

"A privileged instruction is a processor op-code (assembler instruction) which can only be executed in "supervisor" (or Ring-0) mode. These types of instructions tend to be used to access I/O devices and protected data structures from the windows kernel.

Regular programs execute in "user mode" (Ring-3) which disallows direct access to I/O devices, etc...

As others mentioned, the cause is probably a corrupted stack or a messed up function pointer call."

I'm wondering if there is a bug in some VD code that causes this when handling exceptions in x64?
May 27, 2019

On 25/05/2019 21:28, Amex wrote:
> First-chance exception: 0xc0000096: Privileged instruction Unhandled exception: 0xc0000096: Privileged instruction
> 
> Since this error only occurs in VS and not when running the app from the command line, surely these is a VS/VD issue?

No. The D runtime disables catching the (custom) exception for the stack trace when running in a debugger. This allows you to analyze the call stack of unhandled exceptions in the debugger.

Unfortunately, there is currently no way to re-enable that catch, only to disable it for regular execution. If you have a long running process you can attach to it after program start, that will result in the unhandled exception being shown.

The next release of Visual D will show the exception type and message (and the location if available) in the output window along with the "Priviledged instruction" messages. I hope to be able to release a beta in the next couple of days.