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

json.c:607 ast_json_vpack: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string. #69

Closed
532910 opened this issue Aug 26, 2019 · 16 comments

Comments

@532910
Copy link

532910 commented Aug 26, 2019

asterisk 1:16.2.1~dfsg-1 debian buster

[donglename] Got SMS from +phonenumber: 'test'
[2019-08-26 03:47:05] ERROR[23550]: json.c:607 ast_json_vpack: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[2019-08-26 03:47:05] ERROR[23550]:   Got 10 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0x99) [0x564005b91459]
# 1: /usr/sbin/asterisk(ast_channel_publish_varset+0x2b) [0x564005c0c03b]
# 2: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x149) [0x564005bc6f09]
# 3: /usr/lib/asterisk/modules/chan_dongle.so(+0x1865e) [0x7fe5ed74265e]
# 4: /usr/lib/asterisk/modules/chan_dongle.so(+0xd1b0) [0x7fe5ed7371b0]
# 5: /usr/lib/asterisk/modules/chan_dongle.so(+0xdbd2) [0x7fe5ed737bd2]
# 6: /usr/lib/asterisk/modules/chan_dongle.so(+0x12bbb) [0x7fe5ed73cbbb]
# 7: /usr/sbin/asterisk(+0x18843f) [0x564005c2a43f]
# 8: /lib/x86_64-linux-gnu/libpthread.so.0(+0x7fa3) [0x7fe5f1604fa3]
# 9: /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fe5f135f4cf]
@wdoekes
Copy link
Owner

wdoekes commented Aug 26, 2019

Most likely culprit would be:

--- a/channel.c
+++ b/channel.c
@@ -1222,8 +1222,12 @@ static void set_channel_vars(struct pvt* pvt, struct ast_channel* channel)
        //ast_string_field_set (channel, language, CONF_SHARED(pvt, language);
 #endif /* ^11- */
 
-       for(idx = 0; idx < ITEMS_OF(dev_vars); ++idx)
+       for(idx = 0; idx < ITEMS_OF(dev_vars); ++idx) {
+               ast_log(LOG_ERROR, "DEBUG: %s = %s\n",
+                       (dev_vars[idx].name ? dev_vars[idx].name : "(null)"),
+                       (dev_vars[idx].value ? dev_vars[idx].value : "(null)"));
                pbx_builtin_setvar_helper (channel, dev_vars[idx].name, dev_vars[idx].value);
+       }
 }
 
 /* NOTE: called from device and current levels with locked pvt */

Can you check?

I assume that one of those values is NULL and that ast_json_pack in ast_channel_publish_varset doesn't like it.

Additionally, try this for more backtrace output:

diff --git a/Makefile.in b/Makefile.in
index c515874..be0bc18 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,9 +38,9 @@ INSTALL = @INSTALL@
 CHMOD = chmod
 
 # -DAST_MODULE=\"$(PROJM)\" -D_THREAD_SAFE
-CFLAGS  = @CFLAGS@ -I$(srcdir) -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self \
+CFLAGS  = @CFLAGS@ -g3 -I$(srcdir) -DAST_MODULE_SELF_SYM=__internal_chan_dongle_self \
        @CPPFLAGS@ @DEFS@ @AC_CFLAGS@
-LDFLAGS = @LDFLAGS@ 
+LDFLAGS = @LDFLAGS@ -g3
 SOLINK  = @SOLINK@
 LIBS    = @LIBS@
 DISTNAME= @PACKAGE_TARNAME@-@[email protected]@PACKAGE_REVISION@
@@ -51,7 +51,7 @@ VPATH = @srcdir@
 all: @TARGET@
 
 install: all
-       $(STRIP) $(PROJM)
+       #$(STRIP) $(PROJM)
 ifneq (@DESTDIR@,)
        $(INSTALL) -m 644 $(PROJM) @DESTDIR@
 else

@532910
Copy link
Author

532910 commented Aug 26, 2019

Unable to apply the first patch above:

% git clone https://github.com/wdoekes/asterisk-chan-dongle asterisk-chan-dongle-test
% cd asterisk-chan-dongle-test 
% cat ../1.diff| patch -p1    
patching file channel.c
Hunk #1 FAILED at 1222.
1 out of 1 hunk FAILED -- saving rejects to file channel.c.rej

@532910
Copy link
Author

532910 commented Aug 26, 2019

And the second one too:

% cat ../2.diff| patch -p1   
patching file Makefile.in
Hunk #1 FAILED at 38.
Hunk #2 FAILED at 51.
2 out of 2 hunks FAILED -- saving rejects to file Makefile.in.rej

@532910
Copy link
Author

532910 commented Aug 31, 2019

@wdoekes could you check your patches. I can't apply them.

@wdoekes
Copy link
Owner

wdoekes commented Sep 3, 2019

If you cannot get those patches to work, I don't think we can help each other.

@532910
Copy link
Author

532910 commented Sep 3, 2019

Could you attach them as files, my be I can't correctly copy-paste them?

@532910
Copy link
Author

532910 commented Nov 19, 2019

Walter, could you please check the patches, I can't apply them to the master. May be I can't copy them correct. Could you recheck them and attach as files.

Or could you create a separate branch that I can checkout?

@wdoekes
Copy link
Owner

wdoekes commented Nov 19, 2019

Try the patch --ignore-whitespace option. And make sure the Makefile(.in) gets tabs, not spaces.

@532910
Copy link
Author

532910 commented Nov 19, 2019

  1. --ignore-whitespace solves the patch problem
  2. I see the same call trace with both patches applied:
 [donglename] Got SMS from +phonenumber: 'test '
[2019-11-19 19:29:34] ERROR[2847]: channel.c:1226 set_channel_vars: DEBUG: DONGLENAME = donglename
[2019-11-19 19:29:34] ERROR[2847]: channel.c:1226 set_channel_vars: DEBUG: DONGLEPROVIDER = donglename�
[2019-11-19 19:29:34] ERROR[2847]: json.c:607 ast_json_vpack: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[2019-11-19 19:29:34] ERROR[2847]:   Got 11 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0x99) [0x55e07cae1449]
# 1: /usr/sbin/asterisk(ast_channel_publish_varset+0x2b) [0x55e07cb5c01b]
# 2: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x149) [0x55e07cb16f79]
# 3: /usr/lib/asterisk/modules/chan_dongle.so(+0x14ecc) [0x7fd48da4eecc]
# 4: /usr/lib/asterisk/modules/chan_dongle.so(+0x186a5) [0x7fd48da526a5]
# 5: /usr/lib/asterisk/modules/chan_dongle.so(+0xd1b0) [0x7fd48da471b0]
# 6: /usr/lib/asterisk/modules/chan_dongle.so(+0xdbd2) [0x7fd48da47bd2]
# 7: /usr/lib/asterisk/modules/chan_dongle.so(+0x12bbb) [0x7fd48da4cbbb]
# 8: /usr/sbin/asterisk(+0x18849f) [0x55e07cb7a49f]
# 9: /lib/x86_64-linux-gnu/libpthread.so.0(+0x7fa3) [0x7fd491914fa3]
#10: /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fd49166f4cf]

@532910
Copy link
Author

532910 commented Nov 19, 2019

Looks like it's due to symbol at the end of Provider Name from #39

@532910
Copy link
Author

532910 commented Nov 20, 2019

Just an acknowledgment that master works fine. Thank you, Walter!

BTW, do you know, why github shows "Latest commit 8b1827c on Jan 21" on the top of https://github.com/wdoekes/asterisk-chan-dongle, while recent commits are shown on the the commits page https://github.com/wdoekes/asterisk-chan-dongle/commits/master ?

@wdoekes
Copy link
Owner

wdoekes commented Nov 20, 2019

I do.

It's because I cherry-picked an old commit by garronej:

$ git show --format=fuller 8b1827c53 | grep -E 'Author|Commit'
Author:     Garrone Joseph <joseph.garrone...ensimag.grenoble-inp.fr>
AuthorDate: Mon Jan 21 10:41:12 2019 +0100
Commit:     Walter Doekes <walter+github...wjd.nu>
CommitDate: Wed Nov 20 09:49:30 2019 +0100

@532910
Copy link
Author

532910 commented Nov 20, 2019

Is there a reason for this?
I always thought it shows the last activity, now I will not think so anymore. But in any case, this is confusing.

@wdoekes
Copy link
Owner

wdoekes commented Nov 20, 2019

I'm sorry. That's something you have to take up with GitHub. The text "Latest commit 8b1827c on Jan 21" is simply wrong. It should be "Latest commit 8b1827c on Nov 20", as that is the date the commit was done.

Note that this problem goes away when a new commit (that isn't an ancient cherry-pick) is added.

@532910
Copy link
Author

532910 commented Nov 20, 2019

Pressing the commit link 8b1827c also shows "Jan 21".
Do you insist this is a github bug?

@532910
Copy link
Author

532910 commented Nov 20, 2019

Looks like it shows the date commit was added (PR?) (AuthorDate: Mon Jan 21), but not approved by you (CommitDate: Wed Nov 20).

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

2 participants