{"action":"created","issue":{"url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/187","labels_url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/187/comments","events_url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/187/events","html_url":"https://github.com/open-watcom/open-watcom-v2/issues/187","id":96894309,"number":187,"title":"Win32 __init_stack_limits() assumes more stack than provided by Windows 3.1","user":{"login":"joncampbell123","id":6245486,"avatar_url":"https://avatars.githubusercontent.com/u/6245486?v=3","gravatar_id":"","url":"https://api.github.com/users/joncampbell123","html_url":"https://github.com/joncampbell123","followers_url":"https://api.github.com/users/joncampbell123/followers","following_url":"https://api.github.com/users/joncampbell123/following{/other_user}","gists_url":"https://api.github.com/users/joncampbell123/gists{/gist_id}","starred_url":"https://api.github.com/users/joncampbell123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joncampbell123/subscriptions","organizations_url":"https://api.github.com/users/joncampbell123/orgs","repos_url":"https://api.github.com/users/joncampbell123/repos","events_url":"https://api.github.com/users/joncampbell123/events{/privacy}","received_events_url":"https://api.github.com/users/joncampbell123/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-23T20:04:08Z","updated_at":"2015-07-26T17:43:35Z","closed_at":"2015-07-26T17:43:35Z","body":"From bld/clib/startup/c/stklmwnt.c:\r\n\r\n    if( WIN32_IS_NT ) {\r\n        low += 4096 * 3;\r\n    } else if( WIN32_IS_WIN32S ) {\r\n        low += 4096 * (16 + 2);\r\n    } else {\r\n        // Win 95\r\n        low += 4096 * (16 + 3);\r\n    }\r\n\r\nThe problem with the WIN32_IS_WIN32S case is that, according to the PE header, only 64KB of stack is reserved (SizeOfStackReserve == 0x10000), yet it reports the stack base + 72KB as the low point. This is why if you run a Win32s executable compiled with Open Watcom under Windows 3.1, nothing shows up because the C library aborts with a stack overflow message right away.\r\n\r\nI already made a crude homegrown patch of my own, but I suggest two changes in the main branch considering that there might be enough thunking about in the Win32s world for someone to add that kind of safety margin.\r\n\r\nThe first, is that it would be better for __init_stack_limits() to check that low < top and that there's sufficient stack space after the initial low adjustment. So in the Windows 3.1 Win32s case, the code should see that adding 72KB to the base pushes it past the top, and opt for another low point, say, 16KB from base.\r\n\r\nThe other change is that, if the default is to add 72KB to the low point, then perhaps the default stack size for the Win32s target should be 128KB instead of 64KB. Or, wlink could take the Windows 95 approach and use a default stack reserve of 1MB.\r\n\r\nAddressing this issue would resolve one last problem with Open Watcom and compiling Win32s applications for Windows 3.1."},"comment":{"url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/comments/125022148","html_url":"https://github.com/open-watcom/open-watcom-v2/issues/187#issuecomment-125022148","issue_url":"https://api.github.com/repos/open-watcom/open-watcom-v2/issues/187","id":125022148,"user":{"login":"jmalak","id":2017260,"avatar_url":"https://avatars.githubusercontent.com/u/2017260?v=3","gravatar_id":"","url":"https://api.github.com/users/jmalak","html_url":"https://github.com/jmalak","followers_url":"https://api.github.com/users/jmalak/followers","following_url":"https://api.github.com/users/jmalak/following{/other_user}","gists_url":"https://api.github.com/users/jmalak/gists{/gist_id}","starred_url":"https://api.github.com/users/jmalak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmalak/subscriptions","organizations_url":"https://api.github.com/users/jmalak/orgs","repos_url":"https://api.github.com/users/jmalak/repos","events_url":"https://api.github.com/users/jmalak/events{/privacy}","received_events_url":"https://api.github.com/users/jmalak/received_events","type":"User","site_admin":false},"created_at":"2015-07-26T17:43:35Z","updated_at":"2015-07-26T17:43:35Z","body":"OK. For now I remove comment from change bld/clib/startup/c/stklmwnt.c about it looks like incorrect.\r\nIf you have any news reopen this incident to fix what is necessary.\r\nI think that now WIN32s should be fully supported by OW. \r\nThe linker problem with reserved/commited stack size for WIN32 was very old."}}