Comments (5)
Confirmed, thanks for reporting.
http://github.com/ry/node/blob/81f5ed5c654c7b06e11563c36c79024265bcb7e7/src/node_buffer.cc#L150
It seems the call to NewInstance() returns a (wrapped) NULL pointer when there is stack pressure. The easy way out is to allocate memory on the heap but this might be a bug in V8 so I'm going to take a closer look.
from node-iconv.
I added a test case for this issue:
from node-iconv.
Easy way lead to a great success! The original bug is still puzzling, but as long as we don't put convert() 100.000 calls deep down the call stack, it will probably work. :)
Also, allocating memory in 4K chunks is probably suboptimal in terms of efficiency, especially since we can predict that the size of the output is roughly the same as the size of the input. But for now I think it's OK.
from node-iconv.
I'd written a patch already so I didn't use yours (sorry about that) but your unit test is much better than the thingy I whipped up so I added it.
I've created a nice test case on that Node bug (didn't turn out to be V8 after all). I'll keep you posted if you want.
from node-iconv.
PS: I bumped the temp buffers from 4 to 32K. It wasn't an issue with alloca() because that function simply bumps the stack pointer but heap allocation is rather more expensive.
we can predict that the size of the output is roughly the same as the size of the input
Hah! I originally wrote the iconv bindings to convert UTF-32 to UTF-8 (yes, there are people that actually use UTF-32. I didn't know either). dst = malloc(strlen(src)) would waste a lot of memory in such cases. But I agree that smarter heuristics won't hurt.
from node-iconv.
Related Issues (20)
- npm install sqlite3 HOT 1
- cannot open shared object file HOT 2
- What about CHANGELOG.md HOT 5
- utf-8 to iso-8859-1 error no conversion HOT 2
- Fails to install on windows machine HOT 3
- Unable to install
- Unable to install HOT 3
- iconv cannot be used in worker threads HOT 5
- how to change "νκΈ" to euc-kr ? HOT 1
- Can't resolve ~~ error while developing an Electron app HOT 1
- Memory leak when used with byline? HOT 2
- Upgrade node-gyp to remove python2 dependency HOT 1
- Can't convert string from ISO-8859-1 to windows-1251 HOT 3
- Encodings not supported HOT 2
- Any barriers to IBM500, 037 ? HOT 1
- not doing proper encoding HOT 5
- npm ERR! HOT 1
- WSL npm install iconv failing HOT 3
- will it work with nodejs 20? HOT 1
- NV21 failure? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-iconv.