{"action":"created","issue":{"url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/8","labels_url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/8/comments","events_url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/8/events","html_url":"https://github.com/OpenSeaMap/renderer/issues/8","id":125396250,"number":8,"title":"searender segmentation faults","user":{"login":"praabjerg","id":8244343,"avatar_url":"https://avatars.githubusercontent.com/u/8244343?v=3","gravatar_id":"","url":"https://api.github.com/users/praabjerg","html_url":"https://github.com/praabjerg","followers_url":"https://api.github.com/users/praabjerg/followers","following_url":"https://api.github.com/users/praabjerg/following{/other_user}","gists_url":"https://api.github.com/users/praabjerg/gists{/gist_id}","starred_url":"https://api.github.com/users/praabjerg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praabjerg/subscriptions","organizations_url":"https://api.github.com/users/praabjerg/orgs","repos_url":"https://api.github.com/users/praabjerg/repos","events_url":"https://api.github.com/users/praabjerg/events{/privacy}","received_events_url":"https://api.github.com/users/praabjerg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-07T13:43:33Z","updated_at":"2016-01-07T16:00:32Z","closed_at":"2016-01-07T16:00:32Z","body":"Hey! I am currently working on a project where we want to render a world-wide map layer with at least some of the SeaMark symbols. For this reason, I have been playing around with the rendering scripts.\r\nThey seem to work most of the time, but occasionally, searender will throw a segmentation fault on one of the *.osm tiles generated by jsearch, causing an incomplete *.svg to be generated, which then of course causes batik to throw TranscoderExceptions in jtile.\r\nThe end result is that some of the *.png tiles end up missing after the final step.\r\n\r\nI am not sure if this is a local problem with a C library on my computer, or if it even happens on the OpenSeaMap tile server. But it could potentially explain why I sometimes see areas with obviously missing tiles from the public servers, like:\r\nhttp://map.openseamap.org/?zoom=13&lat=59.62631&lon=20.30568&layers=BFTFFFFFFFF0FFFFFFFFFF\r\nor\r\nhttp://map.openseamap.org/?zoom=14&lat=1.4807&lon=102.99102&layers=BFTFFFFFFFF0FFFFFFFFFF\r\n\r\nThe fact that the missing areas are the same from zoom level 12 and down is consistent with my issue, and the way the rendering pipeline works. Pngs for the higher zoom levels are generated from the level 12 svgs, so when one of those end up incomplete because of a segfault, all the pngs for that area from zoom level 12 and up disappear.\r\n\r\nI am attaching a zip file with a set of *.osm tiles (generated by jsearch) that my local instance of searender consistently segfaults on. They originate from a local extract I populated my database with, using the service on http://download.bbbike.org/osm/ , covering Copenhagen and Malmö.\r\n\r\nUnless this is just a local problem with one of my C libraries, then running, for example,\r\n./searender symbols/symbols.defs 12 >2195-1282-12.svg <2195-1282-12.osm\r\nwill cause the segfault.\r\n\r\nUnfortunately, I am not familiar enough with the searender code to localise the problem right away, but if you're having the same problem on the public OpenSeaMap tile servers, hopefully this will be of some help.\r\n[OSMsThatWillSegfaultSeaRender.zip](https://github.com/OpenSeaMap/renderer/files/81201/OSMsThatWillSegfaultSeaRender.zip)\r\n"},"comment":{"url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/comments/169706912","html_url":"https://github.com/OpenSeaMap/renderer/issues/8#issuecomment-169706912","issue_url":"https://api.github.com/repos/OpenSeaMap/renderer/issues/8","id":169706912,"user":{"login":"praabjerg","id":8244343,"avatar_url":"https://avatars.githubusercontent.com/u/8244343?v=3","gravatar_id":"","url":"https://api.github.com/users/praabjerg","html_url":"https://github.com/praabjerg","followers_url":"https://api.github.com/users/praabjerg/followers","following_url":"https://api.github.com/users/praabjerg/following{/other_user}","gists_url":"https://api.github.com/users/praabjerg/gists{/gist_id}","starred_url":"https://api.github.com/users/praabjerg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praabjerg/subscriptions","organizations_url":"https://api.github.com/users/praabjerg/orgs","repos_url":"https://api.github.com/users/praabjerg/repos","events_url":"https://api.github.com/users/praabjerg/events{/privacy}","received_events_url":"https://api.github.com/users/praabjerg/received_events","type":"User","site_admin":false},"created_at":"2016-01-07T16:00:32Z","updated_at":"2016-01-07T16:00:32Z","body":"So, my C is a bit rusty, but with the help of gdb, I think I found what is causing the issue.\r\nIt is the call to strtok on line 1077 in render.c:\r\n```\r\nint drawText(Item_t *item, char *text, char *style, double dx, double dy) {\r\n  XY_t coord = findCentroid(item);\r\n  if ((coord.x > 0.0) || (coord.y > 0.0)) {\r\n    printf(\"<text id=\\\"%d\\\" \", ++ref);\r\n    double size = scaleStyle(style) * 1.1;\r\n    double x = coord.x + (dx*symbolScale[zoom]);\r\n    double y = coord.y + (dy*symbolScale[zoom]);\r\n    char *line = strtok(text, \"\\n\");\r\n    double dy = 0.0;\r\n    printf(\"y=\\\"%f\\\">\", y);\r\n    while (line != NULL) {\r\n      printf(\"<tspan x=\\\"%f\\\" dy=\\\"%f\\\">%s</tspan>\\n\", x, dy, line);\r\n      dy = size;\r\n      line = strtok(NULL, \"\\n\");\r\n    }\r\n    printf(\"</text>\\n\");\r\n    return ref;\r\n  }\r\n  return 0;\r\n}\r\n```\r\nThat call will sometimes receive a string literal in the text parameter, which will cause a segmentation fault because strtok then attempts to modify a string literal. In my case, gdb identified line 724 and 469 in rules.c as entry points (receiving the literals \"(Shoal)\" and \"V-AIS\" respectively)."}}