-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Deprecate DISABLE_EXCEPTION_CATCHING=2 #13733
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
Conversation
10c8e61
to
eef07ba
Compare
eef07ba
to
4493480
Compare
04894f5
to
7dbb6c6
Compare
emcc.py
Outdated
@@ -1578,6 +1578,14 @@ def default_setting(name, new_default): | |||
default_setting('ERROR_ON_UNDEFINED_SYMBOLS', 0) | |||
default_setting('WARN_ON_UNDEFINED_SYMBOLS', 0) | |||
|
|||
if shared.Settings.EXCEPTION_CATCHING_ALLOWED: | |||
if 'DISABLE_EXCEPTION_CATCHING' in settings_key_changes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this line different from
if shared.Settings.DISABLE_EXCEPTION_CATCHING:
? If they are different, should we also check if both shared.Settings.DISABLE_EXCEPTION_CATCHING
and shared.Settings.EXCEPTION_CATCHING_ALLOWE
are set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is set if the user specified it explicitly on the command line (regardless of if the value matches the default).
Doing that here allows me to show a warning (or error) if the user ever passed both these options at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then shouldn't we check if both of those two flags are specified in
- One in
Settings
and the other in the command line (and vice versa) - Both in
Settings
(People can modify settings.js) - Both in the command line
Maybe I could be mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory yes, but I don't think we are careful about local modifications to settings.js
. That is, users should use the commandline. Changes to settings.js
by an emscripten developer would assume they know the risk of changing internals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If users are supposed to use the command line, then we should check the case when both of them are in settings_key_change
at least?
Also most of these checking lines in this function directly refer to not settings_key_change
but shared.Settings
directly, which is weird if users are supposed use the command line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general yes, although I think this code covers the cases we care about.
I don't think (2) is much of an issue. I don't think folks should be directly modifying settings.js
, at least not without also also modifying code like this that is somewhat aware of the default. So I think its fair to say that if EXCEPTION_CATCHING_ALLOWED
is set then its the user that set it.
That means if these two conditions are both two they specified both on the command line. That is exactly the case we care about erroring/warning for. I agree we could possibly be more robust here and not make assumptions about the default values.
I added a comment which should hopefully make it a little more clear what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what I was asking is, if we only care about the command line,
why are we not checking settings_key_change
for EXCEPTION_CATCHING_ALLOWED
as we do for DISABLE_EXCEPTION_CATCHING
? We are checking settings_key_changes
for one and checking shared.Settings
for the other. This is the part I don't understand.
Also, if we only care about command lines, why are all other lines in this function directly checking shared.Settings
and now settings_key_changes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If users are supposed to use the command line, then we should check the case when both of them are in
settings_key_change
at least?Also most of these checking lines in this function directly refer to not
settings_key_change
butshared.Settings
directly, which is weird if users are supposed use the command line.
Technically you are correct yes, we should also check for EXCEPTION_CATCHING_ALLOW
in settings_key_changes
.
Maybe this latest version is more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but the problem here is my lack of knowledge of the code around here ;( Sorry. Can someone answer why we check shared.Settings
directly in the code within this function, if we expect the users to use only the command line? I asked why we were not using settings_key_changes
for both settings, but other code around this line all check shared.Settings
directly, so I'm wondering why this should be, or if this should be, different, and how all this works.
When are we merging settings_key_changes
to shared.Settings
? Before running this code or after? If after, checking settings.Changes
only makes sense, but if so you wouldn't have checked settings_key_changes
in the first place...
Sorry for many questions. If taking offline is easier it's fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shared.Settings
reflects that actual current settings which is the sum of:
a) the defaults
b) any user command line settings
c) any changes made by the running of the code here (which updates a lot of settings).
In almost all cases shared.Settings
is the only thing we care about because it represent the actual current setup.
settings_key_changes
is for cases were we actually care about what the user specified on the commandline as opposed to (a) or (c). Its mostly used for diagnostics stuff like this. For example in this case we need to use it so we can tell the different between the default =0
and the command line =0
.
I will make a couple of PRs to clean this up a bit and give settings_key_changes
a better name :)
@@ -1236,15 +1236,16 @@ def test_exceptions_3(self): | |||
self.do_run('src.js', 'Caught exception: Hello\nDone.', args=['2'], no_build=True) | |||
|
|||
def test_exceptions_allowed(self): | |||
self.set_setting('DISABLE_EXCEPTION_CATCHING', 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we set it to 0 instead and not delete the line? The same for other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because we set EXCEPTION_CATCHING_ALLOWED
below and setting them both at the same time is a warning (and we are building with -Werror
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I meant 0, not 1. The default setting for DISABLE_EXCEPTION_CATCHING
is 1, so I thought we needed to turn it off to catch exceptions. Settings DISABLE_EXCEPTION_CATCHING == 0
and EXCEPTION_CATCHING_ALLOWED
at the same time is an error?
Or does setting EXCEPTION_CATCHING_ALLOWED
automatically imply DISABLE_EXCEPTION_CATCHING == 0
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly, setting EXCEPTION_CATCHING_ALLOWED now implies DISABLE_EXCEPTION_CATCHING.
Also setting DISABLE_EXCEPTION_CATCHING
to anything, including 0, at the same time as EXCEPTION_CATCHING_ALLOWED
an error or warning (=2 is a warning =1, or =0 is an error). They should never appear together .. although we need to continue to support =2 for backward compat (we give a warning in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. But why is setting DISABLE_EXCEPTION_CATCHING
to 0 also an error? Are gonna do that internally anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems cleaner to me that they should never be specified together. Don't you think they should be 100% mutually exclusive?
That fact that internally we set DISABLE_EXCEPTION_CATCHING
to zero when EXCEPTION_CATCHING_ALLOWED
is specified is kind of an implementation detail I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but DISABLE_EXCEPTION_CATCHING
is still an exposed settings variable, so I think a warning can be fine, but an error seems weird, especially specifying both of them is semantically correct. Also this will not be backward compatible.
1bc242c
to
5e57d76
Compare
c3ce1a7
to
8e1e6f5
Compare
Added a test for the new error/warning |
8e1e6f5
to
fff017d
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shared.Settings
reflects that actual current settings which is the sum of:a) the defaults
b) any user command line settings
c) any changes made by the running of the code here (which updates a lot of settings).In almost all cases
shared.Settings
is the only thing we care about because it represent the actual current setup.
settings_key_changes
is for cases were we actually care about what the user specified on the commandline as opposed to (a) or (c). Its mostly used for diagnostics stuff like this. For example in this case we need to use it so we can tell the different between the default=0
and the command line=0
.I will make a couple of PRs to clean this up a bit and give
settings_key_changes
a better name :)
Thanks for the explanation. But sorry the same questions ;( :
- @kripken said we mostly only care about command lines. Then why are other checks within this function only check
shared.Settings
and notsettings_key_changes
? Why should this one be different? - You said
shared.Settings
is the only thing we care about. I think that means by this pointsettings_key_changes
has been merged intoshared.Settings
, right? Then why can't we checkshared.Settings
as the final merged info?
I'm commenting this separately because somehow I can't comment anymore in the original thread inline.
tests/test_core.py
Outdated
err = self.expect_fail([EMCC, test_file('hello_world.c')] + self.get_emcc_args()) | ||
self.assertContained('error: DISABLE_EXCEPTION_CATCHING is no longer needed when specifying EXCEPTION_CATCHING_ALLOWED [-Wdeprecated] [-Werror]', err) | ||
|
||
# =0 and =2 should be a hard error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# =0 and =2 should be a hard error | |
# =0 and =1 should be a hard error |
I think having 0 as a warning is more intuitive though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? The definition of =0 today (before this change) means "all functions" .. so specifying additionally an allow list makes no sense at all today.. so there should be no such users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of today the only value that makes sense along with the allow list
is =2
, right? Why should I start allowing =0
+ allow list
in this change? The point of this change is to try to make these two settings as mutually exclusive as possible without breaking backwards compat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I made =0 into a warning too. The difference I don't think is very important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my interpretation of the switches were different. I thought DISABLE_EXCEPTION_CATCHING
as a on-off switch, which we turn on whenever (in all functions or in only some of them) we want to catch exceptions, and EXCEPTION_CATCHING_ALLOWED
as a fine-grained knob to say which function (if not specified, all functions).
I thought this interpretation was more intuitive, but I don't have strong opinions, so please revert if you feel like it.
I think what he means is "When we want to see if a user has changed a given setting, we only need to consider about the command line". When we want to check the setting in general (regardless is seeing it was changed or not), we tend to use
I think I already answered this above: We only use
|
We can instead imply this mode by the presence of the EXCEPTION_CATCHING_ALLOWED` list. This turns DISABLE_EXCEPTION_CATCHING into a binary option which is easier to deal with both internally and externally.
fff017d
to
d3666c0
Compare
Can you explain a little more on what the difference between this case and other 99.9% of cases? This is mostly to understand the code myself and I don't want to block this ;) Thanks for the long explanation! |
Most of the time code only cares about the state of a given setting, so it quite rightly checks the
There is also all the settings checks in JS code which I cannot easily count. (e.g. Occasionally we actually care about how a settings came to be. i.e. did the user explicitly pass on the command line. In those few cases (which only exist in one place) we can use
Most of these are cases where we want to know if the user explicitly enabled something. For example:
Here we have a setting called |
Note that in the |
We can instead imply this mode by the presence of the
EXCEPTION_CATCHING_ALLOWED
list.This turns
DISABLE_EXCEPTION_CATCHING
into a binary optionwhich is easier to deal with both internally and externally.