Recently I had a chance to explore if we can run Golang pie apps built with 
--buildmode=pie options. I have actually added two examples of it 
- https://github.com/cloudius-systems/osv-apps/tree/master/golang-pie-example 
and 
https://github.com/cloudius-systems/osv-apps/tree/master/golang-pie-httpserver.

Running Golang pie apps does not require the golang wrapper 
(https://github.com/cloudius-systems/osv/blob/master/modules/golang/go.cc) 
which is used to launch apps built as shared libraries which is the 
"official way" of running them on OSv. Relatedly Golang pie apps when run 
trigger a warning about "a PIE using TLS" (see 
issue https://github.com/cloudius-systems/osv/issues/352). Given all that I 
did not expect them to run without crashes which also I reported couple of 
months ago 
- https://github.com/cloudius-systems/osv/issues/352#issuecomment-434692750. 

It turns out that original crash from 352 was caused by missing 
sys_exit_group syscall fixed later by this commit 
- 
https://github.com/cloudius-systems/osv/commit/a52e73ceec726378f642f5621caf5966f96bad9c.
 
So when I built and ran golang-pie-example recently, it would execute 
without any problems. Encouraged with it I tried another more complex 
example - golang-pie-httpserver - and I was also able to start it and 
stress test it with ab. I did not see any issues until I tried to exit with 
'Ctrl-C' which caused a crash as reported by this new issue 
- https://github.com/cloudius-systems/osv/issues/1026.

Couple of questions:

   1. How do these two apps run almost properly (except for that Ctrl-C 
   issue) given they are pie's with local-exec TLS which we do not support per 
   #352? 
   2. Do the apps run properly because they actually do NOT use any thread 
   local variables? Or we simply do not see any bad side effects and program 
   just "happens' to work fine? I know that Golang language itself does not 
   have a concept of thread local variables like C++ or Java but Golang 
   runtime behind the scenes seems to use them given presence of TLS section. 
   Or maybe TLS section is empty?
   3. The C++ example from #352 executes on OSv but prints wrong value. 
   What does exactly mean that local-exec TLS is not supported? In what way? 
   Does code try to read/write data from/to wrong offsets in memory or thread 
   local variables do not get properly initialized?
   4. Is it possible that some patches (for example 
   
https://github.com/cloudius-systems/osv/commit/e60339de2676b186c1ec957102a5a384506d127e_
 
   committed to support Golang apps with initial-exec TLS mode helped support 
   Golang pies as well.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to