Welcome, Guest. Please login or register.

Author Topic: duktape error NetSurf OS3  (Read 33028 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Tygre

Re: duktape error NetSurf OS3
« on: June 15, 2016, 02:06:23 AM »
Hi all!

Thanks for the interesting discussions and all the effort! I wanted to mention that linking with fortify really helps catching memory problems, maybe that could be an option for the development version of netSurf?

Maybe DNADNL could try? :)
Cheers!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #1 on: June 16, 2016, 01:36:40 AM »
Hi Chris and all!

Quote from: chris;810015
Have a look at http://git.netsurf-browser.org/netsurf.git/log/?h=chris/fortify (or git checkout chris/fortify)
However... (a) that probably isn't adding fortify.h to all files (it assumes os3support.h and options.h are eventually included by everything, which probably isn't true) and (b) it doesn't catch AllocVec/FreeVec and friends, which are mostly what I use in the frontend.

Ah, yes, I was just going to post about that: to the best of my knowledge, fortify "intercept" (i.e., redefine) the typical C allocations function: malloc, calloc, et al., and free. So it should probably be modified to add support for AmigaOS-dedicated functions.

Quote from: chris;810015
I'm getting some output, but it seems to be a load of bogus double free()s, which might be due to point (a) above, or because some of the allocations are made by linked libraries.

Try it and see if you can make any sense of the results.  I'll add some #defines for AllocVec when I get chance to catch those too.

That would be very cool because in my (limited) experience with AmiModRadio, fortify really helps catching misplaced/forgotten free and overwrites...

Cheers!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #2 on: August 26, 2016, 01:54:59 AM »
Hi all and Chris and DNADNL in particular :)

I tried to debug this annoying Duktap error that we keep having:
Quote
PANIC 56: uncaught error (calling abort)
and it seems to me that the offending JavaScript code is actually built on the file when Duktap starts and corresponds to the code:
Code: [Select]
(function(d,a){function b(a,b,c){Object.defineProperty(a,b,{value:c,writable:!0,enumerable:!1,configurable:!0})}b(a.Logger,"clog",new a.Logger("C"));b(a,"modLoaded",{})})(this,Duktape);which seems to me legit (at least according to JSFiddle)... Any ideas?

In attachment is the full log... :rtfm: Search for "duk_eval_raw"!

I will continue my debug to try to understand what is happening exactly...
Cheers!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #3 on: August 26, 2016, 03:12:40 AM »
PS. A little bit more detective work and I found the lines causing the problem:

Code: [Select]
DUK_LOCAL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget) {

        // ...

        DUK_D(DUK_DPRINT("second pass of an inner func, skip the function, reparse closing brace; lex offset=%ld, line=%ld",
                             (long) lex_pt.offset, (long) lex_pt.line));

        DUK_LEXER_SETPOINT(&comp_ctx->lex, &lex_pt);
        comp_ctx->curr_token.t = 0;  /* this is needed for regexp mode */
        comp_ctx->curr_token.start_line = 0;  /* needed for line number tracking (becomes prev_token.start_line) */
        duk__advance(comp_ctx);
        duk__advance_expect(comp_ctx, DUK_TOK_RCURLY);

        // ...
}
The offending line is exactly:
Code: [Select]
duk__advance_expect(comp_ctx, DUK_TOK_RCURLY);
because, for some reasons, Duktape expects a right-curly brace but gets an identifier instead... I believe that the syntax-error happens between the right-curly brace and the identifier b in:
Code: [Select]
(function(d,a){function b(a,b,c){Object.defineProperty(a,b,{value:c,writable:!0,enumerable:!1,configurable:!0})}b(a.Logger,"clog",new a.Logger("C"));b(a,"modLoaded",{})})(this,Duktape);Any suggestions? Does this help?

Cheers!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #4 on: August 26, 2016, 07:35:52 PM »
Hi Chris

Thanks Chris!

Quote from: chris;812995
You're probably best off putting it on the netsurf-dev list (try to generate some interest), or putting it on the Duktape bugtracker https://github.com/svaarala/duktape/issues with the log.
Mention it's 68k and NetSurf, Duktape 1.5.0. See what happens.

I contacted yesterday Sami (Vaarala, who helped me few months ago to compile Duktape with VBCC) and I'm now waiting for some answers :laugh1:

Eventually, I will contact NetSurf / Duktape communities...

Quote from: chris;812995
One thing you could try first, is if you have a standalone build of Duktape 1.5.0 you could run that code through it see if the fatal error still occurs.

Yep, same idea here :) I tried with Duktape 1.3.1, worked fine (compiled and run on my Amiga) :angry:

Will try later with 1.5.0...

Talk to you soon!
« Last Edit: August 26, 2016, 07:39:47 PM by Tygre »
 

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #5 on: August 27, 2016, 04:04:14 AM »
Hi Chris and all!

Just to let you know that Sami replied to me very fast and very kindly with several suggestions :angel:

I tried some of his suggestions and got NetSurf and Duktape to compile and run :cool: I am now waiting for his feedback to confirm that my changes make sense or not...

Now, don't get too excited because nothing happens... I loaded various Web pages with JavaScript code and nothing happens but I believe that it could be now due to the way NetSurf handles JavaScript code? :swords:

For example, I noticed something called NETSURF_DUKTAPE_PROTOTYPE_WINDOW in the logs of Duktape... My guess is that this is the "callback" used by NetSurf to control what Duktape should do when it encounters an alert()? Any idea?

Take care!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #6 on: August 27, 2016, 01:57:54 PM »
Hi Chris!

Quote from: chris;813032

I'm not sure alert() is implemented in any visible way - I don't recall seeing any JS alerts since the changeover to Duktape.

This is a good test page:
http://www.javatester.org/javascript.html


Yes, exactly the page I have been using :) but it says that JavaScript is not working, it uses the noscript tag, is it implemented in NetSurf?

Code: [Select]
<script language=&quot;JavaScript&quot;>
     document.write (&quot; &nbsp; JavaScript &nbsp; <b>IS WORKING</b> &nbsp; in your web browser &nbsp;&quot; );
</script>
<noscript>&nbsp; JavaScript <b>IS NOT WORKING</b> in your web browser &nbsp;
</noscript>


I have also used the JavaScripter Web site, which has a simple page with the alert, and my own simpler page, but still no luck:

Code: [Select]
Alert Example




So, alert() may not be implemented but what about a simple document.write()? Into whose backyard does it fall? NetSurf's community?

Cheers! :)

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #7 on: August 27, 2016, 02:00:57 PM »
PS. Sami confirmed that my fix may be the best solution to get Duktape to compile and run on AmigaOS3: all in duk_config.h, DUK_F_USE_REPL_ALL must be defined by:

  • defining AMIGA
  • defining M68000
  • changing the code #elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC) into #elif defined(DUK_F_AMIGAOS)

Let me know!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #8 on: August 28, 2016, 12:14:42 AM »
Quote from: chris;813067
I repeat:

Thanks Chris!

Where do I find the preference program though? :)

Ah! Silly me :lol: They are in the menus...
« Last Edit: August 28, 2016, 12:19:37 AM by Tygre »
 

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #9 on: August 28, 2016, 12:30:23 AM »
And I am very happy to show that JavaScript works now for me too in NetSurf in AmigaOS3!!!

Code: [Select]

<html><head><title>Alert Example</title></head>
<body>
<script>
      document.write('Hello Amiga World!')
</script>
</body>
</html>


« Last Edit: August 28, 2016, 12:49:27 AM by Tygre »
 

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #10 on: August 28, 2016, 12:48:48 AM »
Chris, how could I help further?
Could we chat by PM or e-mail, please? :)

Cheers!

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #11 on: September 14, 2016, 06:56:34 PM »
@freeaks and @gregthecanuck

Thanks a lot!
Will try to contribute further :)

Offline Tygre

Re: duktape error NetSurf OS3
« Reply #12 on: September 14, 2016, 07:04:46 PM »
Hi Chris!

Quote from: chris;813107
Well, there's the usual stuff, and any OS3-specific bugs would be worth fixing (that JS menu item, tabs, the crash on exit that was mentioned, etc).

Of course you can email me :)

Thanks a lot and sorry for the silence, busy with the "back to school" :rolleyes:
Actually, I would rather contribute for OS3-specific bugs... could you give me more info.? I will e-mail you!

Cheers!