Included USD libraries cause symbol conflict with addons using USD binding #76490

Open
opened 2020-05-07 04:03:59 +02:00 by Brian Savery (AMD) · 27 comments

System Information
Operating system: macOS
Graphics card: N/A

Blender Version
Broken: 2.83 beta
Worked: Never

Included USD libraries cause symbol conflict with addons using USD python bindings. That is, if an addon wants to use USD in it (as a python c-extension most likely), there is an error:

"FATAL ERROR: [TF_DEBUG_ENVIRONMENT_SYMBOL] multiple symbol definitions.  This is usually due to software misconfiguration.  Contact the build team for assistance. (duplicate 'TF_SCRIPT_MODULE_LOADER')
in _Add at line 96 of /Users/brecht/dev/build_darwin/deps/build/usd/src/external_usd/pxr/base/lib/tf/debug.cpp"

Exact steps for others to reproduce the error

  1. Download and extract a build of USD. These ones have python3 bindings (I built my own). https://developer.nvidia.com/usd#bin
  2. Open python editor in blender.
  3. Run commands:
import sys
sys.path.append("PATH_TO_USD/lib/python")   # this is to get the pythonpath right
from pxr import Usd

So I can see two possible solutions to this.

  1. include python bindings with Blender
  2. somehow fix the symbol names in the blender side or in the external USD build so they don't clash. I tried to do this with specifying a different namespace name than "pxr" in the USD build but this didn't seem to help.
    3, link python bindings of USD against blender.exe (Not sure how/if this would work)

Willing to work on the solution, but wanted input from Blender developers.

**System Information** Operating system: macOS Graphics card: N/A **Blender Version** Broken: 2.83 beta Worked: Never Included USD libraries cause symbol conflict with addons using USD python bindings. That is, if an addon wants to use USD in it (as a python c-extension most likely), there is an error: ``` "FATAL ERROR: [TF_DEBUG_ENVIRONMENT_SYMBOL] multiple symbol definitions. This is usually due to software misconfiguration. Contact the build team for assistance. (duplicate 'TF_SCRIPT_MODULE_LOADER') in _Add at line 96 of /Users/brecht/dev/build_darwin/deps/build/usd/src/external_usd/pxr/base/lib/tf/debug.cpp" ``` **Exact steps for others to reproduce the error** 1. Download and extract a build of USD. These ones have python3 bindings (I built my own). https://developer.nvidia.com/usd#bin 2. Open python editor in blender. 3. Run commands: ``` import sys sys.path.append("PATH_TO_USD/lib/python") # this is to get the pythonpath right from pxr import Usd ``` So I can see two possible solutions to this. 1. include python bindings with Blender 2. somehow fix the symbol names in the blender side or in the external USD build so they don't clash. I tried to do this with specifying a different namespace name than "pxr" in the USD build but this didn't seem to help. 3, link python bindings of USD against blender.exe (Not sure how/if this would work) Willing to work on the solution, but wanted input from Blender developers.
Author
Member

Added subscriber: @BrianSavery

Added subscriber: @BrianSavery

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'
Sybren A. Stüvel self-assigned this 2020-05-07 10:02:51 +02:00

Hi Brian!

Broken: 2.83 beta

For future reference, unless a version is an official release, please include the Git hash in reports. The easiest to get this from Blender itself is to click Help → Report a Bug.

include python bindings with Blender

For this the USD library needs to support Python 3.7 first. It's still only compatible with Python 2.7. I don't think Blender should switch to a third party version of the library either.

somehow fix the symbol names in the blender side or in the external USD build so they don't clash. I tried to do this with specifying a different namespace name than "pxr" in the USD build but this didn't seem to help.

This is done in Blender as well (see -DPXR_SET_INTERNAL_NAMESPACE=usdBlender in usd.cmake), so the USD library should not conflict. If this namespace is not used in certain parts of the USD library, that would defeat the purpose of that option. This would be a bug in USD, though, and not in Blender.

Hi Brian! > Broken: 2.83 beta For future reference, unless a version is an official release, please include the Git hash in reports. The easiest to get this from Blender itself is to click Help → Report a Bug. > include python bindings with Blender For this the USD library needs to support Python 3.7 first. It's still [only compatible with Python 2.7](https://github.com/PixarAnimationStudios/USD/blob/master/VERSIONS.md). I don't think Blender should switch to a third party version of the library either. > somehow fix the symbol names in the blender side or in the external USD build so they don't clash. I tried to do this with specifying a different namespace name than "pxr" in the USD build but this didn't seem to help. This is done in Blender as well (see `-DPXR_SET_INTERNAL_NAMESPACE=usdBlender` in [usd.cmake](https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/cmake/usd.cmake)), so the USD library should not conflict. If this namespace is not used in certain parts of the USD library, that would defeat the purpose of that option. This would be a bug in USD, though, and not in Blender.
Author
Member

Changed status from 'Archived' to: 'Resolved'

Changed status from 'Archived' to: 'Resolved'
Author
Member

@dr.sybren

You're mistaken about the python3 compatibility:
https://github.com/PixarAnimationStudios/USD/blob/master/CHANGELOG.md#build
USD 20.05 supports Python 3:
"Added support for Python 3. This may be enabled by specifying PXR_USE_PYTHON_3=TRUE when running cmake or by running build_usd.py with Python 3."

The nvidia ones have 3.6 support but you can build master with 3.7: https://developer.nvidia.com/usd-20.02-binary-windows-vs2017-python-3.6

Regardless, if I was using a USD builds with python 2 bindings I would not have gotten to this point.

@dr.sybren You're mistaken about the python3 compatibility: https://github.com/PixarAnimationStudios/USD/blob/master/CHANGELOG.md#build USD 20.05 supports Python 3: "Added support for Python 3. This may be enabled by specifying PXR_USE_PYTHON_3=TRUE when running cmake or by running build_usd.py with Python 3." The nvidia ones have 3.6 support but you can build master with 3.7: https://developer.nvidia.com/usd-20.02-binary-windows-vs2017-python-3.6 Regardless, if I was using a USD builds with python 2 bindings I would not have gotten to this point.
Author
Member

Furthermore. After filing this I am able to work around this by building blender from source without USD support (which obviously removes the symbol conflict), but I would claim that's not a valid workaround for most users

Furthermore. After filing this I am able to work around this by building blender from source without USD support (which obviously removes the symbol conflict), but I would claim that's not a valid workaround for most users
Author
Member

Changed status from 'Resolved' to: 'Archived'

Changed status from 'Resolved' to: 'Archived'
Author
Member

Not sure about status how that got changed. Sybren marked it in valid, which I think is erroneous.

Not sure about status how that got changed. Sybren marked it in valid, which I think is erroneous.
Author
Member

Might this be related to https://developer.blender.org/T76442 ?

Might this be related to https://developer.blender.org/T76442 ?

Changed status from 'Archived' to: 'Needs User Info'

Changed status from 'Archived' to: 'Needs User Info'

In #76490#926093, @BrianSavery wrote:
You're mistaken about the python3 compatibility:
https://github.com/PixarAnimationStudios/USD/blob/master/CHANGELOG.md#build
USD 20.05 supports Python 3:

I'm very happy to be wrong here :) Still, on Linux they only test with Python 3.6, whereas both the VFX Reference Platform and Blender are on 3.7. That's an infintesemally small difference compared to 2.7 though!

If it is indeed related to #76442, @BrianSavery could you maybe test what happens when you build Blender with the conflicting symbols added to source/creator/blender.map? That should hide those symbols; if that is enough I'd be happy to include that in Blender and get things moving forward.

> In #76490#926093, @BrianSavery wrote: > You're mistaken about the python3 compatibility: > https://github.com/PixarAnimationStudios/USD/blob/master/CHANGELOG.md#build > USD 20.05 supports Python 3: I'm very happy to be wrong here :) Still, on Linux they only test with Python 3.6, whereas both the VFX Reference Platform and Blender are on 3.7. That's an infintesemally small difference compared to 2.7 though! If it is indeed related to #76442, @BrianSavery could you maybe test what happens when you build Blender with the conflicting symbols added to `source/creator/blender.map`? That should hide those symbols; if that is enough I'd be happy to include that in Blender and get things moving forward.
Author
Member

Yep will test. Here's what I've done so far:

  1. macOS with standard blender build - Error above
  2. macOS build with USD disabled - Ok
  3. ubuntu build with 3.7 build of USD - Ok.
Yep will test. Here's what I've done so far: 1. macOS with standard blender build - Error above 2. macOS build with USD disabled - Ok 3. ubuntu build with 3.7 build of USD - Ok.
Member

Added subscriber: @jta

Added subscriber: @jta
Member

Added subscriber: @ankitm

Added subscriber: @ankitm
Member

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Member

(since it's a todo)

(since it's a todo)

Added subscriber: @lvxejay

Added subscriber: @lvxejay

Added subscriber: @mel

Added subscriber: @mel

Added subscriber: @YegorSmirnov

Added subscriber: @YegorSmirnov

Is there any advancement on this issue?
I think that adding a custom namespace is the solution, like specified here:

https://github.com/PixarAnimationStudios/USD/blob/release/BUILDING.md#usd-developer-options

Is there any advancement on this issue? I think that adding a custom namespace is the solution, like specified here: https://github.com/PixarAnimationStudios/USD/blob/release/BUILDING.md#usd-developer-options

This is also an issue for projects like https://github.com/GPUOpen-LibrariesAndSDKs/BlenderUSDHydraAddon

But apparently only on macOS?

This is also an issue for projects like https://github.com/GPUOpen-LibrariesAndSDKs/BlenderUSDHydraAddon But apparently only on macOS?

Added subscriber: @JasonSchleifer

Added subscriber: @JasonSchleifer

Blender already builds USD with a custom namespace: https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/cmake/usd.cmake$36

I'm certainly open to suggestions on how to solve this issue.

Blender already builds USD with a custom namespace: https://developer.blender.org/diffusion/B/browse/master/build_files/build_environment/cmake/usd.cmake$36 I'm certainly open to suggestions on how to solve this issue.

Added subscriber: @karlhendrikse

Added subscriber: @karlhendrikse

Using a custom namespace doesn't fix this because the problem isn't a symbol collision.

The problem is that when any shared library is loaded into the process, the USD library looks in the library's Mach-O headers and pulls out function pointers for all special "constructors" and calls them. The USD library contains a macro one can use to declare such "constructors", and they are stored in ".pxrctor" sections in the binary. Some of the constructors declared in the USD library cause the application to abort when run multiple times, which is what happens when there are multiple instances of the library loaded, both searching for ".pxrctor" sections and calling all "constructors" when libraries are loaded.

One solution I found is to change the name used for the sections in one instance of the USD library so the instances aren't trying to run each other's "constructors". Changing all occurrences of pxrctor into fooctor (and likewise pxrdtor into foodtor) in the USD library fixed the problem for me.

(I had this problem in a separate application, but I found this page when searching for the solution and after figuring it out for myself I thought posting here might be helpful.)

Using a custom namespace doesn't fix this because the problem isn't a symbol collision. The problem is that when any shared library is loaded into the process, the USD library looks in the library's Mach-O headers and pulls out function pointers for all special "constructors" and calls them. The USD library contains a macro one can use to declare such "constructors", and they are stored in "`.pxrctor`" sections in the binary. Some of the constructors declared in the USD library cause the application to abort when run multiple times, which is what happens when there are multiple instances of the library loaded, both searching for "`.pxrctor`" sections and calling all "constructors" when libraries are loaded. One solution I found is to change the name used for the sections in one instance of the USD library so the instances aren't trying to run each other's "constructors". Changing all occurrences of `pxrctor` into `fooctor` (and likewise `pxrdtor` into `foodtor`) in the USD library fixed the problem for me. (I had this problem in a separate application, but I found this page when searching for the solution and after figuring it out for myself I thought posting here might be helpful.)
Philipp Oeser removed the
Interest
Pipeline, Assets & IO
label 2023-02-10 08:54:19 +01:00

Unassigning myself, as I'm no longer active in the Pipeline, Assets & IO module.

Unassigning myself, as I'm no longer active in the Pipeline, Assets & IO module.
Sybren A. Stüvel removed their assignment 2023-11-07 16:14:21 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#76490
No description provided.