Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Crash when returning a IntPtr when dynamically invoke .NET APIs

オープン
#459 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp, node.js
領域
api, backend

調査の方向性

src/NodeApi/JSValue.cs:609 から始め、示されている Node.js REPL の例で NativeLibrary.GetMainProgramHandle() を使って失敗を再現します。スタックトレースを IntPtr を返す他の API と比較します。これらの動的呼び出しがクラッシュせず、結果を正常に返すようになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hi!

When I try to invoke dynamically an API which returns an IntPtr (e.g. GetMainProgramHandle()) the process crashes:

C:\Users\xc3ll>node
Welcome to Node.js v16.15.1.
Type ".help" for more information.
> const test = require('node-api-dotnet');
> handle = test.System.Runtime.InteropServices.NativeLibrary.GetMainProgramHandle()


Microsoft.JavaScript.NodeApi.JSException: Invalid argument: Error in DefineProperties at D:\a\_work\1\s\src\NodeApi\JSValue.cs:609
   at REPL72:1:60
   at Script.runInThisContext (node:vm:129:12)
   at REPLServer.defaultEval (node:repl:566:29)
   at bound (node:domain:421:15)
   at REPLServer.runBound [as eval] (node:domain:432:12)
   at REPLServer.onLine (node:repl:893:10)
   at REPLServer.emit (node:events:539:35)
   at REPLServer.emit (node:domain:475:12)
   at REPLServer.Interface._onLine (node:readline:487:10)
   at REPLServer.Interface._line (node:readline:864:8)
   at Microsoft.JavaScript.NodeApi.JSValue.<>c__DisplayClass114_0.<DefineProperties>b__0(String _, ReadOnlySpan`1 descriptorsPtr)
   at Microsoft.JavaScript.NodeApi.JSValue.ToUnmanagedPropertyDescriptors(String name, IReadOnlyCollection`1 descriptors, UseUnmanagedDescriptors action)
   at Microsoft.JavaScript.NodeApi.JSValue.DefineProperties(JSPropertyDescriptor[] descriptors)
   at Microsoft.JavaScript.NodeApi.JSError.CreateErrorValueForException(Exception exception, String& message)
   at Microsoft.JavaScript.NodeApi.JSError.ThrowError(Exception exception)
   at Microsoft.JavaScript.NodeApi.JSValue.InvokeCallback[TDescriptor](napi_env env, napi_callback_info callbackInfo, JSValueScopeType scopeType, Func`2 getCallbackDescriptor)
   at Microsoft.JavaScript.NodeApi.JSValue.InvokeJSMethod(napi_env env, napi_callback_info callbackInfo)


I tested it with other functions and the result is the same.

主要言語
C#
スター
783
フォーク
80
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/node-api-dotnet のほかの issue

microsoft/node-api-dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。