denoland/deno コミットリーディング 12/05

ファシリテータ: @ggtmtmgg セクリタリ: @ggtmtmgg

https://github.com/denoland/deno

0bec0fa594486876ff63d02e98ab454515e9c0d8

Title: Remove leaks from snapshot_creator
タイトル: snapshot_creatorからリークの可能性を取り除く
CommitDate: Mon Dec 3 19:34:01 2018 -0800

# LSAN build. We are in the process of getting a completely clean LSAN build,
# but it will take some work. So for now we just run a subset of the tests.

LSANを完全にcleanにビルドしたいけど、ちょっと大変らしい。
LSANが何かよくわからない。
LSANゾーン(Logical SANゾーン): Fabric間でお互いのFabricをマージせずにIntegrated Routingというルーティングによってデバイス間をゾーンする機能

# We want to detect leaks during the build process as well as when executing
# the tests. So set the ASAN_OPTIONS env var before build.py is run.
export ASAN_OPTIONS=detect_leaks=1

テストを実行するときにビルドプロセスの脆弱性を特定したい。だからASAN_OPTIONSをビルド前に指定する。

-  DENO_BUILD_MODE=release ./tools/build.py -j2
+  ./tools/build.py -C target/release -j2

DENO_BUILD_MODEの脱却が見られる。DENO_BUILD_MODEがどこかに残ってれば書き換えてプルリク送れそう。

-  std::string snapshot_str(reinterpret_cast<char*>(snapshot.data_ptr),
-                           snapshot.data_len);

   std::ofstream file_(snapshot_out_bin, std::ios::binary);
-  file_ << snapshot_str;
+  file_.write(reinterpret_cast<char*>(snapshot.data_ptr), snapshot.data_len);
   file_.close();
+
+  delete[] snapshot.data_ptr;
+  deno_delete(d);
+

あまりどういう処理なのかわからないけど、コネクションを適切にクローズして、snapshotを適切に削除できてそう。

9e839b7e2325e55147cc7e49ed9576cc000eaf63

Title: Avoid memory leak (#1265)
CommitDate: Mon Dec 3 19:07:34 2018 -0800

-    // TODO(zero-copy) Use Buf::leak(buf) to leak the heap allocated buf. And
-    // don't do the memcpy in ImportBuf() (in libdeno/binding.cc)
+    // deno_respond will memcpy the buf into V8's heap,
+    // so borrowing a reference here is sufficient.
     unsafe {
       libdeno::deno_respond(
         self.libdeno_isolate,
         self.as_void_ptr(),
         req_id,
-        buf.into(),
+        buf.as_ref().into(),
       )
     }
   }

deno_respondはV8のヒープ領域にメモリーコピーをする、なので参照を借りてこればここでは充分。 (何いっているかわからない。)

f6c841a6cd85b8e8db3c6cb52fa41811535a72ca

Title: Turn off kPromiseResolvedAfterResolved warning
CommitDate: Mon Dec 3 16:30:08 2018 -0800

+    case "ResolveAfterResolved":
+      // Should not warn. See #1272
+      break;

nodeではresolveされたPromiseをPromise.raceしようとしても特に警告は出ないらしい。 なのでdenoでも無視しようという考え。

参考