Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timer-sense-light crashes after web server started #2

Closed
codelast opened this issue Oct 11, 2015 · 3 comments
Closed

timer-sense-light crashes after web server started #2

codelast opened this issue Oct 11, 2015 · 3 comments
Assignees

Comments

@codelast
Copy link
Owner

subproject: timer-sense-light

When Mongoose web server embedded in the timer-sense-light started in a thread, it crashed immediately.
It seems that it's because of specifying the web-root for mongoose web server caused the problem, but don't konw why.

GDB debug info

[root@alarmpi deploy]# gdb timer_sense_light core.4929
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv6l-unknown-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from timer_sense_light...done.

warning: core file may not match specified executable file.
[New LWP 4930]
[New LWP 4929]
[New LWP 4931]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `/root/raspberry-pi/gpio/timer-sense-light/deploy/timer_sense_light /root/raspbe'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0001f634 in mg_mgr_poll (mgr=0xb6b5ce00, milli=1000) at src/3rd/mongoose.c:2857

2857 tmp = nc->next;
Current thread is 1 (Thread 0xb6b5d450 (LWP 4930)) bt
#0 0x0001f634 in mg_mgr_poll (mgr=0xb6b5ce00, milli=1000) at src/3rd/mongoose.c:2857
#1 0x00012f40 in threadWebHandler () at ./include/thread_web_handler.h:86
#2 0xb6f0d00c in start_thread () from /usr/lib/libpthread.so.0
#3 0xb6c2d718 in ?? () from /usr/lib/libc.so.6

Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) quit

GDB debug guide

  • turn on the core dump for Arch Linux ARM

    ulimit -c unlimited
    sysctl -w kernel.core_pattern=core

  • modify Makefile to include debugging info in the binary executable program

    DEBUG = YES

  • compile & run the program

    make && make install
    cd deploy/bin && ./run-timer-sense-light.sh

You'll find that a core.xxx(e.g. core.4929) file generated under the same dir as the timer-sense-light executable program.

  • run GDB

    gdb timer_sense_light core.xxx
    set args /root/raspberry-pi/gpio/timer-sense-light/deploy/conf/main.conf /root/raspberry-pi/gpio/timer-sense-light/deploy/conf/time-range.txt
    b mongoose.c:2855
    r
    n

@codelast codelast self-assigned this Oct 11, 2015
@codelast
Copy link
Owner Author

codelast commented Nov 6, 2015

Seems that this problem is caused by compiling the Mongoose source by g++ but not gcc, I ran a simple test that using g++ to compile one of the example shipped with Mongoose, then it crashed immediately after running the binary.

@codelast
Copy link
Owner Author

codelast commented Nov 7, 2015

Also found that even if compiling the Mongoose source by gcc, and other .cpp files by g++ for this project, the program still crashes, seems that some of the third-party libs are conflicted with Mongoose?

@codelast
Copy link
Owner Author

Problem solved.
The crash was caused by this line:

if (mg_stat(httpServerOpts.document_root, &st) != 0) {

Implement the logic by myself instead of using the Mongoose implementation solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant