{"action":"created","issue":{"url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/1924","repository_url":"https://api.github.com/repos/varnishcache/varnish-cache","labels_url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/1924/labels{/name}","comments_url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/1924/comments","events_url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/1924/events","html_url":"https://github.com/varnishcache/varnish-cache/issues/1924","id":150941796,"number":1924,"title":"Logging is impossible in `vcl_init`: Assert error in WS_Assert(), cache/cache_ws.c","user":{"login":"kamermans","id":266265,"avatar_url":"https://avatars.githubusercontent.com/u/266265?v=3","gravatar_id":"","url":"https://api.github.com/users/kamermans","html_url":"https://github.com/kamermans","followers_url":"https://api.github.com/users/kamermans/followers","following_url":"https://api.github.com/users/kamermans/following{/other_user}","gists_url":"https://api.github.com/users/kamermans/gists{/gist_id}","starred_url":"https://api.github.com/users/kamermans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamermans/subscriptions","organizations_url":"https://api.github.com/users/kamermans/orgs","repos_url":"https://api.github.com/users/kamermans/repos","events_url":"https://api.github.com/users/kamermans/events{/privacy}","received_events_url":"https://api.github.com/users/kamermans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-25T18:12:01Z","updated_at":"2016-04-26T10:18:06Z","closed_at":null,"body":"In previous versions of varnish, `std.log` and `std.syslog` were available in `vcl_init`.  At some point this stopped working and is problematic because I am initializing other vmods in `vcl_init`.  If there is a problem with one of those vmods, I need to be able to log that event.  In Varnish 3.x I would use `panic` to kill the entire system, but that was removed in 4.x, so then I would resort to logging the problem.  It is worth noting that in my code, `std.log` was only invoked if a vmod returned an error code, and I cannot confirm that this has ever happened until today, so it's possible that logging from `init` has never worked in 4.x.\r\n\r\n## Expected Behavior\r\nLog message is sent to VSL.\r\n\r\n## Current Behavior\r\nVarnish core-dumps with the following output:\r\n\r\n```\r\nroot@52dca29ac81c:/u/apps/site/docker/varnish# varnishd -F -f /tmp/test.vcl\r\nDebug: Platform: Linux,4.2.0-35-generic,x86_64,-junix,-smalloc,-smalloc,-hcritbit\r\n\r\nDebug: Child (28) Started\r\nCLI result = 400\r\nError: Child (28) Pushing vcls failed:\r\nCLI communication error (hdr)\r\nDebug: Stopping Child\r\nError: Child (28) died signal=6 (core dumped)\r\nError: Child (28) Last panic at: Mon, 25 Apr 2016 17:57:47 GMT\r\n\"Assert error in WS_Assert(), cache/cache_ws.c line 41:\r\n  Condition((ws) != NULL) not true.\r\nthread = (cache-main)\r\nversion = varnish-4.1.2 revision 0d7404e\r\nident = Linux,4.2.0-35-generic,x86_64,-junix,-smalloc,-smalloc,-hcritbit,epoll\r\nBacktrace:\r\n  0x433976: varnishd() [0x433976]\r\n  0x44a58b: varnishd(WS_Assert+0x16b) [0x44a58b]\r\n  0x44ac50: varnishd(WS_Reserve+0x10) [0x44ac50]\r\n  0x7f911f9f8420: libvmod_std.so(vmod_log+0x80) [0x7f911f9f8420]\r\n  0x7f91218efcf7: vgc.so(VGC_function_vcl_init+0x37) [0x7f91218efcf7]\r\n  0x7f91218f01e2: vgc.so(+0x21e2) [0x7f91218f01e2]\r\n  0x43ebd1: varnishd() [0x43ebd1]\r\n  0x7f912e8e15c1: libvarnish.so(+0x65c1) [0x7f912e8e15c1]\r\n  0x7f912e8e19fb: libvarnish.so(+0x69fb) [0x7f912e8e19fb]\r\n  0x7f912e8e6ce8: libvarnish.so(VLU_Fd+0xd8) [0x7f912e8e6ce8]\r\n\r\n\"\r\nCould not create _.vsm.18: File exists\r\n```\r\n\r\n## Possible Solution\r\nEither document that `std.log` and `std.syslog` cannot be used in `vcl_init`, or implement them.\r\nFor bonus points, reintroduce `panic` so we can intentionally crash Varnish if a vmod has no chance of working :)\r\n\r\n## Steps to Reproduce (for bugs)\r\n\r\nStep 1. Create `test.vcl`:\r\n```\r\nvcl 4.0;\r\n\r\nimport std;\r\n\r\nbackend backend_test {\r\n    .host = \"localhost\";\r\n    .port = \"8080\";\r\n}\r\n\r\nsub vcl_init {\r\n    std.log(\"test\");\r\n}\r\n```\r\n\r\nStep 2. Run `varnishd -F -f /tmp/test.vcl`\r\n\r\n## Context\r\nWe use the WURFL InFuze for Varnish-Cache module.  This module required rather complex configuration at init time, and could fail for various legitimate reasons, so code like this is common in `vcl_init`:\r\n\r\n```\r\nwurfl.load();\r\nif (wurfl.error()) {\r\n    std.log(wurfl.error());\r\n\r\n    # TODO: Varnish 4.x does not support panic\r\n    #panic wurfl.error();\r\n}\r\n```\r\n\r\n## Your Environment\r\nTested in Ubuntu 14.04 with Varnish 4.0.3 and 4.1.2 from the Varnish Ubuntu repo.\r\n"},"comment":{"url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/comments/214694108","html_url":"https://github.com/varnishcache/varnish-cache/issues/1924#issuecomment-214694108","issue_url":"https://api.github.com/repos/varnishcache/varnish-cache/issues/1924","id":214694108,"user":{"login":"fgsch","id":241785,"avatar_url":"https://avatars.githubusercontent.com/u/241785?v=3","gravatar_id":"","url":"https://api.github.com/users/fgsch","html_url":"https://github.com/fgsch","followers_url":"https://api.github.com/users/fgsch/followers","following_url":"https://api.github.com/users/fgsch/following{/other_user}","gists_url":"https://api.github.com/users/fgsch/gists{/gist_id}","starred_url":"https://api.github.com/users/fgsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgsch/subscriptions","organizations_url":"https://api.github.com/users/fgsch/orgs","repos_url":"https://api.github.com/users/fgsch/repos","events_url":"https://api.github.com/users/fgsch/events{/privacy}","received_events_url":"https://api.github.com/users/fgsch/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T10:18:06Z","updated_at":"2016-04-26T10:18:06Z","body":"@Dridi For other cases, yes. For std.log() I don't think we should artificially limit it to specific subroutines."}}