Thread overview
object.error: Privileged Instruction
Sep 22, 2012
simendsjo
Sep 22, 2012
Maxim Fomin
Sep 22, 2012
Jonathan M Davis
Sep 26, 2012
Don Clugston
Sep 22, 2012
Ali Çehreli
September 22, 2012
What does the message in the subject mean?

Here's a testcase (tested on dmd 2.060 on win7 32-bit):

import core.exception;
import core.runtime; // comment out this, and no stacktrace is printed

void myAssertHandler(string file, size_t line, string msg = null) { }

static this() {
    setAssertHandler(&myAssertHandler);
    f();
}

version(unittest) {
    void f() {
        //assert(false); // without message, object.error: Breakpoint
        assert(false, "aoeu"); // with message, object.error: Privileged Instruction
    }
}

September 22, 2012
Privilege instruction is an assembly instruction which can be executed only at a certain executive process context, typically os kernel. AFAIK assert(false) was claimed to be implemented by dmd as a halt instruction, which is privileged one.

However, compiled code shows that dmd generates int 3 instruction for assert(false) statement and 61_6F_65_75 which is binary representation of "aoeu" for assert(false, "aoeu") statement and the latter is interpreted as privileged i/o instruction.
September 22, 2012
On Saturday, September 22, 2012 21:19:27 Maxim Fomin wrote:
> Privilege instruction is an assembly instruction which can be executed only at a certain executive process context, typically os kernel. AFAIK assert(false) was claimed to be implemented by dmd as a halt instruction, which is privileged one.
> 
> However, compiled code shows that dmd generates int 3 instruction for assert(false) statement and 61_6F_65_75 which is binary representation of "aoeu" for assert(false, "aoeu") statement and the latter is interpreted as privileged i/o instruction.

It's a normal assertion without -release. With -release, it's a halt instruction on Linux but IIRC it's something slightly different (albeit similar) on Windows, though it might be halt there too.

- Jonathan M Davis
September 22, 2012
On 09/22/2012 11:33 AM, simendsjo wrote:

> assert(false, "aoeu"); // with message, object.error: Privileged

Yep, Dvorak keyboard rules! ;)

Ali

September 26, 2012
On 22/09/12 21:49, Jonathan M Davis wrote:
> On Saturday, September 22, 2012 21:19:27 Maxim Fomin wrote:
>> Privilege instruction is an assembly instruction which can be
>> executed only at a certain executive process context, typically
>> os kernel. AFAIK assert(false) was claimed to be implemented by
>> dmd as a halt instruction, which is privileged one.
>>
>> However, compiled code shows that dmd generates int 3 instruction
>> for assert(false) statement and 61_6F_65_75 which is binary
>> representation of "aoeu" for assert(false, "aoeu") statement and
>> the latter is interpreted as privileged i/o instruction.
>
> It's a normal assertion without -release. With -release, it's a halt
> instruction on Linux but IIRC it's something slightly different (albeit
> similar) on Windows, though it might be halt there too.
>
> - Jonathan M Davis
>

I implemented the code runtime code that does it, at least on Windows. You get much better diagnostics on Windows.
IMHO it is a Linux misfeature, they conflate a couple of unrelated hardware exceptions together into one signal, making it hard to identify which it was.