Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline chris

Re: duktape error NetSurf OS3
« Reply #179 from previous page: August 01, 2016, 05:57:15 PM »
Quote from: DNADNL;811952
Aw, I wanted to go on LOG-ing everything, but for this I need to compile regularly NetSurf with DukTape. Unfortunately, i can't now, it seems there is an issue :

Code: [Select]
make: *** [Makefile:809: build-CYGWIN_NT_6_1_WOW-amigaos3/content_handlers_javascript_duktape_dukky.o] Error 1

The output immediately prior to that might be more useful.

Quote
Could the default duk_create_heap cause this issue ?

No.  I tried reverting to the default one and the result was the same (unsurprising, given the replacement functions are more robust versions).

Quote
EDIT 2 :
I've just thought about this : NetSurf has RAM issues/leaks without DukTape, and it seems DukTape has this issue too. So maybe when we combine the RAM issues of both NetSurf and DukTape, the leak is so high that NetSurf is crashing before its launch. Without DukTape, NetSurf can be launched, but at a moment, it says "not enough memory". So maybe be focused only on DukTape memory leak isn't the best solution, is it ?

I've not seen the leak that bad, in fact I'm not sure it's leaking so much as overwriting memory it shouldn't be.

Maybe we need to run something like MemGuard (but an OS3 equivalent, so MuGuardianAngel probably) and see where it crashes?

I did have a problem involving lists in an early version with memory being overwritten only on OS3.  I suspect the current problem is somewhat similar.

I think you're right that it is the combined effects, because NetSurf alone works, and Duktape alone works.

Quote
EDIT 3 (#ILoveEditingMyself) :
Is it normal than in dukky.c the "duk_create_heap" function called isn't a pointer while in duktape.c/duktape.h, "duk_create_heap" is defined as a pointer ("*duk_create_heap") ? Maybe the issue comes from there ! I think we need a * in dukky.c .

The * is part of the return type - it returns a pointer.  No star required when calling the function.
« Last Edit: August 01, 2016, 06:02:33 PM by chris »
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #180 on: August 01, 2016, 06:23:22 PM »
Quote from: chris;811953
The output immediately prior to that might be more useful.

If i understood well, here is the steps before the issue (see the txt file enclosed).

Quote from: chris;811953
I've not seen the leak that bad, in fact I'm not sure it's leaking so much as overwriting memory it shouldn't be.

Maybe we need to run something like MemGuard (but an OS3 equivalent, so MuGuardianAngel probably) and see where it crashes?

I did have a problem involving lists in an early version with memory being overwritten only on OS3.  I suspect the current problem is somewhat similar.

I think you're right that it is the combined effects, because NetSurf alone works, and Duktape alone works.

Yes, so either it's the link between them which doesn't work or when there are combined, they leak too much memory... or maybe both.

Quote from: chris;811953
The * is part of the return type - it returns a pointer.  No star required when calling the function.
OK, I preferred to ask than to stay ignorant ! ^^
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #181 on: August 01, 2016, 07:00:26 PM »
OK, here is the compilation issue, more specifically :
Code: [Select]
content/handlers/javascript/duktape/dukky.c:580: error: syntax error before "if"

OK, that comes from the file I use to replace dukky.c, sorry ! XD
 

Offline chris

Re: duktape error NetSurf OS3
« Reply #182 on: August 01, 2016, 07:01:17 PM »
Quote from: DNADNL;811954
If i understood well, here is the steps before the issue (see the txt file enclosed).


Code: [Select]
content/handlers/javascript/duktape/dukky.c: In function `js_newcontext':
content/handlers/javascript/duktape/dukky.c:580: error: syntax error before "if"


Have a look at line 580 in content/handlers/javascript/duktape/dukky.c.  There's something odd before the "if".  Usually it means there's no semicolon at the end of line 579!

Quote
Yes, so either it's the link between them which doesn't work or when there are combined, they leak too much memory... or maybe both.


Yep.
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #183 on: August 01, 2016, 07:03:55 PM »
Quote from: chris;811957
Code: [Select]
content/handlers/javascript/duktape/dukky.c: In function `js_newcontext':
content/handlers/javascript/duktape/dukky.c:580: error: syntax error before "if"

Have a look at line 580 in content/handlers/javascript/duktape/dukky.c.  There's something odd before the "if".  Usually it means there's no semicolon at the end of line 579!



Yep.
Yes, that was my bad, sorry. ^^
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #184 on: August 01, 2016, 08:20:38 PM »
Is it normal this part of code is in a do while loop with the condition (0) ?
Code: [Select]
#if defined(DUK_USE_COMPUTED_NAN)
do {
/* Workaround for some exotic platforms where NAN is missing
* and the expression (0.0 / 0.0) does NOT result in a NaN.
* Such platforms use the global 'duk_computed_nan' which must
* be initialized at runtime.  Use 'volatile' to ensure that
* the compiler will actually do the computation and not try
* to do constant folding which might result in the original
* problem.
*/
volatile double dbl1 = 0.0;
volatile double dbl2 = 0.0;
duk_computed_nan = dbl1 / dbl2;
} while (0);

EDIT : It seems there are two DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) functins in duktape.c . Is it normal ?
« Last Edit: August 01, 2016, 10:09:33 PM by DNADNL »
 

Offline chris

Re: duktape error NetSurf OS3
« Reply #185 on: August 01, 2016, 10:18:16 PM »
Quote from: DNADNL;811962
Is it normal this part of code is in a do while loop with the condition (0) ?
[...]
EDIT : It seems there are two DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) functins in duktape.c . Is it normal ?


If you haven't changed it, yes.
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #186 on: August 01, 2016, 10:19:46 PM »
Quote from: chris;811971
If you haven't changed it, yes.
Very good answer ! ^^
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #187 on: August 01, 2016, 11:32:17 PM »
HEY, I'VE FOUND SOMETHING !
As I can see, there is a unending loop in duktape.c ! Yahoo !
Here is the NetSurf logged : https://dl.dropboxusercontent.com/u/101212919/NetSurf%20AmigaOS/BUGGINGNetSurf_3.6dev_AmigaOS3.tar
Take it, and launch it into Amikit with -v for example.

EDIT :
Here is the picture : https://dl.dropboxusercontent.com/u/101212919/NetSurf%20AmigaOS/Loop%20Error.png
It's in the DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) function (the big one, not the other).
I'm exhausted with all these LOGs, but so happy I've found something !
« Last Edit: August 02, 2016, 12:22:07 AM by DNADNL »
 

Offline chris

Re: duktape error NetSurf OS3
« Reply #188 on: August 02, 2016, 02:55:12 PM »
Quote from: DNADNL;811978
HEY, I'VE FOUND SOMETHING !
As I can see, there is a unending loop in duktape.c ! Yahoo !


Are you sure it is looping?  With my much reduced logging it took ages for NetSurf to start up.  I'd expect the looping to stop and the fatal error to print eventually.
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #189 on: August 02, 2016, 03:52:06 PM »
Quote from: chris;811996
Are you sure it is looping?  With my much reduced logging it took ages for NetSurf to start up.  I'd expect the looping to stop and the fatal error to print eventually.
I'm not totally sure, but I can see that, when I launch a NetSurf version without duktape.c totally LOGged, The FATAL 56 appears in 3 seconds approx. , and when I launch the totally LOGged one, It takes approx 300 seconds to appear, and the issue doesn't apprear before.
I think it could be good to have a look at this function.

EDIT : I correct, with the totally LOGged version it doesn't stop. I think I unintentionnaly stopped it when I took a screenshot.
EDIT 2 : I correct again, with the totally LOGged version, it stops whenever it wants ! ^^
« Last Edit: August 02, 2016, 04:11:35 PM by DNADNL »
 

Offline chris

Re: duktape error NetSurf OS3
« Reply #190 on: August 02, 2016, 05:58:52 PM »
Quote from: DNADNL;811999
I'm not totally sure, but I can see that, when I launch a NetSurf version without duktape.c totally LOGged, The FATAL 56 appears in 3 seconds approx. , and when I launch the totally LOGged one, It takes approx 300 seconds to appear, and the issue doesn't apprear before.
I think it could be good to have a look at this function.

EDIT : I correct, with the totally LOGged version it doesn't stop. I think I unintentionnaly stopped it when I took a screenshot.
EDIT 2 : I correct again, with the totally LOGged version, it stops whenever it wants ! ^^


I don't really understand, but maybe you can log the variables in that function so we can get a clearer idea of what it is doing?
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #191 on: August 02, 2016, 06:01:34 PM »
Quote from: chris;812004
I don't really understand, but maybe you can log the variables in that function so we can get a clearer idea of what it is doing?
I can give a try, we don't ever know. ^^ How do I do with LOG to display a variable ?
 

Offline chris

Re: duktape error NetSurf OS3
« Reply #192 on: August 02, 2016, 06:24:03 PM »
Quote from: DNADNL;812005
I can give a try, we don't ever know. ^^ How do I do with LOG to display a variable ?


Same as printf, eg:
LOG("Var: %d, String: %s, Ptr: %p", var, string, ptr);
The %d might need to be %ld.  It's usually worth just using %ld anyway, although gcc tends to complain about it.
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar picture is Tabitha by Eric W Schwartz
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #193 on: August 02, 2016, 07:50:14 PM »
Quote from: chris;812007
Same as printf, eg:
LOG("Var: %d, String: %s, Ptr: %p", var, string, ptr);
The %d might need to be %ld.  It's usually worth just using %ld anyway, although gcc tends to complain about it.
OK, well, maybe the issue isn't in a loop. I was happy too fast ! ^^
Here is the last command before the FATAL 56 :
Code: [Select]
duk_eval_string(ctx, (const char *) duk_initjs_data);  /* initjs data is NUL terminated */
EDIT :
Either the Issue is coming from there :
duktape.h :
#define duk_eval_string(ctx,src)  \
   ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))

OR from there : duktape.c : (const char *) duk_initjs_data. (a data table)

OR from the variable ctx, but I don't think so...

EDIT 2 : I wonder if the issue doesn't come from the conversion of duk_initjs_data, so from (const char *) duk_initjs_data... what do you think about it ?

EDIT 3 : Here is the code leading to the issue :
Code: [Select]
(762.335685) duk_hthread_builtins.c:911 duk_hthread_create_builtin_objects: BIG duk_hthread_create_builtin_objects() : duk_push_string(ctx, many letters, ...)
(762.380520) duk_hthread_builtins.c:1017 duk_hthread_create_builtin_objects: BIG duk_hthread_create_builtin_objects() : duk_xdef_prop_stridx(ctx, DUK_BIDX_DUKTAPE, DUK_STRIDX_ENV, DUK_PROPDESC_FLAGS_WC);
(762.428497) duk_hthread_builtins.c:1028 duk_hthread_create_builtin_objects: BIG duk_hthread_create_builtin_objects() : DUK_DD(DUK_DDPRINT(running built-in initjs));
(762.473715) duk_hthread_builtins.c:1030 duk_hthread_create_builtin_objects: BIG duk_hthread_create_builtin_objects() : duk_eval_string(ctx, (const char *) duk_initjs_data);
(762.518614) duk_hthread_builtins.c:1031 duk_hthread_create_builtin_objects: BIG duk_hthread_create_builtin_objects() : ctx = 298973952
FATAL 56: uncaught error
PANIC 56: uncaught error (calling abort)
Abnormal program termination
NetSurf : erreur code 20

EDIT 4 : It's in here : rc = duk_compile_raw(ctx, src_buffer, src_length, comp_flags); In duktape.c (I think I won't finish to follow the tracks today ! XD)

EDIT 5 : Now, it's in there : DUK_LOCAL duk_ret_t duk__do_compile(duk_context *ctx)

EDIT 6 : Just a question about this part of code :
Code: [Select]
if (flags & DUK_COMPILE_NOSOURCE) {
;
} else {
duk_remove(ctx, -2);
}
Why is there only a semi-colon in the if ? I wonder if the if souldn't be like this :
Code: [Select]
if !flags || !DUK_COMPILE_NOSOURCE) {
duk_remove(ctx, -2);
}

EDIT 7 : coming from here : duk_js_compile(thr, comp_args->src_buffer, comp_args->src_length, comp_flags);
... Where will it stop ?
« Last Edit: August 02, 2016, 10:58:34 PM by DNADNL »
 

Offline DNADNL

  • Jr. Member
  • **
  • Join Date: Jun 2016
  • Posts: 87
    • Show only replies by DNADNL
Re: duktape error NetSurf OS3
« Reply #194 on: August 03, 2016, 06:59:28 PM »
OK, I go on LOGging everything, but I can see I'm LOGging the error functions. So, I think I've put tracks on the way to obtain the issue. Here is the code :
Code: [Select]
(525.303815) duk_js_compiler.c:7791 duk_js_compile: duk_js_compile() : comp_stk.comp_ctx_alloc.lex.input_length = src_length;
(525.341080) duk_js_compiler.c:7794 duk_js_compile: duk_js_compile() : duk_push_pointer(ctx, (void *) &comp_stk);
(525.377255) duk_js_compiler.c:7799 duk_js_compile: duk_js_compile() : prev_ctx = thr->compile_ctx;
(525.413752) duk_js_compiler.c:7801 duk_js_compile: duk_js_compile() : thr->compile_ctx = &comp_stk.comp_ctx_alloc;
(525.449799) duk_js_compiler.c:7803 duk_js_compile: duk_js_compile() : safe_rc = duk_safe_call(ctx, duk__js_compile_raw, 2 /*nargs*/, 1 /*nret*/);
(525.504379) duk_error_longjmp.c:9 duk_err_longjmp: duk_err_longjmp() BEGIN
(525.549729) duk_error_longjmp.c:10 duk_err_longjmp: duk_err_longjmp() : DUK_ASSERT(thr != NULL);
(525.584814) duk_error_longjmp.c:13 duk_err_longjmp: duk_err_longjmp() : DUK_DD(DUK_DDPRINT(longjmp error: type=290914608 iserror=315533536 value1=!T value2=!T, (int) thr->heap->lj.type, (int) thr->heap->lj.iserror, &thr->heap->lj.value1, &thr->heap->lj.value2));
(525.643888) duk_error_longjmp.c:27 duk_err_longjmp: duk_err_longjmp() : if (!thr->heap->lj.jmpbuf_ptr) BEGIN
(525.679870) duk_error_longjmp.c:40 duk_err_longjmp: duk_err_longjmp() : if (!thr->heap->lj.jmpbuf_ptr) END
(525.714571) duk_error_longjmp.c:51 duk_err_longjmp: duk_err_longjmp() : DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb);
(525.750039) duk_js_compiler.c:7805 duk_js_compile: duk_js_compile() : thr->compile_ctx = prev_ctx;
(525.784035) duk_js_compiler.c:7808 duk_js_compile: duk_js_compile() : if (safe_rc != DUK_EXEC_SUCCESS) BEGIN
(525.817388) duk_js_compiler.c:7810 duk_js_compile: duk_js_compile() : if (safe_rc != DUK_EXEC_SUCCESS) : duk_throw(ctx);
(525.852152) duk_api_stack.c:4309 duk_throw: duk_throw() BEGIN
(525.880117) duk_api_stack.c:4310 duk_throw: duk_throw() : duk_hthread *thr = (duk_hthread *) ctx;
(525.911546) duk_api_stack.c:4313 duk_throw: duk_throw() : DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
(525.944771) duk_api_stack.c:4315 duk_throw: duk_throw() : DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);
(525.977932) duk_api_stack.c:4317 duk_throw: duk_throw() : DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
(526.009874) duk_api_stack.c:4320 duk_throw: duk_throw() : if (thr->valstack_top == thr->valstack_bottom) BEGIN
(526.044699) duk_api_stack.c:4325 duk_throw: duk_throw() : if (thr->valstack_top == thr->valstack_bottom) END
(526.078504) duk_api_stack.c:4336 duk_throw: duk_throw() : duk_hthread_sync_and_null_currpc(thr);
(526.110254) duk_api_stack.c:4340 duk_throw: duk_throw() : DUK_DDD(DUK_DDDPRINT(THROW ERROR (API): !dT (before throw augment), (duk_tval *) duk_get_tval(ctx, -1)));
(526.147969) duk_api_stack.c:4342 duk_throw: duk_throw() : duk_err_augment_error_throw(thr);
(526.182220) duk_api_stack.c:4345 duk_throw: duk_throw() : DUK_DDD(DUK_DDDPRINT(THROW ERROR (API): !dT (after throw augment), (duk_tval *) duk_get_tval(ctx, -1)));
(526.219230) duk_api_stack.c:4348 duk_throw: duk_throw() : duk_err_setup_heap_ljstate(thr, DUK_LJ_TYPE_THROW);
(526.253096) duk_api_stack.c:4356 duk_throw: duk_throw() : duk_err_longjmp(thr);
(526.283755) duk_error_longjmp.c:9 duk_err_longjmp: duk_err_longjmp() BEGIN
(526.312810) duk_error_longjmp.c:10 duk_err_longjmp: duk_err_longjmp() : DUK_ASSERT(thr != NULL);
(526.344496) duk_error_longjmp.c:13 duk_err_longjmp: duk_err_longjmp() : DUK_DD(DUK_DDPRINT(longjmp error: type=290914608 iserror=315598072 value1=!T value2=!T, (int) thr->heap->lj.type, (int) thr->heap->lj.iserror, &thr->heap->lj.value1, &thr->heap->lj.value2));
(526.397541) duk_error_longjmp.c:27 duk_err_longjmp: duk_err_longjmp() : if (!thr->heap->lj.jmpbuf_ptr) BEGIN
(526.433121) duk_error_longjmp.c:30 duk_err_longjmp: duk_err_longjmp() : if (!thr->heap->lj.jmpbuf_ptr) : DUK_D(DUK_DPRINT(uncaught error: type=290914608 iserror=315598072 value1=!T value2=!T, (int) thr->heap->lj.type, (int) thr->heap->lj.iserror, &thr->heap->lj.value1,
 &thr->heap->lj.value2));
(526.505425) duk_error_longjmp.c:35 duk_err_longjmp: duk_err_longjmp() : if (!thr->heap->lj.jmpbuf_ptr) : duk_fatal((duk_context *) thr, DUK_ERR_UNCAUGHT_ERROR, uncaught error);
FATAL 56: uncaught error
PANIC 56: uncaught error (calling abort)
Abnormal program termination
NetSurf : erreur code 20

So that could mean either the problem comes from
duk_js_compile() : safe_rc = duk_safe_call(ctx, duk__js_compile_raw, 2 /*nargs*/, 1 /*nret*/);
OR from
duk_js_compile() : if (safe_rc != DUK_EXEC_SUCCESS) : duk_throw(ctx);

But now I don't know how to be sure about that...

EDIT : I can't go further for the LOGs, so I think the Issue is there.
« Last Edit: August 03, 2016, 07:11:11 PM by DNADNL »