Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-20 Thread Tyler Compton
Sent in a CL for some documentation on this.

https://github.com/golang/go/issues/20717
https://go-review.googlesource.com/#/c/46212/


On Mon, Jun 19, 2017 at 10:56 AM  wrote:

> It won't blank as much as it can get it's hands on. The default value for
> the pointer will be nil so it will try and assign (causing a panic()
> hopefully) to force an exit
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-19 Thread n . s . glynn
It won't blank as much as it can get it's hands on. The default value for the 
pointer will be nil so it will try and assign (causing a panic() hopefully) to 
force an exit

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-19 Thread 'Thomas Bushnell, BSG' via golang-nuts
Something similar at
https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/abort.c;h=19882f3e3dc1ab830431506329c94dcf1d7cc252;hb=HEAD#l138
in
the GNU C library. Sometimes you just need to be absolutely certain that a
function doesn't return.

On Thu, Jun 15, 2017 at 2:16 PM Rob Pike  wrote:

> Code comments can be helpful with unusual situations like this.
>
> -rob
>
>
> On Fri, Jun 16, 2017 at 4:25 AM, Goodwin Lawlor 
> wrote:
>
>> Thanks for the explanation.
>>
>> My random guess was that it's the compiler version of deleting your
>> browser cache... If exit fails, blank as much memory as we can get our
>> hands on. 
>>
>> On 15 Jun 2017 6:34 pm, "Ian Lance Taylor"  wrote:
>>
>>> On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton 
>>> wrote:
>>> > Why not just panic, though? And why the infinite loop, I wonder?
>>>
>>> The runtime is a special case in many ways, and this is among the more
>>> special parts.  This loop exists to catch problems while testing new
>>> ports.  If that loop is ever reached, something has gone badly wrong:
>>> the exit call should have caused the program to exit.  We can't assume
>>> that panic is working.  We can't really assume that anything is
>>> working.  What we want to do is stop the program.  Since exit failed,
>>> it's possible that a nil dereference will succeed.  If that fails too,
>>> we still have to do something, so we just loop.  We can't return
>>> because this is the main function that started the program; there is
>>> nothing to return to.
>>>
>>> Ian
>>>
>>> > On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal 
>>> wrote:
>>> >>
>>> >> Force a panic in case exit fails?
>>> >>
>>> >> --
>>> >> -- Aldrin Leal,  / http://about.me/aldrinleal
>>> >>
>>> >> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
>>> >>>
>>> >>> Hey,
>>> >>>
>>> >>> Learning golang at the moment and came across this at the end of func
>>> >>> main() in proc.go in the golang source tree.
>>> >>>
>>> >>> exit(0)
>>> >>> for {
>>> >>> var x *int32
>>> >>> *x = 0
>>> >>> }
>>> >>>
>>> >>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>>> >>>
>>> >>> How is the for loop ever reached and what's the purpose of the
>>> infinite
>>> >>> loop, zeroing memory?
>>> >>>
>>> >>> Thanks,
>>> >>>
>>> >>> Goodwin
>>> >>>
>>> >>> --
>>> >>> You received this message because you are subscribed to the Google
>>> Groups
>>> >>> "golang-nuts" group.
>>> >>> To unsubscribe from this group and stop receiving emails from it,
>>> send an
>>> >>> email to golang-nuts+unsubscr...@googlegroups.com.
>>> >>> For more options, visit https://groups.google.com/d/optout.
>>> >>
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "golang-nuts" group.
>>> >> To unsubscribe from this group and stop receiving emails from it,
>>> send an
>>> >> email to golang-nuts+unsubscr...@googlegroups.com.
>>> >> For more options, visit https://groups.google.com/d/optout.
>>> >
>>> > --
>>> > Tyler Compton
>>> > Software Engineering
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "golang-nuts" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> > email to golang-nuts+unsubscr...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Rob Pike
Code comments can be helpful with unusual situations like this.

-rob


On Fri, Jun 16, 2017 at 4:25 AM, Goodwin Lawlor 
wrote:

> Thanks for the explanation.
>
> My random guess was that it's the compiler version of deleting your
> browser cache... If exit fails, blank as much memory as we can get our
> hands on. 
>
> On 15 Jun 2017 6:34 pm, "Ian Lance Taylor"  wrote:
>
>> On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton 
>> wrote:
>> > Why not just panic, though? And why the infinite loop, I wonder?
>>
>> The runtime is a special case in many ways, and this is among the more
>> special parts.  This loop exists to catch problems while testing new
>> ports.  If that loop is ever reached, something has gone badly wrong:
>> the exit call should have caused the program to exit.  We can't assume
>> that panic is working.  We can't really assume that anything is
>> working.  What we want to do is stop the program.  Since exit failed,
>> it's possible that a nil dereference will succeed.  If that fails too,
>> we still have to do something, so we just loop.  We can't return
>> because this is the main function that started the program; there is
>> nothing to return to.
>>
>> Ian
>>
>> > On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:
>> >>
>> >> Force a panic in case exit fails?
>> >>
>> >> --
>> >> -- Aldrin Leal,  / http://about.me/aldrinleal
>> >>
>> >> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
>> >>>
>> >>> Hey,
>> >>>
>> >>> Learning golang at the moment and came across this at the end of func
>> >>> main() in proc.go in the golang source tree.
>> >>>
>> >>> exit(0)
>> >>> for {
>> >>> var x *int32
>> >>> *x = 0
>> >>> }
>> >>>
>> >>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>> >>>
>> >>> How is the for loop ever reached and what's the purpose of the
>> infinite
>> >>> loop, zeroing memory?
>> >>>
>> >>> Thanks,
>> >>>
>> >>> Goodwin
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> Groups
>> >>> "golang-nuts" group.
>> >>> To unsubscribe from this group and stop receiving emails from it,
>> send an
>> >>> email to golang-nuts+unsubscr...@googlegroups.com.
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "golang-nuts" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> an
>> >> email to golang-nuts+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > Tyler Compton
>> > Software Engineering
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to golang-nuts+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Goodwin Lawlor
Thanks for the explanation.

My random guess was that it's the compiler version of deleting your browser
cache... If exit fails, blank as much memory as we can get our hands on. 

On 15 Jun 2017 6:34 pm, "Ian Lance Taylor"  wrote:

> On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton  wrote:
> > Why not just panic, though? And why the infinite loop, I wonder?
>
> The runtime is a special case in many ways, and this is among the more
> special parts.  This loop exists to catch problems while testing new
> ports.  If that loop is ever reached, something has gone badly wrong:
> the exit call should have caused the program to exit.  We can't assume
> that panic is working.  We can't really assume that anything is
> working.  What we want to do is stop the program.  Since exit failed,
> it's possible that a nil dereference will succeed.  If that fails too,
> we still have to do something, so we just loop.  We can't return
> because this is the main function that started the program; there is
> nothing to return to.
>
> Ian
>
> > On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:
> >>
> >> Force a panic in case exit fails?
> >>
> >> --
> >> -- Aldrin Leal,  / http://about.me/aldrinleal
> >>
> >> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
> >>>
> >>> Hey,
> >>>
> >>> Learning golang at the moment and came across this at the end of func
> >>> main() in proc.go in the golang source tree.
> >>>
> >>> exit(0)
> >>> for {
> >>> var x *int32
> >>> *x = 0
> >>> }
> >>>
> >>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
> >>>
> >>> How is the for loop ever reached and what's the purpose of the infinite
> >>> loop, zeroing memory?
> >>>
> >>> Thanks,
> >>>
> >>> Goodwin
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "golang-nuts" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to golang-nuts+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "golang-nuts" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to golang-nuts+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > Tyler Compton
> > Software Engineering
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to golang-nuts+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Tyler Compton
Very interesting. I'm not used to looking at Go code from the perspective
of an implementer of Go.

Somebody should contribute a comment about this upstream :)

On Thu, Jun 15, 2017 at 10:34 AM Ian Lance Taylor  wrote:

> On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton  wrote:
> > Why not just panic, though? And why the infinite loop, I wonder?
>
> The runtime is a special case in many ways, and this is among the more
> special parts.  This loop exists to catch problems while testing new
> ports.  If that loop is ever reached, something has gone badly wrong:
> the exit call should have caused the program to exit.  We can't assume
> that panic is working.  We can't really assume that anything is
> working.  What we want to do is stop the program.  Since exit failed,
> it's possible that a nil dereference will succeed.  If that fails too,
> we still have to do something, so we just loop.  We can't return
> because this is the main function that started the program; there is
> nothing to return to.
>
> Ian
>
> > On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:
> >>
> >> Force a panic in case exit fails?
> >>
> >> --
> >> -- Aldrin Leal,  / http://about.me/aldrinleal
> >>
> >> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
> >>>
> >>> Hey,
> >>>
> >>> Learning golang at the moment and came across this at the end of func
> >>> main() in proc.go in the golang source tree.
> >>>
> >>> exit(0)
> >>> for {
> >>> var x *int32
> >>> *x = 0
> >>> }
> >>>
> >>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
> >>>
> >>> How is the for loop ever reached and what's the purpose of the infinite
> >>> loop, zeroing memory?
> >>>
> >>> Thanks,
> >>>
> >>> Goodwin
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "golang-nuts" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to golang-nuts+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "golang-nuts" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to golang-nuts+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > Tyler Compton
> > Software Engineering
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to golang-nuts+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
-- 
Tyler Compton
Software Engineering

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Ian Lance Taylor
On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton  wrote:
> Why not just panic, though? And why the infinite loop, I wonder?

The runtime is a special case in many ways, and this is among the more
special parts.  This loop exists to catch problems while testing new
ports.  If that loop is ever reached, something has gone badly wrong:
the exit call should have caused the program to exit.  We can't assume
that panic is working.  We can't really assume that anything is
working.  What we want to do is stop the program.  Since exit failed,
it's possible that a nil dereference will succeed.  If that fails too,
we still have to do something, so we just loop.  We can't return
because this is the main function that started the program; there is
nothing to return to.

Ian

> On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:
>>
>> Force a panic in case exit fails?
>>
>> --
>> -- Aldrin Leal,  / http://about.me/aldrinleal
>>
>> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
>>>
>>> Hey,
>>>
>>> Learning golang at the moment and came across this at the end of func
>>> main() in proc.go in the golang source tree.
>>>
>>> exit(0)
>>> for {
>>> var x *int32
>>> *x = 0
>>> }
>>>
>>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>>>
>>> How is the for loop ever reached and what's the purpose of the infinite
>>> loop, zeroing memory?
>>>
>>> Thanks,
>>>
>>> Goodwin
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> Tyler Compton
> Software Engineering
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Aldrin Leal
I don't know.

On Jun 15, 2017 12:29, "Tyler Compton"  wrote:

> Why not just panic, though? And why the infinite loop, I wonder?
>
> On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:
>
>> Force a panic in case exit fails?
>>
>> --
>> -- Aldrin Leal,  / http://about.me/aldrinleal
>>
>> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
>>
>>> Hey,
>>>
>>> Learning golang at the moment and came across this at the end of func
>>> main() in proc.go in the golang source tree.
>>>
>>> exit(0)
>>> for {
>>> var x *int32
>>> *x = 0
>>> }
>>>
>>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>>>
>>> How is the for loop ever reached and what's the purpose of the infinite
>>> loop, zeroing memory?
>>>
>>> Thanks,
>>>
>>> Goodwin
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Tyler Compton
> Software Engineering
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Tyler Compton
Why not just panic, though? And why the infinite loop, I wonder?

On Thu, Jun 15, 2017 at 9:56 AM Aldrin Leal  wrote:

> Force a panic in case exit fails?
>
> --
> -- Aldrin Leal,  / http://about.me/aldrinleal
>
> On Thu, Jun 15, 2017 at 4:54 AM,  wrote:
>
>> Hey,
>>
>> Learning golang at the moment and came across this at the end of func
>> main() in proc.go in the golang source tree.
>>
>> exit(0)
>> for {
>> var x *int32
>> *x = 0
>> }
>>
>> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>>
>> How is the for loop ever reached and what's the purpose of the infinite
>> loop, zeroing memory?
>>
>> Thanks,
>>
>> Goodwin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Tyler Compton
Software Engineering

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread Aldrin Leal
Force a panic in case exit fails?

--
-- Aldrin Leal,  / http://about.me/aldrinleal

On Thu, Jun 15, 2017 at 4:54 AM,  wrote:

> Hey,
>
> Learning golang at the moment and came across this at the end of func
> main() in proc.go in the golang source tree.
>
> exit(0)
> for {
> var x *int32
> *x = 0
> }
>
> Ln 198 - 202 https://golang.org/src/runtime/proc.go
>
> How is the for loop ever reached and what's the purpose of the infinite
> loop, zeroing memory?
>
> Thanks,
>
> Goodwin
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Curious about this snippet in /src/runtime/proc.go

2017-06-15 Thread goodwin . lawlor
Hey,

Learning golang at the moment and came across this at the end of func 
main() in proc.go in the golang source tree.

exit(0)
for {
var x *int32
*x = 0
}

Ln 198 - 202 https://golang.org/src/runtime/proc.go

How is the for loop ever reached and what's the purpose of the infinite 
loop, zeroing memory?

Thanks,

Goodwin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.