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

[TSan] Unlock mini-trampolines.c #5597

Merged

Conversation

cherusker
Copy link
Contributor

  • guint32 -> gint32: nothing changes since the counters were registered as MONO_COUNTER_INT before. Additionally, by using gint32, existing Interlocked* () and Unlocked* () functions can be used.

  • Avoid "function static" counters and initialise all counters in mono_trampolines_init (): that matches the current (more modern) approach of dealing with counters and it also helps with readability and produces less duplicate code.

  • I think that Interlocked* () is no option when calling trampolines which is why I used Unlocked* () everywhere; sometimes, however, it can be bundled with other locks (domain and trampolines) to interlock some counters implicitly.

@dnfclas
Copy link

dnfclas commented Sep 16, 2017

@cherusker,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot


static_rgctx_trampolines ++;
UnlockedIncrement (&static_rgctx_trampolines); /* use the domain lock to synchronise */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that comment is confusing: the domain lock won't protect accessing static_rgtx_trampoline because the domain lock is, well, per domain 🙂 Otherwise, why would you need UnlockedIncrement here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to add some kind of synchronisation by using the domain lock but the comment is false of course; I will remove it! :)

@@ -1496,10 +1497,9 @@ mono_create_jit_trampoline (MonoDomain *domain, MonoMethod *method, MonoError *e

mono_domain_lock (domain);
g_hash_table_insert (domain_jit_info (domain)->jit_trampoline_hash, method, tramp);
UnlockedIncrement (&jit_trampolines); /* use the domain lock to synchronise */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

inited = TRUE;
}
num_trampolines++;
UnlockedIncrement (&rgctx_num_lazy_fetch_trampolines); /* use the trampolines lock to synchronise */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this comment is wrong (mono_trampolines_lock () is used). However, UnlockedIncrement shouldn't be required here then.

- have all counters in a global place and initialise them in `mono_trampolines_init ()`
- use `Unlocked* ()` and `mono_trampolines_lock ()` to mark / synchronise all racy counters
@cherusker cherusker force-pushed the cherusker-2017-09-16-mini-trampolines-c branch from fb1cf99 to 3cbb352 Compare September 19, 2017 19:45
@cherusker
Copy link
Contributor Author

@lewurm fixed! :)

@lewurm
Copy link
Contributor

lewurm commented Sep 20, 2017

@monojenkins rebase

@monojenkins
Copy link
Contributor

cannot rebase:

  • "Linux i386" state is "success"
  • "Linux x64" state is "success"
  • "Linux ARMv7 hard float" state is "success"
  • "Linux AArch64" state is "success"
  • "OS X i386" state is "success"
  • "OS X x64" state is "success"
  • "Windows i386" state is "failure"
  • "Windows x64" state is "success"

1 similar comment
@monojenkins
Copy link
Contributor

cannot rebase:

  • "Linux i386" state is "success"
  • "Linux x64" state is "success"
  • "Linux ARMv7 hard float" state is "success"
  • "Linux AArch64" state is "success"
  • "OS X i386" state is "success"
  • "OS X x64" state is "success"
  • "Windows i386" state is "failure"
  • "Windows x64" state is "success"

@vargaz vargaz merged commit 5d97d9b into mono:master Sep 21, 2017
@lewurm
Copy link
Contributor

lewurm commented Sep 21, 2017

hmmm, in the i386 windows build:

=============== sgen-domain-unload-2.exe.stdout ===============
............* Assertion at ..\mono\mini\mini-trampolines.c:842, condition `mono_thread_is_gc_unsafe_mode ()' not met

I can't imagine it's related, but it looks suspicious.

@vargaz
Copy link
Contributor

vargaz commented Sep 21, 2017

Its probly not related.

@cherusker cherusker deleted the cherusker-2017-09-16-mini-trampolines-c branch September 21, 2017 15:53
@lewurm lewurm mentioned this pull request Feb 1, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
- have all counters in a global place and initialise them in `mono_trampolines_init ()`
- use `Unlocked* ()` and `mono_trampolines_lock ()` to mark / synchronise all racy counters

Commit migrated from mono/mono@5d97d9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants