golang: runtime error: invalid memory address or nil pointer dereference - go

I am new to golang and currently following this tutorial and source code here - http://golang.org/doc/articles/wiki/part2.go
After building this file, I am getting
calvin$ ./mywebwiki2
2012/07/23 17:12:59 http: panic serving [::1]:58820: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/pkg/net/http/server.go:576 (0x3f202)
_func_003: buf.Write(debug.Stack())
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:1443 (0x10c79)
/private/tmp/bindist454984655/go/src/pkg/runtime/runtime.c:128 (0x11745)
/private/tmp/bindist454984655/go/src/pkg/runtime/thread_darwin.c:418 (0x148b5)
/Users/calvin/work/gowiki/mywebwiki2.go:33 (0x2248)
viewHandler: fmt.Fprintf(w, "<h1>%s</h1><div>%s</div>", p.Title, p.Body)
/usr/local/go/src/pkg/net/http/server.go:690 (0x331ae)
HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/pkg/net/http/server.go:926 (0x34030)
(*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
/usr/local/go/src/pkg/net/http/server.go:656 (0x32fc1)
(*conn).serve: handler.ServeHTTP(w, w.req)
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:271 (0xed7f)
2012/07/23 17:12:59 http: panic serving [::1]:58821: runtime error: invalid memory address or nil pointer dereference
Any idea what I did wrong to be causing this apparent memory corruption?

There's an ignored err at line 36. The error probably says open .txt: no such file or directory if you tested in browser using URL http://localhost:8080/view/ or open foo.txt: no such file or directory if you tested in browser using URL http://localhost:8080/view/foo. In the later case there must be a file "foo.txt" in your working directory for this example code to work. After that the code seems to work for me locally.
Someone should probably fill an issue about the ignored error value.

In the tutorial, you created the file TestPage previously. Which is the page you should be navigating to when you first build the server. In the tutorial, they have you navigate to view/test instead of view/TestPage as you should which is what creates the confusion.

Related

Handling error while connecting to kubernetes server using config file

I intentionally broke my .config file which is responsible for connecting to kubernetes server by changing the content in the user section and I am getting this error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45756e]
goroutine 1 [running]:
k8s.io/client-go/kubernetes.NewForConfig(0x0, 0x0, 0xc42031c120, 0x1c)
/home/saivamsi/go/src/k8s.io/client-go/kubernetes/clientset.go:371 +0x4e
exit status 2
I was doing this to test what happens if somehow invalid config was supplied so I want to handle this error by retrying to connect to server for next 5sec to see if it. How can I achieve this?
I am using kubernetes go client with this code to make the connection:
var KubeConfigPath = os.Getenv("HOME") + "/.kube/config2"
var config, ConfigErr = clientcmd.BuildConfigFromFlags("", KubeConfigPath)
var clientset, ClientErr = kubernetes.NewForConfig(config)
You can likely avoid the segfault if you check that the error from BuildConfigFromFlags is not nil. If it is nil then sleep and retry, otherwise continue.

Magento 1 Embedded ERP Removed but AdvancedStock still called

I attempted to remove the Embedded ERP from my website. Everything worked smoothly except som SQL stuff. But when a customer attempts to add an item to their cart, the flash loads forever and the System.log throws the following.
ERR (3): Warning: include(Mage/AdvancedStock/Helper/Product/Base.php):
failed to open stream: No such file or directory in
/var/www/phono.dk/public_html/subdomains/dev/lib/Varien/Autoload.php
on line 94 ERR (3): Warning:
include(Mage/AdvancedStock/Helper/Product/Base.php): failed to open
stream: No such file or directory in
/var/www/phono.dk/public_html/subdomains/dev/lib/Varien/Autoload.php
on line 94 ERR (3): Warning: include(): Failed opening
'Mage/AdvancedStock/Helper/Product/Base.php' for inclusion
(include_path='/var/www/phono.dk/public_html/subdomains/dev/app/code/local:/var/www/phono.dk/public_html/subdomains/dev/app/code/community:/var/www/phono.dk/public_html/subdomains/dev/app/code/core:/var/www/phono.dk/public_html/subdomains/dev/lib:.:/usr/share/php:/usr/share/pear')
in
/var/www/phono.dk/public_html/subdomains/dev/lib/Varien/Autoload.php
on line 94
I have no idea what's still calling for AdvancedStock, but whatever does it shouldn't. Any suggestions as to what that might be?

Go compile error?

I'm trying to compile a fork of cuttle that merges this pull request
by running
# GOPATH=`pwd` /usr/local/go/bin/go get github.com/andresdouglas/cuttle
# github.com/andresdouglas/cuttle
src/github.com/andresdouglas/cuttle/main.go:103: zone.GetController(r.URL.Host, r.URL.Path).Acquire() used as value
Here is the offending line
I have no experience with Go. Is that an error? It doesn't seem to update the compiled binary.
Check the source code here:
// Acquire permission from NoopControl.
// Permission is granted immediately since it does not perform any rate limit.
func (c *NoopControl) Acquire() {
log.Debugf("NoopControl[%s]: Seeking permission.", c.Label)
log.Debugf("NoopControl[%s]: Granted permission.", c.Label)
}
There is NO return value of func (c *NoopControl) Acquire().

Parse deploy command error x509

On parse deploy command I get this error, how can I solve it?
x509: failed to load system roots and no roots provided.
/home/travis/gopath/src/github.com/ParsePlatform/parse-cli/main.go:143 checkIfSupported
/home/travis/gopath/src/github.com/ParsePlatform/parse-cli/main.go:101 main
/home/travis/.gimme/versions/go1.4.2.linux.amd64/src/runtime/proc.go:72 main
/home/travis/.gimme/versions/go1.4.2.linux.amd64/src/runtime/asm_386.s:2288 goexit
(OS Ubuntu 14.04 LTS 64)
UPDATE
Now sometimes, one in ten attempts, it requests email and password. But, after input password, I get:
panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x1 pc=0x8097025]
I solved executing an update-ca-certificates command. I think that certificates were broken and it stopped to work, but I dont know why.

After porting some php and web app related files from my friend's windows computer to my mac I'm getting some errors

This is for a facebook app being run on heroku, but heroku is probably not the issue. The issue is either some kind of cache related thing, os porting, or I'm thinking it might be a carriage return issue.
In any case I'm getting a couple errors at the top and bottom respectively:
Warning: Unknown:
Warning: session_start(): open(C:\ProgramData\Jcx.Software\VS.Php\2.10.6970.0\temp/sess_i4ood4poc11ebsgth000g1nm74, O_RDWR) failed: No such file or directory (2) in /app/www/sdk/src/facebook.php on line 37
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /app/www/sdk/src/facebook.php:37) in /app/www/sdk/src/facebook.php on line 37
open(C:\ProgramData\Jcx.Software\VS.Php\2.10.6970.0\temp/sess_i4ood4poc11ebsgth000g1nm74, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\ProgramData\Jcx.Software\VS.Php\2.10.6970.0\temp) in Unknown on line 0
Essentially I have tried the whole "making sure session is at the top thing," but I don't have that session piece of code in any of the files. I have tried the whole making sure "?>" is on a new line as well to no effect.
update
I have discovered something called:
zend_extension_ts="C:\Program Files (x86)\Jcx.Software\VS.Php\2010\php 5.2\ext\php_xdebug.dll"
within a file called php.ini which even after I tried to get rid of didn't seem to change anything. So, I'm thinking this has something to do with some previous files that I pushed and then removed with extensions like puo, intellisense.cache, projphp, etc.
I don't know if those are auto-generated or not, but in any case according to my errors:
There is some session data in a file called temp. I have no file named temp.
zend_extension_ts supposedly gets referenced somewhere, but it isn't visible in my code.
I apparently need to resend session cache limiter again through session_start() which is not visible in my code.
Is not the session , I'm sure. But there is directory path included in your code but that directory does not exist! Just refactor that part of the code first!
As a tip you should use realpath() and check if path exist before attempting to use it.
Hope this helps!

Resources