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

CoreHdfsFile init expects non-PyObjects #291

Open
simleo opened this issue Mar 19, 2018 · 0 comments
Open

CoreHdfsFile init expects non-PyObjects #291

simleo opened this issue Mar 19, 2018 · 0 comments
Assignees
Labels

Comments

@simleo
Copy link
Member

simleo commented Mar 19, 2018

At the C level, the open_file method is based on a hack where the libhdfs C structs for the fs and file objects are passed directly to the init method of CoreHdfsFile (a Python object), taking advantage of the fact that the "O" format string in PyArg_Parse* doesn't perform any actual type checking, but rather stores the object as-is. This means that all hell can break loose if a PyObject is passed to the method and, later on, anything is attempted that tries to use the self->file or self->fs refs.

We don't see this much in practice because directly instantiating CoreHdfsFile is explicitly discouraged in the docs, but it's still possible (and not too hard) to break the interpreter due to this.

For instance, this is OK:

import pydoop.hdfs as hdfs

f = hdfs.open("foo")
print(f.readline())
f.close()

But this:

import pydoop.hdfs as hdfs

f = hdfs.open("foo")
core_file = f.f.raw
core_fs = f.fs.fs
core_file.__init__(core_fs, core_file, "hosts", "r")
print(f.readline())
f.close()

Crashes the JVM with a core dump.

@simleo simleo added the bug label Mar 19, 2018
@simleo simleo self-assigned this Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant