[ 
https://issues.apache.org/jira/browse/DAEMON-401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831657#comment-16831657
 ] 

Jonathan Gallimore commented on DAEMON-401:
-------------------------------------------

Hi Mark

Thanks for the followup and apologies for my delayed reply. Thanks for the 
build environment information; I should be able to replicate that setup on my 
hardware, and I'm happy to expand on any documentation.

Did you manage to test the issue? Reproducing it is tricky - I did try the 
binaries from the project. I'm able to set the environment variables, and they 
are picked up in Java code in the JVM - everything is good there.

If the JVM then calls out to a JNI library that is built with a later version 
of Visual Studio (MSVC 14 in my case), and that JNI dll uses getenv(), the 
issue is visible. Using a JNI library compiled with earlier versions of Visual 
Studio, or MinGW doesn't show the issue.

In an ideal world, I'd recompile the JNI library, but I don't have control over 
that or its dependencies.

If I produce a test case, could I get some pointers with regard to my patch, or 
discuss some potential work-arounds?

Thanks

Jon

> Environment variables set on service not available in JNI dll
> -------------------------------------------------------------
>
>                 Key: DAEMON-401
>                 URL: https://issues.apache.org/jira/browse/DAEMON-401
>             Project: Commons Daemon
>          Issue Type: Bug
>            Reporter: Jonathan Gallimore
>            Priority: Major
>         Attachments: daemon-env.diff
>
>
> I have a JNI dll loaded by a Java process running as a Windows service on 
> Windows 2019 using prunsrv. The JNI library is built with VC14, and makes 
> calls to getenv(), which is imported from ucrtbase.dll.
> This call to getenv does not pick up environment variables that are set on 
> the service via //US//Service ++Environment "key=value". Commons Daemon is 
> setting these environment variables using _wputenv(), which is imported from 
> msvcrt.dll.
> I started a discussion on the mailing list regarding this. I have patch which 
> dynamically loads ucrtbase.dll and calls its _wputenv method as well, if it 
> is available.
> I'm happy to provide changes or further patches, and work on this issue, but 
> feedback would be useful and very much appreciated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to