Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmake dev causes "Wrong descriptor" error #3138

Closed
SirLynix opened this issue Dec 5, 2022 · 9 comments
Closed

xmake dev causes "Wrong descriptor" error #3138

SirLynix opened this issue Dec 5, 2022 · 9 comments
Labels
Milestone

Comments

@SirLynix
Copy link
Member

SirLynix commented Dec 5, 2022

Xmake Version

dev

Operating System Version and Architecture

Windows 11

Describe Bug

I was building a project using emscripten on Windows, updated to the latest xmake dev version (xmake update dev) and when I tried to build, I couldn't because of this error:

C:\Projets\Perso\NazaraNext\NazaraEngine>xmake build -j1 -vD GraphicsTest
examples assets are up-to-date, ignoring
[ 71%]: compiling.debug src\Nazara\OpenGLRenderer\OpenGLShaderModule.cpp
emcc.bat -c -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -O0 -std=c++17 -Iinclude -Isrc -DNAZARA_DEBUG -DNAZARA_BUILD -DNAZARA_UTILS_WINDOWS_NT6=1 -DNAZARA_RENDERER_BUILD -DNAZARA_RENDERER_DEBUG -DNAZARA_RENDERER_EMBEDDEDBACKENDS -DNAZARA_OPENGLRENDERER_BUILD -DNAZARA_OPENGLRENDERER_DEBUG -DNZSL_STATIC -isystem thirdparty\include -isystem C:\Users\lynix\AppData\Local\.xmake\packages\n\nzsl\2022.11.19\84193d7c82b74fd490037feaff449a5a\include -isystem C:\Users\lynix\AppData\Local\.xmake\packages\f\fmt\9.1.0\5d3b23ee190d4b21b39394459979443a\include -isystem C:\Users\lynix\AppData\Local\.xmake\packages\f\frozen\1.1.1\907ca7fe6c524a63876aa54795418521\include -isystem C:\Users\lynix\AppData\Local\.xmake\packages\o\ordered_map\v1.0.0\1c77d88f66fa459b9772585ed8203f99\include -isystem C:\Users\lynix\AppData\Local\.xmake\packages\n\nazarautils\2022.11.19\64f8e54951e342af9d1b22480ef55385\include -g -sNO_DISABLE_EXCEPTION_CATCHING -sERROR_ON_WASM_CHANGES_AFTER_LINK -o build\.objs\NazaraRenderer\wasm\wasm32\debug\src\Nazara\OpenGLRenderer\OpenGLShaderModule.cpp.o src\Nazara\OpenGLRenderer\OpenGLShaderModule.cpp
error: @programdir\modules\private\async\runjobs.lua:256: @programdir\modules\private\action\build\object.lua:91: @programdir\modules\core\tools\gcc.lua:704: emcc: error: 'E:/GitHub/emsdk/upstream/bin\clang.exe --version' failed: [WinError 6] Wrong descriptor
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:897]:
    [@programdir\modules\core\tools\gcc.lua:704]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [@programdir\modules\core\tools\gcc.lua:645]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\modules\private\action\build\object.lua:91]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:104]: in function 'build_object'
    [@programdir\modules\private\action\build\object.lua:129]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:232]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:218]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:404]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:897: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\modules\private\async\runjobs.lua:256: in field 'catch'
        @programdir\core\sandbox\modules\try.lua:123: in global 'try'
        @programdir\modules\private\async\runjobs.lua:218: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397>

I think it's related to the execution of .bat or something like that, I don't have this error when building a Windows application.

Expected Behavior

That it compiles.

Project Configuration

No response

Additional Information and Error Logs

Everything works fine with the current binary (2.7.3) and the latest script, after doing

xmake update -f
xmake update -s dev
@SirLynix SirLynix added the bug label Dec 5, 2022
@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

It turns out that it is indeed related to the recent modifications.

I have encountered similar problems with bat twice before and have tried to make some changes to fix it, but it seems that it cannot fully support all bat calls.

If it is enabled after UpdateProcThreadAttribute, it seems that the root of the problem is processing stdin/stdout, but I am not sure how to handle it better.

@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

If I pass all std handle to inherit them, it work.

        os.execv(program, argv, {stdout=os.tmpfile(), stderr=os.tmpfile(), stdin=infile})

But I pass partial std handles, it does not work.

        os.execv(program, argv, {stdout=os.tmpfile(), stderr=os.tmpfile()})

@SirLynix
Copy link
Member Author

SirLynix commented Dec 6, 2022

so this error could be caused by having a missing stderr handle? if stderr is missing can't be pass stdout again?

@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

I'm not sure how to set the missing stdxx handles. Both setting them to UpdateProcThreadAttribute and just setting them to StartupInfo.hStdxxx will have some issues.

@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

case1

  1. pass stdout (file/pipe)to UpdateProcThreadAttribute
  2. pass GetStdHandle(stdin/stderr) to StartupInfo and UpdateProcThreadAttribute

it maybe cause invalid handle in build-artifacts ci when running gh

case2

  1. pass stdout (file/pipe) to UpdateProcThreadAttribute
  2. pass GetStdHandle(stdin/stderr) to StartupInfo

it maybe cause detect vs fails, call vcallvars.bat failed.

case3 (now)

  1. jsut pass stdout (file/pipe) to UpdateProcThreadAttribute
  2. do not pass GetStdHandle(stdin/stderr) to StartupInfo , use default empty values (INVALID_HANDLE_VALUE).

it wil fix case1 and case2, but it will cause your problem. (emcc.bat)

@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

If I revert this patch tboox/tbox@e64ac7f , case2/case3 will works fine, but case1 does not work. hmm..

error: failed to run git: fork/exec C:\Program Files\Git\bin\git.exe: The handle is invalid.

https://github.com/xmake-mirror/build-artifacts/actions/runs/3627766237/jobs/6118046735

@waruqi waruqi added this to the v2.7.4 milestone Dec 6, 2022
@waruqi
Copy link
Member

waruqi commented Dec 6, 2022

I have improved it. xmake update dev

@SirLynix
Copy link
Member Author

SirLynix commented Dec 6, 2022

It's working for emcc.bat and cl.exe 👍

@waruqi waruqi closed this as completed Dec 6, 2022
@waruqi
Copy link
Member

waruqi commented Dec 21, 2023

stdout does not work when call with {stdin = ""} on windows. #4527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants