Code comments can be helpful with unusual situations like this.

-rob


On Fri, Jun 16, 2017 at 4:25 AM, Goodwin Lawlor <goodwin.law...@gmail.com>
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" <i...@golang.org> wrote:
>
>> On Thu, Jun 15, 2017 at 10:28 AM, Tyler Compton <xavi...@gmail.com>
>> 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 <ald...@leal.eng.br> wrote:
>> >>
>> >> Force a panic in case exit fails?
>> >>
>> >> --
>> >> -- Aldrin Leal, <ald...@leal.eng.br> / http://about.me/aldrinleal
>> >>
>> >> On Thu, Jun 15, 2017 at 4:54 AM, <goodwin.law...@gmail.com> 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.

Reply via email to