Page MenuHomePhabricator

Get Version SWIG wrapper should fill the list it makes
ClosedPublic

Authored by jingham on Mar 27 2019, 6:21 PM.

Details

Summary

The "uint32_t *versions, uint32_t num_versions" wrapper makes a list with the number of elements that SBModule::GetVersion said it returns, but if one of those elements is UINT32_MAX it aborts filling the list. If you then iterate over that returned list in Python, you will get a crash. This patch will fill all the elements GetVersion said it had.

This comes up if you have a library with a version 0.0.0. That returns the (to me) not very sensical result of 2 elements, the first of which is UINT32_MAX.

This patch is just to handle the crash that that result causes in Python. I asked on lldb-dev why GetVersion does this - maybe there is some good reason I don't know. But anyway, I want to treat that as a separate issue.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

jingham created this revision.Mar 27 2019, 6:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2019, 6:21 PM

The fix looks correct, but I am wondering if it wouldn't be possible to test this in a more platform-independent manner. Please see inline comment below.

packages/Python/lldbsuite/test/macosx/version_zero/TestGetVersionZeroVersion.py
2–50

Would it be possible to generate this binary via yaml2obj (e.g. compile it manually, like you did above, and then yamlize it)? Then, if you avoid running the target and just load the module by creating the SBModule object directly from a ModuleSpec, you should get a test that is able to run on all platforms, and not just darwin.

jingham updated this revision to Diff 192677.Mar 28 2019, 10:27 AM

Use yaml2obj to create the dylib with version 0.0.0

This revision was not accepted when it landed; it landed in state Needs Review.Mar 28 2019, 12:24 PM
This revision was automatically updated to reflect the committed changes.