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

Mem read 0x0 on 0.12.85 #110

Closed
qhua948 opened this issue Jan 21, 2018 · 13 comments
Closed

Mem read 0x0 on 0.12.85 #110

qhua948 opened this issue Jan 21, 2018 · 13 comments

Comments

@qhua948
Copy link

qhua948 commented Jan 21, 2018

Hi,

When I do a isReadableOrWritable() with a default TCP socket creation, I get a error: memory read failed for 0x0.

I can confirm this issue does not exist in 0.12.82.

@billabt
Copy link
Collaborator

billabt commented Jan 22, 2018

@AlanQuatermain: Any chance you can take a look at this? I'm a bit under the weather today... It seems to be in the area related to the PR from you I just merged. Thanks.

@billabt
Copy link
Collaborator

billabt commented Jan 22, 2018

@AlanQuatermain: I did take a look at it a bit. I looks like the problem is with fd_set.zero(). When that function is called, self gets clobbered...

@billabt
Copy link
Collaborator

billabt commented Jan 22, 2018

@AlanQuatermain: If we can't get it fixed soon, I'll have to back out the FD changes temporarily... This is going to break a few folks.

@billabt
Copy link
Collaborator

billabt commented Jan 22, 2018

The crash bug is now fixed in 0.12.86. Let me know if you have any problems. Thanks.

@billabt billabt closed this as completed Jan 22, 2018
@AlanQuatermain
Copy link
Contributor

Eep; I'll take a look at this and see what I can figure out. I;'m laid up with a broken ankle right now, so I have plenty of time on my hands.

@AlanQuatermain
Copy link
Contributor

At a guess, I think maybe I'm using the UnsafeMutablePointer.initialize(to:count:) method incorrectly. Maybe that's changing the pointer value instead of the contents of the referenced memory? Once Xcode 9.3 finishes installing I'll run it through a debugger a few times to see what actual effect that has (grumbles something about the slowest company-owned laptop he's seen in twenty years…)

@AlanQuatermain
Copy link
Contributor

…or not, since it apparently requires High Sierra and I'm not allowed to install that on my company laptop. Le sigh.

@billabt
Copy link
Collaborator

billabt commented Jan 26, 2018

Sorry to hear about the ankle. I just found out I need some surgery, not sure when but soon. I’ll find out Tuesday. Anyway, if I don’t respond real quick, you’ll know why. 🤪

@AlanQuatermain
Copy link
Contributor

Ooof. Getting old sucks, doesn't it…? 😕

@billabt
Copy link
Collaborator

billabt commented Jan 26, 2018

For sure!!! 😖

@AlanQuatermain
Copy link
Contributor

The calls seem just fine. The actual fd_set doesn't seem to be problematic. I suspect what's actually happening is that the zero() call is clobbering the return address on the stack.

@AlanQuatermain
Copy link
Contributor

Oops, yeah, found it. I'm setting __fd_set_size on macOS to be __DARWIN_FD_SET_SIZE / MemoryLayout<Int32>.stride, i.e. set-size-in-bits / number of bytes in an Int32. That last bit should be number of bits in an Int32. Oops. So zero() on macOS was blanking 256 bytes of memory, not 32 bytes. Sigh. Nice small fix, though.

@billabt
Copy link
Collaborator

billabt commented Jan 27, 2018

Cool. I added a new test for the function that was failing, assuming that passes now, go ahead and redo the PR. Then we can get it merged again. Thanks.

P.S. Take care of that ankle.

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

No branches or pull requests

3 participants