Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uplibnative: main task has bad thread local data on windows #13259
Comments
This comment has been minimized.
This comment has been minimized.
|
What happens if you add this to the top of the unsafe { ::std::rt::stack::record_sp_limit(0); } |
This comment has been minimized.
This comment has been minimized.
|
Wow, that one fixed all problems! |
This comment has been minimized.
This comment has been minimized.
|
See this comment for how I discovered that. It sounds like this modification to the TIB is causing something to fail when some initial library is loaded. At this point, I think we need to figure out the minimal set of things that need to be done to "get things loaded". This minimal set of things can be done whenever libnative starts up, but I'm not sure what the minimal set of things are. The minimal set of things includes "boot libgreen and spawn a task" because that's what using libgreen will do, but it would be nice to narrow it down more than that! Does that make sense? |
This comment has been minimized.
This comment has been minimized.
|
The behavior seems to suggest that it's not a good idea to modify fs:0x14 is known as "ArbitraryUserPointer", but Raymond Chen said that it's "arbitrary" for internals, not for application. (it's safe to believe what Raymond says!) #include <windows.h>
int main() {
asm("movl $1234, %fs:0x14");
MessageBoxA(0, "abc", "abc", 0);
}So I want to investigate if LLVM can use TIB's stack bounds instead of ArbitraryUserPointer for segmented stack. We use them in |
This comment has been minimized.
This comment has been minimized.
|
I've replaced all occurrence (including llvm) of |
This comment has been minimized.
This comment has been minimized.
|
Are we sure that the kernel won't modify those TIB values to some other internal stack limit? (just a mild concern of mine) |
This comment has been minimized.
This comment has been minimized.
|
Hmm, BTW, the librand issue ( |
alexcrichton
referenced this issue
Apr 4, 2014
Closed
stdin().read_u8 results in unknown error (OS Error 8 (FormatMessageW() returned error 15105)) #13304
This comment has been minimized.
This comment has been minimized.
|
Hm, interestingly your C code example works for me. I think I'm on a windows 7 VM. The |
huonw
added
the
A-windows
label
Apr 4, 2014
This comment has been minimized.
This comment has been minimized.
|
How about using the actual TLS API for this? TlsGetValue() and TlsSetValue() are both like 10 instructions long. Is this enough overhead to bother messing with undocumented TIB fields? And if it is, maybe we could write directly into TLS slots (after allocating one via TlsAlloc(), of course). |
This comment has been minimized.
This comment has been minimized.
|
It may be possible to do that, although this is an extra bit of overhead an all function calls made in rust (each function is preceded with this information). I also fear that the root cause is still unknown so it's too soon to move away from the current implementation (which seems like it should work). |
alexcrichton
closed this
Apr 21, 2014
alexcrichton
reopened this
Apr 21, 2014
This comment has been minimized.
This comment has been minimized.
|
Actually, function prologues could use current bottom of stack (fs:[8]) for quick comparison, and only check the hard stack limit when kicked off of the fast path. The latter would happen only when stack commit limit is about to grow anyway, so it wouldn't matter for perf. |
This comment has been minimized.
This comment has been minimized.
I tend to believe Raymond, when he says that "ArbitraryUserPointer" is reserved for OS use. Looks like you've discovered this yourself too. |
klutzy
referenced this issue
May 28, 2014
Closed
`std::io::fs::symlink` returns `IoError: OS Error 0` on windows #14490
alexcrichton
referenced this issue
Aug 6, 2014
Closed
rustdoc --test does not work on windows #16275
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Aug 6, 2014
alexcrichton
referenced this issue
Aug 6, 2014
Merged
rustdoc: Run all work in a separate task #16288
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Aug 6, 2014
Zoxc
added a commit
to Zoxc/rust
that referenced
this issue
Aug 6, 2014
Zoxc
added a commit
to Zoxc/rust
that referenced
this issue
Aug 11, 2014
retep998
referenced this issue
Aug 12, 2014
Closed
std::os::MemoryMap::new() fails on Windows #16070
This was referenced Aug 12, 2014
Zoxc
added a commit
to Zoxc/rust
that referenced
this issue
Aug 16, 2014
This comment has been minimized.
This comment has been minimized.
|
Nominating, I just spent an hour tracking this down for what feels like the 10th time. This causes syscalls to fail at random for no apparent reason, and the errors are often quite misleading. |
mrmonday
added a commit
to mrmonday/rust
that referenced
this issue
Aug 25, 2014
This comment has been minimized.
This comment has been minimized.
|
P-backcompat-libs, 1.0 milestone. |
pnkfelix
added
P-backcompat-libs
and removed
I-nominated
labels
Aug 28, 2014
pnkfelix
added this to the 1.0 milestone
Aug 28, 2014
This comment has been minimized.
This comment has been minimized.
|
@Zoxc what's the state of your stack probe patch? |
This comment has been minimized.
This comment has been minimized.
|
Ah, so this is why |
This comment has been minimized.
This comment has been minimized.
|
@brson: AFAIK, we already have stack probes on Windows via |
This comment has been minimized.
This comment has been minimized.
|
@brson The error message reporting (#16388) is mostly working. I suspect there's some unrelated error breaking it on Windows). I've yet to find someone who will commit my x86 LLVM patches (which adds support for stack probes on non-Windows x86 systems), but you could just adapt my code (Zoxc@ecec992) to use stack probes on Windows only. Since fixing this error is more important than nice stack overflow messages (which will added later anyway). |
thestinger
referenced this issue
Sep 12, 2014
Closed
mingw support for C11/C++11-style thread-local data is broken #10315
This comment has been minimized.
This comment has been minimized.
|
Just FYI: this also appears to break |
This comment has been minimized.
This comment has been minimized.
|
Working on adapting @Zoxc's patch now. |
brson
self-assigned this
Sep 19, 2014
This comment has been minimized.
This comment has been minimized.
|
Win32 backtrace also broken! |
brson
added a commit
to brson/rust
that referenced
this issue
Sep 25, 2014
brson
added a commit
to brson/rust
that referenced
this issue
Sep 25, 2014
This comment has been minimized.
This comment has been minimized.
|
@klutzy I can't reproduce the problem on either 64-bit win8 or 32-bit win 2008 using your test case in the op. FormatMessage succeeds producing 'Incorrect function.'. |
klutzy commentedApr 2, 2014
More investigation from #13073.
If the code is bulit with
--cfg green,--cfg rawor--cfg spawn, it works as expected. However, if it is built with no cfg, it behaves strangely:FormatMessageW()fails to get system locale mssage, andMessageBoxA()shows gui message box with non-system-themed border.I guess the main task has bad thread-local data due to
libnative::start().cc @alexcrichton