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

connman_ncurses crashes when toggling between online/offline modes #2

Merged
merged 1 commit into from
Jan 29, 2015

Conversation

alan-mushi
Copy link
Contributor

Testcase:

  1. Execute connman_ncurses
  2. Press 'o' on an available technology (tested only for wifi)
  3. The status is toggle, the network is shutdown or configured but connman_ncurses crashes.

libjson-c2 version 0.11-3. I don't know enough C, but anyway went on and tried to debug by myself without success =)

(gdb) bt
#0  0x00007ffff77752b0 in printbuf_reset () from /lib/x86_64-linux-gnu/libjson-c.so.2
#1  0x00007ffff777158e in json_object_to_json_string_ext () from /lib/x86_64-linux-gnu/libjson-c.so.2
#2  0x00000000004093b1 in __renderers_state (jobj=0x618e40) at renderers.c:237
#3  0x0000000000409534 in __renderers_home_page (jobj=0x6482d0) at renderers.c:271
#4  0x000000000040d175 in action_on_cmd_callback (jobj=0x648590) at main.c:475
#5  0x000000000040e039 in main_callback (status=0, jobj=0x648590) at main.c:831
#6  0x000000000040761d in get_home_page (jobj=0x0) at engine.c:353
#7  0x00000000004088eb in engine_query (jobj=0x647c40) at engine.c:964
#8  0x000000000040e1fe in print_home_page () at main.c:882
#9  0x000000000040cdc7 in exec_refresh () at main.c:362
#10 0x000000000040d46e in action_on_signal (jobj=0x643b10) at main.c:559
#11 0x000000000040e053 in main_callback (status=12345, jobj=0x643b10) at main.c:834
#12 0x00000000004080ff in engine_commands_sig (jobj=0x643b10) at engine.c:765
#13 0x0000000000405476 in monitor_changed (connection=0x616c30, message=0x618710, user_data=0x0) at commands.c:622
#14 0x00007ffff7ba4ad6 in dbus_connection_dispatch () from /lib/x86_64-linux-gnu/libdbus-1.so.3
#15 0x0000000000406dc9 in loop_run (poll_stdin=true) at loop.c:194
#16 0x000000000040f7ad in main () at main.c:1554

@jobol
Copy link
Contributor

jobol commented Jan 21, 2015

Thanks for the report.

It should work with json-c 0.11 thus there is no problem of version with json-c.
What version of connman are you using?

We should check but it can take time.

Is there a work around?

@javier-lopez
Copy link
Contributor Author

I was able to reproduce this with the latest connman git version and connman 1.27, haven't tried with lower versions. I've not found any workaround but will keep poking it.

@alan-mushi
Copy link
Contributor

Hi,

I was able to reproduce the bug on debian with the connmand packaged and the latest git version. connman_ncurses don't crash every time, often it just keep hanging on "Toggling OfflineMode..." after at least 3 offline/online toggling.

@chilicuil when it crashes do you see "junk" string for State and OfflineMode in the header ? By junk string I mean some random JSON string that shouldn't be there, for example I have State: wifi and OfflineMode: [ "Pow....

This far I found that the jobj argument for __renderers_state() causes a segfault when I try to print it (as well as state and offline_mode variables). I was able to trace back the faulty object back to state in engine.c. I can't investigate more right away but I will do as soon as possible (e.g. one weekend).

@javier-lopez
Copy link
Contributor Author

Hello Alan,

Yes, I also see garbage strings in the headers, exactly the same text, State: wifi OfflineMode: [ "Pow

@alan-mushi
Copy link
Contributor

So I solved this:
In engine.c react_to_sig_manager() (line 865), the state is updated with a pointer to the data to print but I forgot to increment the refcount of the aforementioned data.

@jobol Do you prefer a pull request or a commit to fix this ?

I'm sorry I missed it.

@jobol
Copy link
Contributor

jobol commented Jan 29, 2015

@alan-mushi to be honest, I prefer a pull request linked to that issue (#2) but the operation is really painful to do. That script is doing that:

#!/bin/bash

usage() {
    echo "usage: $(basename $0) nick repo issue [brsrc [brtgt]]"
}

case $# in
    3) nick=$1; repo=$2; issue=$3; brsrc=issue$3; brtgt=master;;
    4) nick=$1; repo=$2; issue=$3; brsrc=$4; brtgt=master;;
    5) nick=$1; repo=$2; issue=$3; brsrc=$4; brtgt=$5;;
    *) usage >&2; exit 1;;
esac

cat << EOC
curl \
    --user $nick \
    --request POST \
    --data '{"issue": "$issue", "head": "$nick:$brsrc", "base": "$brtgt"}' \
    https://api.github.com/repos/$repo/pulls
EOC

By typing

  script alan-mushi connman-json-client 2

You will get the REST API pull request for attaching the commit to the issue

@alan-mushi
Copy link
Contributor

PS: there might be a better solution than the script : https://github.com/blog/1506-closing-issues-via-pull-requests

@jobol
Copy link
Contributor

jobol commented Jan 29, 2015

When I tried what you suggest, it failed. So do it as you want. Let's try...

@alan-mushi
Copy link
Contributor

I got an issue (404 HTTP code) with your script for the api url see https://developer.github.com/v3/pulls/#create-a-pull-request for the new url format.

jobol added a commit that referenced this pull request Jan 29, 2015
@jobol jobol merged commit 50ec7b9 into eurogiciel-oss:master Jan 29, 2015
@jobol
Copy link
Contributor

jobol commented Jan 29, 2015

I'll update my script, thanks

@alan-mushi alan-mushi deleted the issue2 branch February 2, 2015 09:54
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

Successfully merging this pull request may close these issues.

3 participants