Forums

StackOverflowException tip

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

StackOverflowException tip

Postby Charles » Mon Jan 27, 2014 4:10 am

Neither .NET nor Mono are very helpful if you get a StackOverflowException. Cobra's own -detailed-stack-trace option can help here. It explicitly guards against stack overflow with a lower threshold and gives you the recent stack frames when it happens.

Tonight I had a program that overflowed and all .NET told me about it was that it happened. Then I added this to the top of the code (the shorthand name of the option):
@args -dst

And got this:
Code: Select all
Cobra detected stack overflow:
  Last 20 frames:
    480. def RegExRoute.match at line 62
    481. def RegExRoute.error at line 59
    482. def RegExRoute.match at line 62
    483. def RegExRoute.error at line 59
    484. def RegExRoute.match at line 62
    485. def RegExRoute.error at line 59
    486. def RegExRoute.match at line 62
    487. def RegExRoute.error at line 59
    488. def RegExRoute.match at line 62
    489. def RegExRoute.error at line 59
    490. def RegExRoute.match at line 62
    491. def RegExRoute.error at line 59
    492. def RegExRoute.match at line 62
    493. def RegExRoute.error at line 59
    494. def RegExRoute.match at line 62
    495. def RegExRoute.error at line 59
    496. def RegExRoute.match at line 62
    497. def RegExRoute.error at line 59
    498. def RegExRoute.match at line 62
    499. def RegExRoute.error at line 58
    500. def RegExRoute.regEx.get at line 53
Fail fast: Stack Overflow

... which is all I needed to quickly fix the problem.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: StackOverflowException tip

Postby kobi7 » Thu Jan 30, 2014 10:01 am

hi Charles,
I see some nice patches in the bugs database.

Why aren't they accepted into the master branch?
is it outdated with regard to the current code base?
They have some really useful features and fixes.

honestly wanting to know,
Thanks, kobi
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: StackOverflowException tip

Postby Charles » Thu Jan 30, 2014 12:59 pm

I have a response started for you, but before I give it, please tell me: Why is your question here in the "StackOverflowException tip" thread? It's not obvious from your message:
kobi7 wrote:hi Charles,
I see some nice patches in the bugs database.

Why aren't they accepted into the master branch?
is it outdated with regard to the current code base?
They have some really useful features and fixes.

honestly wanting to know,
Thanks, kobi
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: StackOverflowException tip

Postby kobi7 » Fri Jan 31, 2014 2:34 am

well, it's just a discussion board, not a book. why the strictness?
it's just a little question. I don't know if it concerns everyone, and it's harder to contact you guys on irc. I assume different timezones.
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: StackOverflowException tip

Postby hopscc » Sat Feb 01, 2014 5:20 am

I have a similar issue with irc/timezones

Its easier/clearer for skimming/filtering/searching/future reference if each new item/question/topic is entered as a new forum topic
(also if it turns into a long interminable thread) both to allow folks to easily follow it as its being generated or to ignore it :)

Imagine trying to make sense of anything here if every forum discussion ever had was in one big gnarly indigestible (web accessible) text blob (interleaved)....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: StackOverflowException tip

Postby Charles » Sat Feb 01, 2014 7:02 pm

What hopscc said.

Please post new topics as new topics. Think of it as "modularity" for discussions. Thank you for your cooperation!
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: StackOverflowException tip

Postby kobi7 » Sun Feb 02, 2014 9:45 am

He's right, and I'm wrong
heh, thank you both. I'll try to improve my lack of patience, and follow the rules more.
I tend to go the direct route, sometimes disregarding consequences for others. which I shouldn't do.
this is actually the prevailing mentality in this country and maybe the mediterenean too, I guess I'm affected. ofcourse it's no excuse. just a cultural thing, different way of doing things, but it has its negatives too, and it manifests itself in big and smaller things..

anyway. sorry about that. I'll try to be more aware.
back to the topic, shall I start a new thread?
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: StackOverflowException tip

Postby Charles » Sun Feb 02, 2014 12:57 pm

No worries. Thanks for listening.

"Yes" to new thread.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: StackOverflowException tip

Postby thriwkin » Mon Feb 03, 2014 1:43 pm

Charles,
thanks a lot for this tip:

The "-dst" commandline option.

I am using Cobra since years, but I have completely forgotten this option,
mainly because
* it does not work if the source code contains a `struct` constructor.

But it is
* a very useful debugging aid, especially when a large program shows an endless loop.

I think,
* the option "-turbo:yes" should cause
-dst:no
in addition to
-contracts:none, -include-asserts:no, -include-nil-checks:no, -include-tests:no, -optimize:yes,
because the "-dst" option inserts a lot of code that no one wants in a RELEASE version:
- CobraCoreInternal.CobraImp.PushFrame(...);
- CobraCoreInternal.CobraImp.SetLocal(...);
- CobraCoreInternal.CobraImp.PopFrame();

Code: Select all
@args -dst
# @args -dst  -turbo     # ==> "-turbo" does not cause "-dst:no"

struct A
    var x as int

#   cue init(x as int)    # ==> 'error: The "this" object cannot be used ...'
#       .x = x

class Program
    def main is shared
        .main    # ==> endless loop, stack overflow -- catched by the "-dst" code
        print "Hello!"


In a `struct` constructor all the following features do not work properly:
- "-dst" option,
- `require`,
- `ensure`,
- `invariant`.
The reason: the inserted code calls a method with `this` as an argument,
which can be used only at the end of the constructor.
(C#: "error CS0188: The 'this' object cannot be used before all of its fields are assigned to".)
thriwkin
 
Posts: 26


Return to Discussion

Who is online

Users browsing this forum: No registered users and 102 guests

cron