qiansunn / naclports

Automatically exported from code.google.com/p/naclports
0 stars 0 forks source link

Negative thread IDs in naclports/python #185

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the NaCl python interactive shell (e.g. 
http://commondatastorage.googleapis.com/naclports/builds/pepper_40/trunk-154-gea
cd680/publish/python/pnacl/index.html)
2. import threading
3. threading.current_thread().ident

What is the expected output? What do you see instead?
I expected a non-negative number, but got "-18083752" instead. Not sure if this 
is a bug, or working as intended.

What version of the product are you using? On what operating system?
Chrome 39 (64-bit)
Linux

Please provide any additional information below.

Original issue reported on code.google.com by petrcer...@chromium.org on 16 Jan 2015 at 5:04

GoogleCodeExporter commented 9 years ago
I think this is working as intended.  IIUC current_thread().ident runs 
pthread_self() which gives a pthread_t.

pthread_t under PNaCl is a pointer type which, when python coverts it to an 
integer will be negative if its in the upper half of the 32-bit address space.

I ran a test program on my machine and got 0xfefe04b0, which is -16907088.

Original comment by sbc@google.com on 21 Jan 2015 at 10:06