#StackBounty: #c++ #linux #segmentation-fault #static-linking #mesa lib OSMesa off-screen context creation fails in C++, but only when …

Bounty: 50

I made a C++ tool for off-screen rendering of 3D models. The rendering is done using OSMesa library.

The software was working flawlessly for more than a year, and I stopped to make updates to it something like 6 months ago. In the meanwhile my development environment was updated multiple times.

Now I was compiling it again and found an unexpected bug.

The plain version of the software was still working as expected, but the statically linked one is segfaulting.

I’m assuming that the error is mine in the OSmesa configuration/compilation/linking procedure and not in the library code, but any advice about better debugging of the segmentation fault is appreciated.

Having tried numerous variations of the compilation process without success, I’m now quite stuck.
Anyone can see something stupid I’m doing in some of the steps described below?


I recompiled a static version of the OSmesa library with the same version of the shared library that is working in my system (12.0.6), disabling all the non-needed features (using an Ubuntu based system, no static version of OSmesa lib is available from repositories):

./configure 
    --disable-xvmc 
    --disable-glx 
    --disable-dri 
    --with-dri-drivers="" 
    --with-gallium-drivers="" 
    --disable-shared-glapi 
    --disable-egl 
    --with-egl-platforms="" 
    --enable-osmesa 
    --enable-gallium-llvm=no 
    --disable-gles1 
    --disable-gles2 
    --enable-static 
    --disable-shared

This is the compile command of my off-screen rendering tool:

g++ -std=c++11 -Wall -O3 -g -static -static-libgcc -static-libstdc++ ./src/measure_model.cpp model.o thumbnail.o -o measure_model_debug -pthread -lOSMesa -ldl -lm -lpng -lz -lcrypto

This is a warning that I was getting by statically compiling using OSMesa, and it was present even a year ago with the working static binary:

/home/XXX/XXX/backend/lambda/mesa/mesa-12.0.6/src/mesa/main/dlopen.h:52: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

This is what I get from running the tool:

Segmentation fault (core dumped)

But no segmentation fault is produced if I simply skip the OSmesa context creation step (and obviously all the 3D rendering)

This is the backtrace:

#0  0x0000000000000000 in ?? ()
#1  0x00000000004af20a in mtx_init (type=4, mtx=0xe10f70) at ../../include/c11/threads_posix.h:215
#2  _mesa_NewHashTable () at main/hash.c:135
#3  0x000000000052f295 in _mesa_alloc_shared_state (ctx=ctx@entry=0xdcc9b0) at main/shared.c:67
#4  0x000000000046e717 in _mesa_initialize_context (ctx=ctx@entry=0xdcc9b0, api=api@entry=API_OPENGL_COMPAT, visual=, share_list=share_list@entry=0x0, driverFunctions=driverFunctions@entry=0x7fffffffcd40) at main/context.c:1192
#5  0x000000000046c870 in OSMesaCreateContextAttribs (attribList=attribList@entry=0x7fffffffd290, sharelist=) at osmesa.c:834
#6  0x000000000046ccdc in OSMesaCreateContextExt (format=, depthBits=, stencilBits=, accumBits=, sharelist=) at osmesa.c:660
#7  0x0000000000468742 in generate_thumbnail(Model*, Json::Value) ()
#8  0x0000000000401c7d in main (argc=, argv=) at ./src/measure_model.cpp:107

A statically linked binary is a strict requirement.

The segmentation fault is happening on the same machine I use to compile the tool (OSmesa static lib is compiled in the same machine too), but no segmentation fault in the non-statically linked version of the same tool.


Get this bounty!!!

#StackBounty: #javascript #c# #jquery #.net #winforms JQuery click() on anchor tag not firing from an injected script inside WebBrowser…

Bounty: 50

I am developing a web bot using WinForms WebBrowser control. Everything is working fine except for the second click() call in following code:

function SaveRecordClick() {
    try {
        var menuButton = $('#s_at_m_4');
        menuButton.click();             //<-- This is working
        var x = $('#s_at_m_4-menu li')[5];
        var saveLink = $(x).find('a')[0];
        if (saveLink != null){
            saveLink.click();           //<-- This is not working

            return "1";
        }
    }
    catch (err) {
        alert(err.message);
    }
    return "0";
}

saveLink is not null. I know this because I placed an alert() call inside the condition.

Updated code with suggested solutions

function SaveRecordClick() {
    try {
        var menuButton = $('#s_at_m_4');
        menuButton.click();
        var x = $('#s_at_m_4-menu li').eq(5);
        var saveLink = x.find('a').eq(0);
        if (saveLink != null) {
            alert(saveLink.html());
            saveLink.click();

            return "1";
        }
    }
    catch (err) {
        alert(err.message);
    }
    return "0";
}

But still the same problem. ‘alert()’ is working fine but html() is showing inner text instead of HTML of the anchor.

HTML Code

<li data-caption="Save Record                [Ctrl+S]" class="sbui-appletmenu-item  ui-menu-item" role="presentation">
<a href="javascript:void(0)" aria-disabled="false" class="ui-corner-all" id="ui-id-254" tabindex="-1" role="menuitem">Save Record                [Ctrl+S]</a>
</li>

ID of the anchor tag is dynamically generated.

Also, click() is triggering when the same code is executed from Google Chrome Console. So, could it be the issue with the WebBrowser control?


Get this bounty!!!

#StackBounty: #unity #c# #virtual-reality Object movement to a circular shape, with the grab of a VR controller?

Bounty: 50

I have a HTC Vive VR set, which has a controller. I have a sphere object, which I want to rotate in a circular motion around my VR Player object, based on the controller grab and its movement. The controller should first grab the object, then it will move left or right, in a circular motion, based on the controller movement. How can I achieve this?


So far, I have made a sphere, with a parent. The parent position is updating with respect to my camera head, so I can move my sphere with my player. The sphere object should move with the controller, but in a circular motion. This has not been achieved, yet, and I really don’t know how to do it.

I am able to grip the sphere object using a VRTK script, and I can freely move it, but I want to restrict its movement; much like in the illustrated figure, below:

enter image description here


Get this bounty!!!

#StackBounty: #unity #c# #virtual-reality Restrict object movement to a circular shape, with the grab of a VR controller?

Bounty: 50

I have a HTC Vive VR set, which has a controller. I have a sphere object, which I want to rotate in a circular motion around my VR Player object, based on the controller grab and its movement. The controller should first grab the object, then it will move left or right, in a circular motion, based on the controller movement. How can I achieve this?


So far, I have made a sphere, with a parent. The parent position is updating with respect to my camera head, so I can move my sphere with my player. The sphere object should move with the controller, but in a circular motion. This has not been achieved, yet, and I really don’t know how to do it.

I am able to grip the sphere object using a VRTK script, and I can freely move it, but I want to restrict its movement; much like in the illustrated figure, below:

enter image description here


Get this bounty!!!

#StackBounty: #c# #.net #printing #.net-4.0 #printdialog Print file with selected printer profile/page size

Bounty: 100

I have a option that user can select the print option where it brings up the PrintDialogwhere user can select the already defined printer profile.

For this printer default paper size is A4 but selecting this profile it get change to A5.

enter image description here

I am using the below code which send the print task to correct printer but doesn’t pick up the correct paper size as it always print in A4. Am I missing anything here or is there alternate way of achieving this?

 using (var pd = new PrintDialog())
 {
   if (pd.ShowDialog() == DialogResult.OK)
      {
         var info = new ProcessStartInfo(filepath)
                    {
                        Arguments = """ + pd.PrinterSettings + """,
                        CreateNoWindow = true,
                        WindowStyle = ProcessWindowStyle.Hidden,
                        UseShellExecute = true,
                        Verb = "Print"
                    };
        Process.Start(info);
      }
  }


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c# #excel-interop #npoi Reading image position(row and cell position) from excel using excel introp or npoi

Bounty: 50

I need to extract images from excel with start&&end row no. and start && end col no

My current code is as below:-

  var excelApp = new Application();
  var wb = excelApp.Workbooks.Open(filePath, Type.Missing, Type.Missing, 
          Type.Missing, Type.Missing, Type.Missing, Type.Missing,
          Type.Missing, Type.Missing, Type.Missing, Type.Missing, 
          Type.Missing, Type.Missing, Type.Missing, Type.Missing);
  var ws = (Worksheet)wb.Worksheets["Sheet1"];
   int startCol = 0;
   int startRow =0;
   int endCol = 0;
   int endRow = 0;
  foreach (var pic in ws.Pictures())
                    {
                        int startCol = pic.TopLeftCell.Column;
                        int startRow = pic.TopLeftCell.Row;
                        int endCol = pic.BottomRightCell.Column;
                        int endRow = pic.BottomRightCell.Row;
                     }

Above code works fine when all images are different but when I put the same image in different cells than it picks only first one.

For example,
Works fine when i put abc.jpeg at B1 cell and xyz.jpeg at C5 cell then results are
two object first startRow=1,endRow=1,startCol=1,endCol=1 and
second startRow=5,endRow=5,startCol=2,endCol=2

But if I put abc.jpeg at B1 cell and C5 cell then result is one object with startRow=1,endRow=1,startCol=1,endCol=1 for both images.It doesn’t pic the second image.

Why it’s happing?Is there any solution using interop or npoi


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!