openjpeg icon indicating copy to clipboard operation
openjpeg copied to clipboard

getenv is not allowed in certain cases causing linking issues.

Open malaterre opened this issue 7 years ago • 11 comments

getenv is not allowed in certain cases causing linking issues. This fix should be pushed to the openjpeg group. Thanks to Chris for the fix.

malaterre avatar Mar 02 '17 10:03 malaterre

Patch is at:

  • http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f8d299c;hp=8e8831a02f172490d7b175e54c7d15814acacea4

malaterre avatar Mar 02 '17 10:03 malaterre

Can you give more details why getenv() would cause issues ? This is conformant with C89

rouault avatar Jul 29 '17 16:07 rouault

Well the original statement was about a specific linking issue. I am guessing this is some kind of hardened libc implementation. I could not find a specific one line reproducer, but basically you cannot use getenv safely from a multithreaded application, see for instance first link in google: http://www.club.cc.cmu.edu/~cmccabe/blog_the_setenv_fiasco.html

Before this gets into an infinite thread (bad pun intended), I understand that the root issue is the call to setenv, while openjpeg library makes no such call, the application level could make one such call.

malaterre avatar Sep 25 '17 08:09 malaterre

getenv() is not available when targetting Universal Windows Platform.

https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps

Tryum avatar Mar 15 '18 13:03 Tryum

@Tryum Would the suggested fix at http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f8d299c;hp=8e8831a02f172490d7b175e54c7d15814acacea4 work for UWP ? If not, can you propose something ?

rouault avatar Mar 15 '18 13:03 rouault

I think it would fix it, I just wrote a similar patch to use openjpeg through vcpkg ( Microsoft/vcpkg#208 )

Tryum avatar Mar 15 '18 13:03 Tryum

@Tryum Just add a look at https://github.com/Microsoft/vcpkg/pull/208 and can't see how it relates to getenv.

Anyone please submit a pull request

rouault avatar Mar 15 '18 14:03 rouault

The issue I linked doesn't relate to getenv, just to openjpeg. I'm using openjpeg through vcpkg. I'll send a pull request of my fix once I'm sure I fixed my UWP issue.

Tryum avatar Mar 15 '18 14:03 Tryum

@Tryum any update ?

malaterre avatar Feb 08 '21 08:02 malaterre

Not working on that subject nor the company anymore... I can't remember how it was finally solved. Sorry.

Tryum avatar Feb 08 '21 09:02 Tryum

Quick google search reveal:

  • https://gitlab.freedesktop.org/gstreamer/cerbero/-/blob/1c7f523a649753351293510d6711647374f62e0c/recipes/orc/0001-orc-Implement-a-windows-helper-for-getenv.patch

Who has access to UWP to test a patch ?

malaterre avatar Feb 09 '21 06:02 malaterre