Skip to content

Support pthread_create#986

Merged
sporksmith merged 7 commits intoshadow:devfrom
sporksmith:pthread_create
Sep 16, 2020
Merged

Support pthread_create#986
sporksmith merged 7 commits intoshadow:devfrom
sporksmith:pthread_create

Conversation

@sporksmith
Copy link
Copy Markdown
Contributor

  • Handle PROT_NONE in mmap
  • Handle mprotect syscall
  • Handle gettid syscall
  • Add and enable pthread_create detached thread test

@sporksmith sporksmith linked an issue Sep 15, 2020 that may be closed by this pull request
@sporksmith sporksmith marked this pull request as ready for review September 15, 2020 19:51
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 15, 2020

Codecov Report

Merging #986 into dev will increase coverage by 0.22%.
The diff coverage is 51.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #986      +/-   ##
==========================================
+ Coverage   52.80%   53.02%   +0.22%     
==========================================
  Files         125      126       +1     
  Lines       18146    18187      +41     
  Branches     4320     4329       +9     
==========================================
+ Hits         9582     9644      +62     
+ Misses       5877     5845      -32     
- Partials     2687     2698      +11     
Flag Coverage Δ
#tests 53.02% <51.16%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/syscall/clone.c 64.10% <0.00%> (+19.65%) ⬆️
src/test/pthreads/test_pthreads.c 45.83% <40.90%> (ø)
src/main/host/syscall_handler.c 53.36% <50.00%> (+0.96%) ⬆️
src/test/memory/test_mmap.c 70.70% <71.42%> (+0.05%) ⬆️
src/main/host/syscall/mman.c 62.29% <77.77%> (+1.42%) ⬆️
src/main/host/thread.c 58.73% <0.00%> (+1.58%) ⬆️
src/support/logger/rust_bindings/src/lib.rs 15.50% <0.00%> (+5.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66b3ca1...4aa916b. Read the comment docs.

Copy link
Copy Markdown
Member

@robgjansen robgjansen left a comment

Choose a reason for hiding this comment

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

LGTM! I'm really falling behind w.r.t. Rust though, so you might wanna get @stevenengler to look over the Rust bits.

@sporksmith
Copy link
Copy Markdown
Contributor Author

@stevenengler could you take a look at the rust?

Copy link
Copy Markdown
Contributor

@stevenengler stevenengler left a comment

Choose a reason for hiding this comment

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

I don't really follow what's happening in handle_mprotect(), but the rust code generally looks good to me.

size: usize,
prot: i32,
) -> c::SysCallReg {
let memory_manager = &mut *memory_manager;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check for a null pointer here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done throughout.

@robgjansen
Copy link
Copy Markdown
Member

Oh yeah, I should have included the general comment that I would have liked some additional comments to explain what was going on in some of the Rust code. Seems like that could be helpful for Steven too.

@stevenengler
Copy link
Copy Markdown
Contributor

Maybe for another PR, but I think the memory manager could use more top-level comments. For example, what the memory manager does and what it's responsible for, what do functions like handle_mprotect and handle_mremap actually do in the context of the memory manager, etc? The regions and mutations seem like a nice abstraction, but I find the code can be hard to follow before I understand what the general goal is.

@sporksmith
Copy link
Copy Markdown
Contributor Author

I have PR #987 q'd up that builds on this one, switching from println to the logging macros. I'll make a pass on the comments in that PR is as well.

@sporksmith sporksmith merged commit f097d96 into shadow:dev Sep 16, 2020
@sporksmith sporksmith deleted the pthread_create branch September 16, 2020 19:03
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.

Support multi-threaded plugins

3 participants