feeding [rest-json] output to [json-decode] crashes on Mac OS X #4

eighthave opened this Issue Jan 30, 2012 · 4 comments


None yet

2 participants


I open rest-json-help.pd, replace [print data] with [json-decode] and click one of the URLs, and it crashes every time for me. I'm using Pd-extended 0.43.1 20120119 64-bit build on Mac OS X 10.6.8. purest_json is built against json-c 0.9 and libcurl 7.24.0.

0 libjson.0.dylib 0x0000000106a95bdc json_object_put + 12
1 pd 0x0000000100027782 outlet_list + 82
2 libpurest_json.dylib 0x0000000106a9fac9 output_json + 473 (libpurest_json.c:48)
3 rest-json.pd_darwin 0x0000000106aa374c execute_rest_thread + 284 (rest-json.c:163)
4 libSystem.B.dylib 0x000000010017dfd6 _pthread_start + 331
5 libSystem.B.dylib 0x000000010017de89 thread_start + 13

Using the 32-bit Mac OS X build with , I also get a similar crash:
0 libjson.0.dylib 0x190e609a json_object_put + 10
1 pd 0x0002ccad outlet_list + 77
2 libpurest_json.dylib 0x190eedd9 output_json + 665
3 ??? 0x0604d200 0 + 100979200
4 ??? 0x65736e6f 0 + 1702063727

@residuum residuum was assigned Jan 30, 2012

[rest-json] outputs a series of lists, while [json-decode] takes a string as an input. You will have to do something like this currently:

[list trim]
[route commits] <--- or something similar
[print  decoded]

Ah, ok makes sense. Figuring out how to represent json's nested lists in Pd is a tricky problem. It would be nice if output_json() didn't crash given bad input.


I am working on it right now. I am thinking about decoding the nested objects, and outputting them, therefore making the list trim and route unnecessary.


I have just found the source of the segfault: A call to json_object_put without testing for json errors with is_error first. Will commit that later.

@residuum residuum added a commit that referenced this issue Jan 30, 2012
@residuum Fixing issue #4:
- test for is_error(jobj) before json_object_put(jobj)
- using lists for [json-decode]
@residuum residuum closed this Jan 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment