3

長い投稿についてお詫び申し上げます - ガベージ コレクションに関連していると思われる問題が発生しています。

次のように DMDScript をラップするクラスがあります。

/**
*   Wrapper class for the DMDScript 
*/
class ScriptingHost
{
    protected static CallContext *cc ;  // Call Context for interaction with the script.
    protected static Program prg ;      // Reference to program object (this is where the script buffer gets parsed)

    static this()
    {
        // create our program instance
        prg = new Program();

        // create reference to call Context 
        cc = prg.callcontext;

        Stdout( "cc.global: " )( cc.global ).newline ;

        // add some built-in functions, like trace() and trigger()
        DnativeFunction dnfTrace = new DnativeFunction( &jsTrace, "trace", 0, Dfunction.getPrototype() ) ;
        DnativeFunction dnfTrigger = new DnativeFunction( &jsTrigger, "trigger", 0, Dfunction.getPrototype() ) ;

        // add it to the call context
        cc.global.Put("trace", dnfTrace , 0);
        cc.global.Put("trigger", dnfTrigger , 0);
    }

    /***********************************************************************
    *   Helper functions for D<-->JS interaction
    ************************************************************************/

    /**
    *   Trace (output)
    */
    protected static void* jsTrace( Dobject pthis, CallContext* cc, Dobject othis, Value* ret, Value[] arglist) 
    {
        Stdout( "<<" )( arglist ).newline ;
        return null;
    }  

    /**
    *   Trigger
    */
    protected static void* jsTrigger( Dobject pthis, CallContext* cc, Dobject othis, Value* ret, Value[] arglist) 
    {
        Stdout( "<<" )( arglist ).newline ;
        return null;
    }  
}

これまでのところ、すべて問題なく、エラーなしでコードを実行できます。出力:

cc.global: dmdscript_tango.dglobal.Dglobal

また、cc.global オブジェクトをトレースするメソッドを ScriptingHost に追加しました。

public static void testGlobal()
{
    Stdout( "testGlobal: " )( cc.global ).newline.flush ; 
}

...これも正常に動作します-クラスalaの外部からアクセスしようとすると問題が発生します:

int main()
{
    Stdout( "DMDScriptTest" ).newline ;
    ScriptingHost.testGlobal() ;
    Stdout( "global: " )( ScriptingHost.global() ).newline.flush ; 
    ScriptingHost.testGlobal() ;
}

次に、次のエラーが表示されます。

cc.global: dmdscript_tango.dglobal.Dglobal
DMDScriptTest
testGlobal: dmdscript_tango.dglobal.Dglobal
object.Exception: Illegal Instruction
----------------
[  5fd264]       0+0   ???                                                                                 @0+1975211 :0 
[  404e05]       0+0   tango.text.convert.Layout.Layout!(char).Layout.parse.process                     @0+29 c:\dmd\dmd\bin\..\import\tango\text\convert\Layout.d:595 
[  404875]       0+0   tango.text.convert.Layout.Layout!(char).Layout.parse                             @0+65 c:\dmd\dmd\bin\..\import\tango\text\convert\Layout.d:603 
[  40463b]       0+0   tango.text.convert.Layout.Layout!(char).Layout.convert                           @0+34 c:\dmd\dmd\bin\..\import\tango\text\convert\Layout.d:347 
[  40418e]       0+0   tango.io.stream.Format.FormatOutput!(char).FormatOutput.print                    @0+67 c:\dmd\dmd\bin\..\import\tango\io\stream\Format.d:172 
[  40206c]       0+0   __Dmain                                                                          @0+45 test2.d:87 
[  4380b5]       0+0   rt.compiler.dmd.rt.dmain2.main.runMain                                           @0+119292 :0 
[  43800b]       0+0   rt.compiler.dmd.rt.dmain2.main.tryExec                                           @0+119122 :0 
[  4380f3]       0+0   rt.compiler.dmd.rt.dmain2.main.runAll                                            @0+119354 :0 
[  43800b]       0+0   rt.compiler.dmd.rt.dmain2.main.tryExec                                           @0+119122 :0 
[  437fc3]       0+0   _main                                                                            @0+119050 :0 
[  44c980]       0+0   _mainCRTStartup                                                                  @0+203463 :0 
[75e133c8]       0+0   ???                                                                                 @0+1973388559 :0 
[76f49ed0]       0+0   ???                                                                                 @0+1991438359 :0 
[76f49ea0]       0+0   ???                                                                                 @0+1991438311 :0 
global: unittest start
unittest end

ここで問題に光を当てることができる人はいますか?おそらくそれを回避する方法を教えてください。:)

編集: Windows D1-Tango セットアップを使用しています。私が使用しているバージョンは 0.99.9 Tango/DMD 1.056 Kai bundle です。

ありがとう、

4

2 に答える 2

0

どのバージョンの DMD を使用していますか? まだ 1.067 を使用していて、64 ビット モードでコンパイルしていて、十分に古いハードウェアを使用している場合は、問題が発生している可能性があります。1.067 は 64 ビットをサポートする最初のバージョンで、非常に古い 64 ビット CPU ではサポートされていない LAHF および SAHF 命令を使用するバグがありました。

于 2011-07-12T02:32:53.420 に答える