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

Page fault on Redox accessing invalid TLS address #42761

Closed
jackpot51 opened this issue Jun 20, 2017 · 5 comments
Closed

Page fault on Redox accessing invalid TLS address #42761

jackpot51 opened this issue Jun 20, 2017 · 5 comments
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. O-redox Operating system: Redox, https://www.redox-os.org/

Comments

@jackpot51
Copy link
Contributor

jackpot51 commented Jun 20, 2017

Something in this commit range is causing the TLS size to be calculated incorrectly, and the code accesses TLS addresses slightly beyond the size of the TLS:

The first commit and last commit in this range have been tested, with the first working and the last not working:
4bf5c99...0389d40

For example, Command::new attempts to access offset 0x100, but the TLS is only 0xF0

@jackpot51
Copy link
Contributor Author

I have now narrowed it down to this: 4bf5c99...27650ee

@jackpot51
Copy link
Contributor Author

jackpot51 commented Jun 20, 2017

So, the failure is as follows:
Page fault: 04:000001FFFFFFFFF0 at 23:000000000040CF4A

Where 0x1FFFFFFFFF0 is exactly 16 bytes beyond the end of TLS.

The readelf seems to indicate that the TLS is 0xF0 bytes in length:

Elf file type is EXEC (Executable file)
Entry point 0x400130
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x000000 0x0000000000400000 0x0000000000400000 0x02432c 0x02432c R E 0x200000
  LOAD           0x024340 0x0000000000624340 0x0000000000624340 0x001130 0x001230 RW  0x200000
  TLS            0x024340 0x0000000000624340 0x0000000000624340 0x0000e8 0x0000f0 R   0x20
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x10

 Section to Segment mapping:
  Segment Sections...
   00     .init .text .fini .rodata .eh_frame 
   01     .tdata .ctors .dtors .data .bss 
   02     .tdata .tbss 
   03  

Yet, it attempts to access address 0x100 in the TLS:

  40cf41:       64 48 8b 04 25 00 00 00 00    mov    rax,QWORD PTR fs:0x0
  40cf4a:       48 83 b8 00 ff ff ff 00       cmp    QWORD PTR [rax-0x100],0x0

Here you can find the good and bad binaries, with their listings:
init-test.tar.gz

@jackpot51
Copy link
Contributor Author

I have opened this PR to temporarily fix this issue: #42762

frewsxcv added a commit to frewsxcv/rust that referenced this issue Jun 21, 2017
Disable repr(simd) in mem::swap on Redox

This addresses rust-lang#42761
@Mark-Simulacrum Mark-Simulacrum added O-redox Operating system: Redox, https://www.redox-os.org/ A-SIMD Area: SIMD (Single Instruction Multiple Data) labels Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@steveklabnik
Copy link
Member

Triage: this issue is very old. @jackpot51 is it still relevant?

@jackpot51
Copy link
Contributor Author

It hasn't come up again, so maybe not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. O-redox Operating system: Redox, https://www.redox-os.org/
Projects
None yet
Development

No branches or pull requests

3 participants