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

throw() doesn't work in Cling on Windows x64 #17557

Open
1 task done
bellenot opened this issue Jan 29, 2025 · 4 comments
Open
1 task done

throw() doesn't work in Cling on Windows x64 #17557

bellenot opened this issue Jan 29, 2025 · 4 comments
Assignees
Labels

Comments

@bellenot
Copy link
Member

bellenot commented Jan 29, 2025

Check duplicate issues.

  • Checked for duplicates

Description

As discovered in #17536 , throw() makes root silently crash on Windows x64

Reproducer

C:\root-dev\build\x64\debug>root -l
root [0] void fun(){throw std::runtime_error("");}
root [1] fun()

C:\root-dev\build\x64\debug>

But works fine on x86:

C:\root-dev\build\x86\nowinrtdebug\debug>root -l
root [0] void fun(){throw std::runtime_error("const std::vector<std::string> & overload");}
root [1] fun()
Error in <TRint::HandleTermInput()>: std::runtime_error caught: const std::vector<std::string> & overload
root [2]

ROOT version

6.35.01 but most probably all versions

Installation method

built from source

Operating system

Windows (x64)

Additional context

No response

@bellenot bellenot added the bug label Jan 29, 2025
@bellenot bellenot changed the title throw doesn't work on Windows x64 throw() doesn't work on Windows x64 Jan 29, 2025
@pcanal pcanal changed the title throw() doesn't work on Windows x64 throw() doesn't work in Cling on Windows x64 Jan 29, 2025
@pcanal
Copy link
Member

pcanal commented Jan 29, 2025

More exactly it seems to be that Cling throws the exception in a way that the 'catch' in (compiled code in) TRint can not catch it.

The (expected) behavior in linux is:

cmslpc-el9-heavy01:src (master-non-defaults-enums) pcanal$ root.exe -b -l 
root [0] void fun(){throw std::runtime_error("fun threw an exception");}
root [1] fun()
Error in <TRint::HandleTermInput()>: std::runtime_error caught: fun threw an exception

@bellenot
Copy link
Member Author

@pcanal right, like on Windows x86:

C:\root-dev\build\x86\nowinrtdebug\debug>root -l
root [0] void fun(){throw std::runtime_error("const std::vector<std::string> & overload");}
root [1] fun()
Error in <TRint::HandleTermInput()>: std::runtime_error caught: const std::vector<std::string> & overload
root [2]

@devajithvs
Copy link
Contributor

I am wondering if this is due to the usage of setjmp library call in windows. Using: https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp?view=msvc-170 might fix it.

@bellenot
Copy link
Member Author

Thanks @devajithvs , but it fails also in cling...

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

4 participants