Git Product home page Git Product logo

node-nim-memory-bug's Introduction

This demonstrates a bug I keep finding while trying to make a Node native addon using Nim as the C-code generator.

Requirements:

  • Node (I'm using 11.7.0)
  • Nim (I'm using 0.19.9)

To see the problem:

make clean
npm i --ignore-scripts
make NIMBASE=/path/to/your/nimbase.h
make test

This will delete and regenerate files in csrc/, build/, lib/ and dist/. I've committed my versions of dist/ and csrc/ to the repo for reference.

Important files

  • jssrc/test.ts - TypeScript code that's run when you do make test
  • jssrc/main.ts - JS module imported by test.ts and which wraps the native Node addon
  • clib.nim - My C library which provides an echo function
  • jstonimbinding.cpp - Some C++ code that uses node-addon-api to wrap the C library into a form Node can consume
  • binding.gyp - The magical incantation that compiles the Node addon.

My output

On my computer, running this produces a ton of output, ending with:

C++ passing message: Hello 4129-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[GCASSERT] decRef
Traceback (most recent call last)
strformat.nim(268)       hello_echo
gc.nim(245)              unsureAsgnRef
gc.nim(109)              decRef
make: *** [test] Error 1

In other cases, I've seen different errors (e.g. "incRef: interior pointer").

node-nim-memory-bug's People

Contributors

iffy avatar

Watchers

 avatar  avatar  avatar

Forkers

rayman22201

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.