www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - object.error: Privileged Instruction

reply "simendsjo" <simendsjo gmail.com> writes:
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
     }
}
Sep 22 2012
next sibling parent reply "Maxim Fomin" <maxim maxim-fomin.ru> writes:
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.
Sep 22 2012
parent Don Clugston <dac nospam.com> writes:
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.
Sep 26 2012
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Sep 22 2012
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 09/22/2012 11:33 AM, simendsjo wrote:

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

Yep, Dvorak keyboard rules! ;) Ali
Sep 22 2012