Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs (windows) freeze of death, core dumped #3322

Closed
shimondoodkin opened this issue Oct 11, 2015 · 3 comments
Closed

nodejs (windows) freeze of death, core dumped #3322

shimondoodkin opened this issue Oct 11, 2015 · 3 comments
Labels
windows Issues and PRs related to the Windows platform.

Comments

@shimondoodkin
Copy link

windows 7

C:\Users\USER>node --version
v4.1.2

nodejs totally freezed not responding to end task also its parent cmd process did not respond.
there was no convert.exe running, node was using only one thread and 73mb memory and zero cpu..

i could still copy text but it did not responded to any attempt to interrupt.

the script was

converting images to webp using imagemagick executable(static 64bit version with config files copied from installed version)
after it converted 21,162 of about 30,000 files it freezed.

code dump: http://www.filedropper.com/node


var fs=require('fs')
var async = require('async')
var exec = require('child_process').exec;


function magicmime(file,cb)
{
    fs.open(file, 'r', function(status, fd) {
        if (status) {
            console.log(status.message);
            return;
        }
        var buffer = new Buffer(16);
        fs.read(fd, buffer, 0, 16, 0, function(err, num) {
            fs.close(fd, function(){
                var str=buffer.toString('binary', 0, num);
                if(str.substr(1,3)=='PNG') return cb('.png');
                if(str.substr(0,2)=='BM') return cb('.bmp');
                if(str.substr(0,6)=='GIF89a') return cb('.gif');
                if(str.substr(6,4)=='JFIF'||str.substr(6,4)=='Exif') return cb('.jpg');
                if(str.substr(10,4)=='HTML') return cb(''); //cb('.html');
                if(str=="") return cb(''); // empty file
                var hex=buffer.toString('hex');
                if(hex.substr(0,6)=='ffd8ff') return cb('.jpg'); // low end digital camera
                if(hex.substr(0,10)=='0000000000') return cb(''); // empty file
                if(hex.substr(0,6)=='1f8b08') return cb('.gz'); // empty file
                console.log('different file',file,buffer.toString('hex'));
                return cb('');
            });
        });
    });
}

function trimimg()
{
    var i=0;
    var files=fs.readdirSync('img');
    async.eachLimit(files,8,function(a,cb)
    {
     if(!a.match(/\.(png|jpg|bmp|gif)$/i)){i++;return cb()};

     if(fs.existsSync("imgtrim/"+a.replace(/\..+?$/i,"")+".webp")) {i++;return cb()};

     var name=a,
         oname=a.replace(/\..+?$/i,"")+".webp";

     magicmime('img/'+name,function(a){

         if(a=='.png'||a=='.bmp'||a=='.gif'||a=='.jpg')
         {
             var cmd='C:/mingw/msys/1.0/home/USER/stores/bin/imm/convert img/'+name
                     +' -bordercolor white -border 1x1'
                     +' -fill none -fuzz 2.5% -draw "color 0,0 floodfill"'
                     +' -trim +repage'
                     +' imgtrim/'+oname;

             console.log(i++,files.length,name);
             run(cmd,cb);
         }
         else
         {
            cb();
         }

     });

    },function(){console.log('done')});
}
trimimg()

(i don't need solutions it was one time run script, just a bug report)

@shimondoodkin shimondoodkin changed the title nodejs (windows) freeze death, core dumped nodejs (windows) freeze of death, core dumped Oct 11, 2015
@Fishrock123 Fishrock123 added the windows Issues and PRs related to the Windows platform. label Oct 12, 2015
@seishun
Copy link
Contributor

seishun commented Oct 15, 2015

A bug report normally includes a minimal test case. Would you be willing to attempt to produce one?

@shimondoodkin
Copy link
Author

i'll try

@bnoordhuis
Copy link
Member

Closing, no follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

4 participants