jerryscript-project / iotjs

Platform for Internet of Things with JavaScript http://www.iotjs.net
Other
2.58k stars 440 forks source link

SegFault on require for JS module which uses RegEx with iotjs snapshots #1971

Open tysenmoore-xse opened 3 years ago

tysenmoore-xse commented 3 years ago

I am am trying to migrate a reasonable large webpacked module to iot.js for running on an embedded target. Some of my node dependencies require the url module--I have bo control over this. It seems iot.js does not natively support a polyfil for the url module. I saw PR #1528 which was written to address this limitation but it was moved to iotjs-modules but the submodule link is now broken. However, I took the original developers code and integrated it into iotjs. When using the code as originally written there were two statements that were causing crashes when the url module was required into the test program. The two lines are:

var protocolPattern = /^[a-z0-9.+-]+:/i;
var portPattern = /:[0-9]*$/;

After a bunch of trial and error I determined:

It would seem the code generating the snapshot does not like the regex syntax and causes a seg fault when parsed. The fact that it works when included using a relative path indicates to me that the jerry-script itself does not have a problem with the syntax. I could however be way off here.

I am new to iotjs/jerry-scipt. I am wondering if this a known limitation when creating native JS modules inside iotjs or is it a bug? Is that syntax allowed for normal use but not supported in the JS modules for iotjs? Or am I completely missing something and it is a different problem all together?

Thanks in advance for any info or help.

My initial testing is done using:

working.tar.gz -- these are my working files. You can see what I commented out in the url file. Also the test_url.js has the relative path commented out at the moment.