GitHub PullRequestEvent at 2014-06-27 17:11:53
Repository: otp
Actor: lrascao
Payload: {"action":"opened","number":411,"pull_request":{"url":"https://api.github.com/repos/erlang/otp/pulls/411","id":17714337,"html_url":"https://github.com/erlang/otp/pull/411","diff_url":"https://github.com/erlang/otp/pull/411.diff","patch_url":"https://github.com/erlang/otp/pull/411.patch","issue_url":"https://api.github.com/repos/erlang/otp/issues/411","number":411,"state":"open","title":"fix escript archive symlinked across drives","user":{"login":"lrascao","id":639415,"avatar_url":"https://avatars.githubusercontent.com/u/639415?","gravatar_id":"509f8f3a2cfbfc96129089ede13f3546","url":"https://api.github.com/users/lrascao","html_url":"https://github.com/lrascao","followers_url":"https://api.github.com/users/lrascao/followers","following_url":"https://api.github.com/users/lrascao/following{/other_user}","gists_url":"https://api.github.com/users/lrascao/gists{/gist_id}","starred_url":"https://api.github.com/users/lrascao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrascao/subscriptions","organizations_url":"https://api.github.com/users/lrascao/orgs","repos_url":"https://api.github.com/users/lrascao/repos","events_url":"https://api.github.com/users/lrascao/events{/privacy}","received_events_url":"https://api.github.com/users/lrascao/received_events","type":"User","site_admin":false},"body":"TL;DR: escript archive files won't work on Windows when located in directory symlinks between different drives\r\n\r\nimpact:\r\nrebar for instance will not work in these circumstances\r\n\r\nrequirements:\r\n\r\nWindows machine, two different drives (eg. C: and J:)\r\nfolder J:\\otp_bug\\otp_bug, containging an .escript file (generation of .escript described below)\r\nfolder C:\\tmp\\otp_bug which is a folder symlink to J:\\otp_bug (created with: cd c:\\tmp, mklink /d otp_bug j:\\otp_bug)\r\nrepro steps:\r\n\r\nsnip repro scripts below, copy demo.erl, build_demo.erl and bug.erl to J:\\otp_bug\\otp_bug\r\nenter C:\\tmp\\otp_bug\\otp_bug\r\ngenerate demo.escript (run ./build_demo.erl)\r\nrun ./demo.script, it will fail with error undefined function demo:main\r\nchange directory to J:\\otp_bug\\otp_bug, run the same exact ./demo.script, it will succeed\r\nrun ./bug.erl for isolated problem cause (will print: path: C:/tmp/j:/otp_bug/otp_bug/demo.escript) with fix in place correct output will be j:/otp_bug/otp_bug/demo.escript\r\nproblem description:\r\n\r\nproblem is located in method real_path@erts/preloaded/src/erl_prim_loader.erl\r\nreal_path assumes that when a symlink is encountered when exploring the path only the last element of the path array can be replaced (with the symlink target)\r\nthis is fine for unix, however in windows there is the possibility that the last n elements have to be replaced, eg. C:\\tmp\\otp_bug ([\"gub_pto\", \"pmt\", \":c\"] should become [\"gub_pto\", \":j\"])\r\nrepro scripts:\r\n---------------- start demo.erl ---------------\r\n%% Demo\r\n-module(demo).\r\n-mode(compile).\r\n\r\n-export([main/1]).\r\n\r\nmain(_Args) ->\r\n    io:format(\"SMP support: ~p~n\", [erlang:system_info(smp_support)]).\r\n---------------- end demo.erl ---------------\r\n\r\n---------------- start build_demo.erl ---------------\r\n#!/usr/bin/env escript\r\n%% This is an -*- erlang -*- file\r\n%%!\r\nmain(_Args) ->\r\n  {ok, _, BeamCode} = compile:file(\"demo.erl\", [binary, debug_info]),\r\n  {ok, SourceCode} = file:read_file(\"demo.erl\"),\r\n  escript:create(\"demo.escript\", [shebang, comment, {emu_args, \"\"}, {archive, [{\"demo.erl\", SourceCode}, {\"demo.beam\", BeamCode}], []}]),\r\n  escript:extract(\"demo.escript\", []),\r\n  ok.\r\n---------------- end build_demo.erl ---------------\r\n\r\n---------------- start bug.erl ---------------\r\n#!/usr/bin/env escript\r\n%% This is an -*- erlang -*- file\r\n%%!\r\nmain([]) ->\r\n  File = \"./demo.escript\",\r\n  {ok, ArchiveBin} = escript:parse_file(File),\r\n  {ok, FileInfo} = file:read_file_info(File),\r\n  {ok, Path} = erl_prim_loader:set_primary_archive(File, ArchiveBin, FileInfo, fun escript:parse_file/1),\r\n  io:format(\"path: ~s~n\", [Path]).\r\n---------------- end bug.erl ---------------","created_at":"2014-06-27T17:11:51Z","updated_at":"2014-06-27T17:11:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/erlang/otp/pulls/411/commits","review_comments_url":"https://api.github.com/repos/erlang/otp/pulls/411/comments","review_comment_url":"https://api.github.com/repos/erlang/otp/pulls/comments/{number}","comments_url":"https://api.github.com/repos/erlang/otp/issues/411/comments","statuses_url":"https://api.github.com/repos/erlang/otp/statuses/ab50e4e5121c2c29b8a49916f8ac89e42e37a978","head":{"label":"lrascao:fix_bug_windows_directory_symlinks","ref":"fix_bug_windows_directory_symlinks","sha":"ab50e4e5121c2c29b8a49916f8ac89e42e37a978","user":{"login":"lrascao","id":639415,"avatar_url":"https://avatars.githubusercontent.com/u/639415?","gravatar_id":"509f8f3a2cfbfc96129089ede13f3546","url":"https://api.github.com/users/lrascao","html_url":"https://github.com/lrascao","followers_url":"https://api.github.com/users/lrascao/followers","following_url":"https://api.github.com/users/lrascao/following{/other_user}","gists_url":"https://api.github.com/users/lrascao/gists{/gist_id}","starred_url":"https://api.github.com/users/lrascao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrascao/subscriptions","organizations_url":"https://api.github.com/users/lrascao/orgs","repos_url":"https://api.github.com/users/lrascao/repos","events_url":"https://api.github.com/users/lrascao/events{/privacy}","received_events_url":"https://api.github.com/users/lrascao/received_events","type":"User","site_admin":false},"repo":{"id":20764012,"name":"otp","full_name":"lrascao/otp","owner":{"login":"lrascao","id":639415,"avatar_url":"https://avatars.githubusercontent.com/u/639415?","gravatar_id":"509f8f3a2cfbfc96129089ede13f3546","url":"https://api.github.com/users/lrascao","html_url":"https://github.com/lrascao","followers_url":"https://api.github.com/users/lrascao/followers","following_url":"https://api.github.com/users/lrascao/following{/other_user}","gists_url":"https://api.github.com/users/lrascao/gists{/gist_id}","starred_url":"https://api.github.com/users/lrascao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrascao/subscriptions","organizations_url":"https://api.github.com/users/lrascao/orgs","repos_url":"https://api.github.com/users/lrascao/repos","events_url":"https://api.github.com/users/lrascao/events{/privacy}","received_events_url":"https://api.github.com/users/lrascao/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lrascao/otp","description":"Erlang/OTP","fork":true,"url":"https://api.github.com/repos/lrascao/otp","forks_url":"https://api.github.com/repos/lrascao/otp/forks","keys_url":"https://api.github.com/repos/lrascao/otp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lrascao/otp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lrascao/otp/teams","hooks_url":"https://api.github.com/repos/lrascao/otp/hooks","issue_events_url":"https://api.github.com/repos/lrascao/otp/issues/events{/number}","events_url":"https://api.github.com/repos/lrascao/otp/events","assignees_url":"https://api.github.com/repos/lrascao/otp/assignees{/user}","branches_url":"https://api.github.com/repos/lrascao/otp/branches{/branch}","tags_url":"https://api.github.com/repos/lrascao/otp/tags","blobs_url":"https://api.github.com/repos/lrascao/otp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lrascao/otp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lrascao/otp/git/refs{/sha}","trees_url":"https://api.github.com/repos/lrascao/otp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lrascao/otp/statuses/{sha}","languages_url":"https://api.github.com/repos/lrascao/otp/languages","stargazers_url":"https://api.github.com/repos/lrascao/otp/stargazers","contributors_url":"https://api.github.com/repos/lrascao/otp/contributors","subscribers_url":"https://api.github.com/repos/lrascao/otp/subscribers","subscription_url":"https://api.github.com/repos/lrascao/otp/subscription","commits_url":"https://api.github.com/repos/lrascao/otp/commits{/sha}","git_commits_url":"https://api.github.com/repos/lrascao/otp/git/commits{/sha}","comments_url":"https://api.github.com/repos/lrascao/otp/comments{/number}","issue_comment_url":"https://api.github.com/repos/lrascao/otp/issues/comments/{number}","contents_url":"https://api.github.com/repos/lrascao/otp/contents/{+path}","compare_url":"https://api.github.com/repos/lrascao/otp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lrascao/otp/merges","archive_url":"https://api.github.com/repos/lrascao/otp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lrascao/otp/downloads","issues_url":"https://api.github.com/repos/lrascao/otp/issues{/number}","pulls_url":"https://api.github.com/repos/lrascao/otp/pulls{/number}","milestones_url":"https://api.github.com/repos/lrascao/otp/milestones{/number}","notifications_url":"https://api.github.com/repos/lrascao/otp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lrascao/otp/labels{/name}","releases_url":"https://api.github.com/repos/lrascao/otp/releases{/id}","created_at":"2014-06-12T10:43:28Z","updated_at":"2014-06-24T16:36:55Z","pushed_at":"2014-06-26T23:09:18Z","git_url":"git://github.com/lrascao/otp.git","ssh_url":"git@github.com:lrascao/otp.git","clone_url":"https://github.com/lrascao/otp.git","svn_url":"https://github.com/lrascao/otp","homepage":"http://erlang.org","size":110605,"stargazers_count":0,"watchers_count":0,"language":"Erlang","has_issues":true,"has_downloads":false,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"maint"}},"base":{"label":"erlang:maint","ref":"maint","sha":"461dc05384eece7b4b7d84370fb0a2cf96ed2f6d","user":{"login":"erlang","id":153393,"avatar_url":"https://avatars.githubusercontent.com/u/153393?","gravatar_id":"ad362b896bde685c30da5569549cf531","url":"https://api.github.com/users/erlang","html_url":"https://github.com/erlang","followers_url":"https://api.github.com/users/erlang/followers","following_url":"https://api.github.com/users/erlang/following{/other_user}","gists_url":"https://api.github.com/users/erlang/gists{/gist_id}","starred_url":"https://api.github.com/users/erlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erlang/subscriptions","organizations_url":"https://api.github.com/users/erlang/orgs","repos_url":"https://api.github.com/users/erlang/repos","events_url":"https://api.github.com/users/erlang/events{/privacy}","received_events_url":"https://api.github.com/users/erlang/received_events","type":"Organization","site_admin":false},"repo":{"id":374927,"name":"otp","full_name":"erlang/otp","owner":{"login":"erlang","id":153393,"avatar_url":"https://avatars.githubusercontent.com/u/153393?","gravatar_id":"ad362b896bde685c30da5569549cf531","url":"https://api.github.com/users/erlang","html_url":"https://github.com/erlang","followers_url":"https://api.github.com/users/erlang/followers","following_url":"https://api.github.com/users/erlang/following{/other_user}","gists_url":"https://api.github.com/users/erlang/gists{/gist_id}","starred_url":"https://api.github.com/users/erlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erlang/subscriptions","organizations_url":"https://api.github.com/users/erlang/orgs","repos_url":"https://api.github.com/users/erlang/repos","events_url":"https://api.github.com/users/erlang/events{/privacy}","received_events_url":"https://api.github.com/users/erlang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/erlang/otp","description":"Erlang/OTP","fork":false,"url":"https://api.github.com/repos/erlang/otp","forks_url":"https://api.github.com/repos/erlang/otp/forks","keys_url":"https://api.github.com/repos/erlang/otp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erlang/otp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erlang/otp/teams","hooks_url":"https://api.github.com/repos/erlang/otp/hooks","issue_events_url":"https://api.github.com/repos/erlang/otp/issues/events{/number}","events_url":"https://api.github.com/repos/erlang/otp/events","assignees_url":"https://api.github.com/repos/erlang/otp/assignees{/user}","branches_url":"https://api.github.com/repos/erlang/otp/branches{/branch}","tags_url":"https://api.github.com/repos/erlang/otp/tags","blobs_url":"https://api.github.com/repos/erlang/otp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erlang/otp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erlang/otp/git/refs{/sha}","trees_url":"https://api.github.com/repos/erlang/otp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erlang/otp/statuses/{sha}","languages_url":"https://api.github.com/repos/erlang/otp/languages","stargazers_url":"https://api.github.com/repos/erlang/otp/stargazers","contributors_url":"https://api.github.com/repos/erlang/otp/contributors","subscribers_url":"https://api.github.com/repos/erlang/otp/subscribers","subscription_url":"https://api.github.com/repos/erlang/otp/subscription","commits_url":"https://api.github.com/repos/erlang/otp/commits{/sha}","git_commits_url":"https://api.github.com/repos/erlang/otp/git/commits{/sha}","comments_url":"https://api.github.com/repos/erlang/otp/comments{/number}","issue_comment_url":"https://api.github.com/repos/erlang/otp/issues/comments/{number}","contents_url":"https://api.github.com/repos/erlang/otp/contents/{+path}","compare_url":"https://api.github.com/repos/erlang/otp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erlang/otp/merges","archive_url":"https://api.github.com/repos/erlang/otp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erlang/otp/downloads","issues_url":"https://api.github.com/repos/erlang/otp/issues{/number}","pulls_url":"https://api.github.com/repos/erlang/otp/pulls{/number}","milestones_url":"https://api.github.com/repos/erlang/otp/milestones{/number}","notifications_url":"https://api.github.com/repos/erlang/otp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erlang/otp/labels{/name}","releases_url":"https://api.github.com/repos/erlang/otp/releases{/id}","created_at":"2009-11-16T17:17:57Z","updated_at":"2014-06-27T10:54:18Z","pushed_at":"2014-06-25T10:16:48Z","git_url":"git://github.com/erlang/otp.git","ssh_url":"git@github.com:erlang/otp.git","clone_url":"https://github.com/erlang/otp.git","svn_url":"https://github.com/erlang/otp","homepage":"http://erlang.org","size":175972,"stargazers_count":2622,"watchers_count":2622,"language":"Erlang","has_issues":false,"has_downloads":false,"has_wiki":true,"forks_count":826,"mirror_url":null,"open_issues_count":68,"forks":826,"open_issues":68,"watchers":2622,"default_branch":"maint"}},"_links":{"self":{"href":"https://api.github.com/repos/erlang/otp/pulls/411"},"html":{"href":"https://github.com/erlang/otp/pull/411"},"issue":{"href":"https://api.github.com/repos/erlang/otp/issues/411"},"comments":{"href":"https://api.github.com/repos/erlang/otp/issues/411/comments"},"review_comments":{"href":"https://api.github.com/repos/erlang/otp/pulls/411/comments"},"review_comment":{"href":"https://api.github.com/repos/erlang/otp/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/erlang/otp/pulls/411/commits"},"statuses":{"href":"https://api.github.com/repos/erlang/otp/statuses/ab50e4e5121c2c29b8a49916f8ac89e42e37a978"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":6,"deletions":1,"changed_files":1}}