Re: [AOLSERVER] Segmentation fault

2002-01-18 Thread Jeff Rogers

On Thu, 17 Jan 2002 13:15:51 -0600, Rob Mayoff [EMAIL PROTECTED] wrote:

+-- On Jan 17, Daniel P. Stasinski said:
 My second suggestion was meant as humor.  The reason that your
 server crashes is because your code is flawed.

Obviously his infinite-recursion example will always fail in some way.
But his real code might not recurse infinitely.  It might simply need to
recurse to a greater depth than the default stack size allows.  In that
case, increase the stack size is the correct solution.

The infinite-recursing code as originally written should work, because catch
is supposed to catch errors.  And if you run tclsh and try the code, it does
the right thing, which is to generate a tcl exception when the recursion
goes too deep (which is 1000 levels by default).

The problem is really a configuration bug in AOLserver, where the default
stacksize is not enough to accomodate the max size of the tcl stack.

Two possible fixes:  set the default tcl recursion limit lower, or patch the
code so that TclpCheckStackSpace() calls NsTclCheckStackSpace(), which is
there for exactly this problem.  This is done in in the tcl7.6 core, but not
8.x as its just the basic tcl distrib unpatched.

-J



Re: [AOLSERVER] Segmentation fault

2002-01-17 Thread Chiriac Petrica Clement

Thanks for the help, Daniel .
I put

  ns_param   stacksize  [expr 128*1024*16]

and works.

Daniel P. Stasinski wrote:

 The only two solutions i see so far is maybe:

 proc x {} {
 puts [info level]
 if  { [catch {  x  }] } {
 return
 }
 }

 Or, there is always...

   ns_section ns/threads
   ns_param   stacksize \
 1
 0
 0
 0
 0 :)

 Daniel P. Stasinski
 Software Engineer
 Mayor Pharmaceutical Laboratories
 [EMAIL PROTECTED]

--
Petrica



Re: [AOLSERVER] Segmentation fault

2002-01-17 Thread Daniel P. Stasinski

My second suggestion was meant as humor.  The reason that your
server crashes is because your code is flawed.  Either there is
something you are not telling us or you don't have a firm
understanding of procedural programming concepts.

Daniel P. Stasinski
Software Engineer
Mayor Pharmaceutical Laboratories
[EMAIL PROTECTED]

- Original Message -
From: Chiriac Petrica Clement [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 17, 2002 3:52 AM
Subject: Re: [AOLSERVER] Segmentation fault


Thanks for the help, Daniel .
I put

  ns_param   stacksize  [expr 128*1024*16]

and works.



Re: [AOLSERVER] Segmentation fault

2002-01-17 Thread Rob Mayoff

+-- On Jan 17, Daniel P. Stasinski said:
 My second suggestion was meant as humor.  The reason that your
 server crashes is because your code is flawed.

Obviously his infinite-recursion example will always fail in some way.
But his real code might not recurse infinitely.  It might simply need to
recurse to a greater depth than the default stack size allows.  In that
case, increase the stack size is the correct solution.



[AOLSERVER] Segmentation fault

2002-01-16 Thread Chiriac Petrica Clement

 This code produce Segmentation fault

 proc x {} {
puts [info level]
catch {
  x
}
 }

 In log :
1
2
3
4
...
48
49
50
51
Segmentation fault


 Who can help me ?
 Is urgent.

--
Petrica Clement Chiriac



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Peter M. Jansson

Don't do that!  You have an infinite recursion here.  You need to include
some condition in the code which will stop the recursive calls to x at
some point (preferably before 50 levels of recursion).

On 1/16/02 12:08 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

 This code produce Segmentation fault

 proc x {} {
   puts [info level]
   catch {
 x
   }
 }



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Chiriac Petrica Clement

  My code is an example for real problem.

  How can change this value 50 ?
  Why produce Segmentation fault ?

Peter M. Jansson wrote:

 Don't do that!  You have an infinite recursion here.  You need to include
 some condition in the code which will stop the recursive calls to x at
 some point (preferably before 50 levels of recursion).

 On 1/16/02 12:08 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

  This code produce Segmentation fault
 
  proc x {} {
puts [info level]
catch {
  x
}
  }

--
Petrica Clement Chiriac



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Peter M. Jansson

Your code doesn't do any work -- it's the same as:

proc x {} {
set somevalue 1
while 1 {
puts $somevalue
incr somevalue
}
}

Except that my version won't consume the stack until the process breaks.  It
still doesn't do any work!  (You get the segmentation fault because your
proc eventually consumes all available stack.  If you were to try to
increase the stack, it wouldn't matter, because this function will consume
*all* stack, no matter how much you give it -- it's a seriously and
obviously flawed piece of code.)

You really need to tell us more about what you're trying to do.  You've
abstracted away too much in your sample code.

On 1/16/02 12:28 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

 My code is an example for real problem.

 How can change this value 50 ?
 Why produce Segmentation fault ?

 Peter M. Jansson wrote:

 Don't do that!  You have an infinite recursion here.  You need to include
 some condition in the code which will stop the recursive calls to x at
 some point (preferably before 50 levels of recursion).

 On 1/16/02 12:08 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

 This code produce Segmentation fault

 proc x {} {
   puts [info level]
   catch {
 x
   }
 }



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Chiriac Petrica Clement

  My OS is RedHat 7.2.

  Under RedHat 6.2 work best !

Petrica.



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Peter M. Jansson

Infinite loops are platform independent.  Your code has an infinite loop.
What are you trying to do?

On 1/16/02 12:38 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

 My OS is RedHat 7.2.

 Under RedHat 6.2 work best !



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Chiriac Petrica Clement

I have a template mechanism for generate html static pages.
I can't detect where is Segmentation fault.


Peter M. Jansson wrote:

 Infinite loops are platform independent.  Your code has an infinite loop.
 What are you trying to do?

 On 1/16/02 12:38 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

  My OS is RedHat 7.2.
 
  Under RedHat 6.2 work best !

--
Petrica Clement Chiriac



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Peter M. Jansson

Do you think the proc you previously sent is an example of the problem, or
is it just something else that generates a segmentation fault?  The code you
previously sent has the error I've mentioned, which will cause a
segmentation fault.  If you have a similar piece of code, you need to fix it
in a similar way.

If you're getting a segmentation, and the only reason you sent the previous
code is because it is the only thing you could find that also generates the
segmentation fault, then you have a different problem.  You need to sprinkle
ns_log statements through your code to generate log information that tells
you what your code is doing, and figure out what is broken from there.

On 1/16/02 12:53 PM, Chiriac Petrica Clement [EMAIL PROTECTED] wrote:

 I have a template mechanism for generate html static pages.
 I can't detect where is Segmentation fault.



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Daniel P. Stasinski

The only two solutions i see so far is maybe:

proc x {} {
puts [info level]
if  { [catch {  x  }] } {
return
}
}

Or, there is always...

  ns_section ns/threads
  ns_param   stacksize \
1
0
0
0
0 :)

Daniel P. Stasinski
Software Engineer
Mayor Pharmaceutical Laboratories
[EMAIL PROTECTED]



Re: [AOLSERVER] Segmentation fault

2002-01-16 Thread Patrick Spence

In 006801c19eb0$3684f380$[EMAIL PROTECTED], on 01/16/02
   at 10:07 AM, Daniel P. Stasinski [EMAIL PROTECTED] said:

The only two solutions i see so far is maybe:

proc x {} {
puts [info level]
if  { [catch {  x  }] } {
return
}
}

Or, there is always...

  ns_section ns/threads
  ns_param   stacksize \
1
0
0
0
0 :)

It crashed on the colon parens token..  maybe the colon parens token needs
to be first?  or maybe its the more obscure semi-colon parens token on
that line?  ;)




Patrick Spence [EMAIL PROTECTED]