Golang Revel Assertf causes panic - revel

I have created revel test suite, I use Assertf for checking an error.
t.Assertf(err == nil, "error occurred: %v", err)
It worked without any problem in my Windows and also Mac OSX. But in my remote server, Ubuntu 16.04, whenever assert error, I got error message like this.
server.go:2753: http: panic serving [::1]:44626: open /go/src/runtime/debug/stack.go: no such file or directory
goroutine 74 [running]:
net/http.(*conn).serve.func1(0xc4204a7f40)
/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0xa04ba0, 0xc4204c2f60)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/revel/revel.MustReadLines(0xc420198a4c, 0x1e, 0x1, 0xc4204d2a80, 0x3e)
/go/src/github.com/revel/revel/util.go:56 +0x168
github.com/revel/revel.NewErrorFromPanic(0xa04ba0, 0xc4204c2f00, 0x0)
/go/src/github.com/revel/revel/errors.go:63 +0x25b
github.com/revel/revel.handleInvocationPanic(0xc42024e0c0, 0xa04ba0, 0xc4204c2f00)
/go/src/github.com/revel/revel/panic.go:25 +0x4d
github.com/revel/revel.PanicFilter.func1(0xc42024e0c0)
/go/src/github.com/revel/revel/panic.go:16 +0x5c
panic(0xa04ba0, 0xc4204c2f00)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/revel/revel.InterceptorFilter.func1(0xc42024e0c0)
/go/src/github.com/revel/revel/intercept.go:97 +0x7d
panic(0xa04ba0, 0xc4204c2f00)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/revel/revel.MustReadLines(0xc42018605a, 0x1e, 0x1, 0xc420278d10, 0xad)
/go/src/github.com/revel/revel/util.go:56 +0x168
github.com/revel/revel.NewErrorFromPanic(0x9feea0, 0xc4204d8aa0, 0xc4204d8aa0)
/go/src/github.com/revel/revel/errors.go:63 +0x25b
github.com/revel/modules/testrunner/app/controllers.TestRunner.Run.func1.1(0xaa9ba0, 0xc4204c2a80, 0x16, 0xc4204d284c, 0x15, 0xc4204d2862, 0x14, 0xc4203fac78)
/go/src/github.com/revel/modules/testrunner/app/controllers/testrunner.go:113 +0x70
panic(0x9feea0, 0xc4204d8aa0)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/revel/revel/testing.(*TestSuite).Assertf(0xc4204c2a80, 0xc4203fa600, 0xac7700, 0x16, 0xc4203fa620, 0x1, 0x1)
/go/src/github.com/revel/revel/testing/testsuite.go:313 +0x87
madvrstudio/bnkjigsaw/tests.(*ReceiptValidationTest).TestValidateAppStore(0xc4204c2a80)

Assert triggers a panic, and the panic filter is failing because it cannot locate the source file of the go code that caused the error. If you have stripped away the source files from the deployment this could cause that (IMHO it really shouldn't) but looking at the code it is attempting to load up the file which the stack says has the error on it.

This is due to a bug in revel - https://github.com/revel/revel/issues/1287
The issue is that your server has GOPATH set equal to /go, and revel incorrectly identifies the first frame of the stacktrace (/usr/local/go/src/runtime/debug/stack.go:24) as being in the GOPATH because it contains /go/src. You can work around the issue by manually setting/maintaining a different GOPATH on your server that doesn't contain /go in the path anywhere. This is also an issue with the official docker containers for go found at https://hub.docker.com/_/golang/

Related

Memory failure when running gem5 SE RISCV code

When I try to run a simulation in SE mode in gem5 I get the following output:
warn: No dot file generated. Please install pydot to generate the dot file and pdf. build/RISCV/mem/mem_interface.cc:791: warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes) 0: system.remote_gdb: listening for remote gdb on port 7000 build/RISCV/sim/simulate.cc:194: info: Entering event queue # 0. Starting simulation... build/RISCV/sim/mem_state.cc:443: info: Increasing stack size by one page. build/RISCV/sim/mem_state.cc:99: panic: Someone allocated physical memory at VA 0x4000000000000000 without creating a VMA! Memory Usage: 619616 KBytes Program aborted at tick 2222000
I'm using the ELF-linux cross compiler. Compiling with the Newlib-ELF cross compiler simulates just fine, but the thing is that I need to use pthreads(openmp) and the Newlib compilation doesn't support it. To get a grip on things I tried to simulate in x86, and found out that it wont work either with a simple gnu/gcc compilation. Then I complied replicating what the test-progs folder did with docker and then it worked fine. Is this the way to go? Since the error says there are problems with physical memory, would compiling with docker help out, or am I missing an obviuos fix? How would go about compiling RISCV with docker (I couldn't find examples of docker+RISCV)?

How to recover from infinite reboot loops in NodeMCU?

My NodeMCU program has gone in to infinite reboot loop.
My code is functionally working but any action I try to do, e.g. file.remove("init.lua") or even just =node.heap(), it panics and reboots saying: PANIC: unprotected error in call to Lua API (not enough memory).
Because of this, I'm not able to change any code or delete init.lua to stop automatic code execution.
How do I recover?
I tried re-flashing another version of NodeMCU, but it started emitting garbage in serial port.
Then, I recalled that NodeMCU had two extra files: blank.bin and esp_init_data_default.bin.
I flashed them at 0x7E000 and 0x7C000 respectively.
They are also available as INTERNAL://BLANK and INTERNAL://DEFAULT in the NodeMCU flasher.
This booted the new NodeMCU firmware, all my files were gone and I'm out of infinite reboot loop.
Flash the following files:
0x00000.bin to 0x00000
0x10000.bin to 0x10000
And, the address for esp_init_data_default.bin depends on the size of your module's flash.
0x7c000 for 512 kB, modules like ESP-01, -03, -07 etc.
0xfc000 for 1 MB, modules like ESP8285, PSF-A85
0x1fc000 for 2 MB
0x3fc000 for 4 MB, modules like ESP-12E, NodeMCU devkit 1.0, WeMos D1 mini
Then, after flashing those binaries format its file system (run "file.format()" using ESPlorer) before flashing any other binaries.
Downloads Link
I've just finished working through a similar problem. In my case it was end-user error that caused a need to forcibly wipe init.lua, but I think both problems could be solved similarly. (For completeness, my problem was putting a far-too-short dsleep() call in init.lua, leaving the board resetting itself immediately upon starting init.lua.)
I tried flashing new NodeMCU firmware, writing blank.bin and esp_init_data_default.bin to 0x7E000 and 0x7C000, and also writing 0x00000.bin to 0x00000 and 0x10000.bin to 0x10000. None of these things helped in my case.
My hardware is an Adafruit Huzzah ESP8266 breakout (ESP-12), with 4MB of flash.
What worked for me was:
Download the NONOS SDK from Espressif (I used version 1.5.2 from http://bbs.espressif.com/viewtopic.php?f=46&t=1702).
Unzip it to get at boot_v1.2.bin, user1.1024.new.2.bin, blank.bin, and esp_init_data_default.bin (under bin/ and bin/at/).
Flash the following files to the specified memory locations:
boot_v1.2.bin to 0x00000
user1.1024.new.2.bin to 0x010000
esp_init_data_default.bin to 0xfc000
blank.bin to 0x7e000
Note about flashing:
I used esptool.py 1.2.1.
Because of the nature of my problem, I was only able to write changes to the flash when in programming mode (i.e. after booting with GPIO0 held down to GND).
I found that I needed to reset the board between each step (else invocations of esptool.py after the first would fail).
Erased the flash. esptool.py --port <your/port> erase_flash
Then I was able to write a new firmware. I used a stock nodeMCU 0.9.5 just to isolate variables, but I strongly suspect any firmware would work at this point.
The only think that worked for me was python flash tool esptool in ubuntu, windows flashtool never deleted init.lua and reboot loop.
Commands (ubuntu):
git clone https://github.com/themadinventor/esptool.git
cd esptool
python esptool.py -h
ls -l /dev/tty*
nodemcu_latest.bin can be downloaded from github or anywhere.
sudo python esptool.py -p /dev/ttyUSB0 --baud 460800 write_flash --flash_size=8m 0 nodemcu_latest.bin

How to setup a debuggable project, that statically links libraries?

I am working under Eclipse with gcc for bare metal ARM. The version control is SVN and the make system is make.
The project is quite large, and it would be beneficial to extract some areas into external libraries. The libraries are to be compiled, collected within an .a file, and the main project will statically link against them.
I managed to do this. The library has it's own makefile, which the project makefile calls. The linking is ok. However, I have trouble when trying to setup debugging! A "Hard fault" occurs within the CPU, and the debugger reports:
Open On-Chip Debugger 0.7.0 (2013-05-05-10:44)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
WARNING!
This file was not tested with real interface, but is assumed to work as this
interface uses the same layout as configs that were verified. Please report your
experience with this file to openocd-devel mailing list, so it could be marked
as working or fixed.
Info : only one transport option; autoselect 'jtag'
adapter speed: 500 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m3 reset_config sysresetreq
adapter speed: 3000 kHz
Info : clock speed 3000 kHz
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : sam4.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : JTAG tap: sam4.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x004000d0 msp: 0x2001fffc
force hard breakpoints
Info : accepting 'gdb' connection from 3333
Warn : acknowledgment received, but no packet pending
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0xfffffffc
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0xfffffffc
Warn : Block read error address 0xfffffff8
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0xfffffffc
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x23000052, MEM_AP_TAR 0xfffffffc
Warn : Block read error address 0xfffffff8

Core in libc.so.1

I am using Solaris 10 and my C program is getting crashed and creates a core file. On debugging, it seems like the core is created in libc.so.1. Please let me know if anyone have any clue.
Below is the dbx report.
dbx prock.new core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.6' in your .dbxrc
Reading prock.new
core file header read successfully
Reading ld.so.1
Reading libsocket.so.1
Reading libnsl.so.1
Reading libl.so.1
Reading libpthread.so.1
Reading librt.so.1
Reading libthread.so.1
Reading libc.so.1
Reading libaio.so.1
Reading libmd.so.1
Reading libc_psr.so.1
WARNING!!
A loadobject was found with an unexpected checksum value.
See `help core mismatch' for details, and run `proc -map'
to see what checksum values were expected and found.
dbx: warning: Some symbolic information might be incorrect.
t#null (l#1) terminated by signal SEGV (no mapping at the fault address)
0xffffffff7ea3bc14: strcasecmp+0x0134: orn %i0, %i3, %i0
(dbx) where
=>[1] strcasecmp(0x10014b68e, 0x57, 0x7ffffc00, 0x1001332d7, 0x27, 0x24), at 0xffffffff7ea3bc14
[2] 0x10000af48(0x27, 0x10014b68e, 0x57, 0x10014b68e, 0x57, 0x0), at 0x10000af48
[3] 0x100009c08(0x27, 0x5e, 0x0, 0x9, 0x1001332c3, 0x2b), at 0x100009c08
(dbx) whereis strcasecmp
function: `libc.so.1`strcasecmp
(dbx)
My solaris version is
Solaris 10 8/07 s10s_u4wos_12b SPARC
Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 16 August 2007
No, the problem is not with the C standard library. You're passing an invalid parameter (NULL string pointer, etc.) to strcasecmp(). Without actual code (which you haven't posted), it's not possible to deduce what exactly the error is.
(Also, you better compile your program with debug symbols - with optimization turned off! If you're on Solaris, you most probably use GCC:
gcc -O0 -g etc...
)
1) Compile your program to include debug information (add "-g" to the list of options to your compiler), so that you actually get information instead of this:
[2] 0x10000af48(0x27, 0x10014b68e, 0x57, 0x10014b68e, 0x57, 0x0), at 0x10000af48
[3] 0x100009c08(0x27, 0x5e, 0x0, 0x9, 0x1001332c3, 0x2b), at 0x100009c08
2) DBX will now tell you which of your functions has been calling strcasecmp. Step through the source (or have it generate log output), check the parameters of the fatal function call for anything out of the ordinary (like invalid pointers).
The chances of you discovering a bug in a libc function are infinitesimal compared to the chances that your call to that function was in error.
1) Run bt (backtrace) to see who is calling strcasecmp [ this will list frames like #0, #1 ]
2) Now jump in to the specific frame to get the values [ frame 0 ]
3) Then display / print the value of the argument passed to strcasecmp ( using print or display)
I feel the argument is NULL on calling strcasecmp and that's why you are getting segfault.

WinDbg issues only in Windows 7

I'm pretty new to using WinDbg, but recently my application started having issues, but only on Windows 7 machines (it runs fine the first time the PC is started but crashes or just disappears silently each time after).
I got the mdmp file, but find myself somewhat lacking on how best to extract the data I need from it. I got the following analysis (might be doing it wrong)...
Can anyone hopefully help shed some light on my issue or if I'm running the analysis incorrectly:
0:000> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************
GetPageUrlData failed, server returned HTTP status 404
URL requested: http://watson.microsoft.com/StageOne/Star_exe/1_0_0_0/4dbad268/KERNELBASE_dll/6_1_7600_16385/4a5bdaae/e0434352/00009617.htm?Retriage=1
FAULTING_IP:
KERNELBASE!RaiseException+58
752d9617 c9 leave
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 752d9617 (KERNELBASE!RaiseException+0x00000058)
ExceptionCode: e0434352 (CLR exception)
ExceptionFlags: 00000001
NumberParameters: 5
Parameter[0]: 80070002
Parameter[1]: 00000000
Parameter[2]: 00000000
Parameter[3]: 00000000
Parameter[4]: 57af0000
PROCESS_NAME: Star.exe
ERROR_CODE: (NTSTATUS) 0xe0434352 - <Unable to get error code text>
EXCEPTION_CODE: (NTSTATUS) 0xe0434352 - <Unable to get error code text>
EXCEPTION_PARAMETER1: 80070002
EXCEPTION_PARAMETER2: 00000000
EXCEPTION_PARAMETER3: 00000000
EXCEPTION_PARAMETER4: 0
MOD_LIST: <ANALYSIS/>
NTGLOBALFLAG: 0
APPLICATION_VERIFIER_FLAGS: 0
MANAGED_STACK: !dumpstack -EE
No export dumpstack found
MANAGED_BITNESS_MISMATCH:
Managed code needs matching platform of sos.dll for proper analysis. Use 'x86' debugger.
ADDITIONAL_DEBUG_TEXT: Followup set based on attribute [Is_ChosenCrashFollowupThread] from Frame:[0] on thread:[PSEUDO_THREAD]
LAST_CONTROL_TRANSFER: from 57c03970 to 752d9617
FAULTING_THREAD: ffffffff
DEFAULT_BUCKET_ID: STACKIMMUNE
PRIMARY_PROBLEM_CLASS: STACKIMMUNE
BUGCHECK_STR: APPLICATION_FAULT_STACKIMMUNE_NOSOS_CLR_EXCEPTION_WRONG_SYMBOLS
STACK_TEXT:
00000000 00000000 star.exe+0x0
SYMBOL_NAME: star.exe
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: star
IMAGE_NAME: Star.exe
DEBUG_FLR_IMAGE_TIMESTAMP: 4dbad268
STACK_COMMAND: ** Pseudo Context ** ; kb
FAILURE_BUCKET_ID: STACKIMMUNE_e0434352_Star.exe!Unknown
BUCKET_ID: APPLICATION_FAULT_STACKIMMUNE_NOSOS_CLR_EXCEPTION_WRONG_SYMBOLS_star.exe
FOLLOWUP_IP: *** WARNING: Unable to verify timestamp for Star.exe
Star!.ctor+0 [C:\Users\Aj\Documents\Visual Studio 2010\Projects\Star\Star\ViewModels\ViewModelBase.cs # 22]
00360000 ?? ???
WATSON_STAGEONE_URL: http://watson.microsoft.com/StageOne/Star_exe/1_0_0_0/4dbad268/KERNELBASE_dll/6_1_7600_16385/4a5bdaae/e0434352/00009617.htm?Retriage=1
Followup: MachineOwner
---------
You may want to use this article as a starting point: SOS: It's Not Just an ABBA Song Anymore
It looks like your application is a .NET application, make sure you've got the right .NET Framework installed. When you load the sos.dll file into windbg, you may have to provide a full path. Also, you can set up access to the public microsoft symbol servers to help with some of your stack tracing. This article may help: Debugging Tools and Symbols: Getting Started. Make sure you've got the latest version of the debugging tools.
!analyze will give you some information about the fault, but not too much else. You should look at the first article to see what else is going on.
Posting some information about your application will also help people see if you are having a similar issue.
It looks like the fault is happening in your ViewModelBase.cs file. You may want to add some logging (using log4net or similar tool) to catch the exception and print out the stack trace. You can also hook into AppDomain.CurrentDomain.UnhandledException event (or the Application.DispatcherUnhandledException event for WPF applications) to catch anything that's getting thrown and printing out something to a log file. In this case, you won't need to resort to WinDbg to figure out what's going on.
Well after several weeks of searching (maybe more), it turns out that when using Trend Micro Corporate, XP to Server 2003 is fine, Vista and Windows 7 to 2003 is fine, and even XP/Vista to server 2008 is fine, but (and I have no idea why), when using Windows 7 and trying to run a network application using a UNC path in the shortcut, it blocks certain pieces of the network traffic for that application, and it does so sporadically and what seems to be without any sound logic. I can't say why as we never quite figured out what exactly the catalyst was for setting off Trend, but I do know that when we disabled Trend, all was back to normal (something I wished we tried sooner). We found that by mapping a drive to our share and changing our shortcuts on our users workstations to use the mapped drive rather than a UNC path, the issue was averted.
Hopefully no one else runs into this problem, but if they do, this will perhaps shed some light on the issue.
Thank you!
Aj

Resources