Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

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

Closed
eighthave opened this issue Jan 30, 2012 · 4 comments
Closed
Assignees

Comments

@eighthave
Copy link
Contributor

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

@ghost ghost assigned residuum Jan 30, 2012
@residuum
Copy link
Owner

[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:

[rest-json]
|
[list trim]
|
[route commits] <--- or something similar
|
[json-decode]
|
[print  decoded]

@eighthave
Copy link
Contributor Author

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.

@residuum
Copy link
Owner

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.

@residuum
Copy link
Owner

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 added a commit that referenced this issue Jan 30, 2012
- test for is_error(jobj) before json_object_put(jobj)
- using lists for [json-decode]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants