lua_getglobal crashing program


I made a previous post regarding trying to call lua functions from C. You can take a look at that here:

<a href="https://stackoverflow.com/questions/6741050/lua-getting-global-function-failing-after-loading-file" rel="nofollow">Lua: getting global function failing after loading file</a>

As you can see, I am loading the lua file and then attempting to get the function and call it. One reader suggested my solution to that problem was to change to dofile rather than load file because you need to execute the script to access those functions. But that's not the problem at hand...

Regardless of using dofile or loadfile, When I call the lua_getglobal(L, "abc");<br /> my program crashes...


> Translation.exe!luaS_newlstr(lua_State * L=0xcccccccc, const char * str=0x00460924, unsigned int l=3) Line 84 + 0x3 bytes C Translation.exe!lua_getfield(lua_State * L=0xcccccccc, int idx=-10002, const char * k=0x00460924) Line 551 + 0x20 bytes C Translation.exe!LanguageShovel::FileFound(std::basic_string<char,std::char_traits<char>,std::allocator<char> > path="C:\Loud\Resolution\orchid\source\EAWResolutionApplication.cpp") Line 32 + 0x16 bytes C++

Crashes on:

for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; o != NULL; o = o->gch.next) {

in the lstring.c file in Lua library. I have no idea what the heck is going on in this lua source code. Do you think it could be a lua bug? Or am I just doing this incorrectly?

Running: Windows xp 32 bit.


The L=0xcccccccc suggests that you didn't pass the Lua state variable correctly to this function (or that it was lost somewhere between your lua_open and lua_getglobal calls).


  • Autofac Injection of data into OWIN Startup class
  • Segfault in SIGSEGV handler
  • XCode 7 XCTest(Kiwi) +load category methods called twice
  • How to call C# method in DLL from Runbook in Azure Automation?
  • Custom accordion content divs all share same size, no idea why
  • rollback sql transactions if any failed in c#
  • Loading files into variables in python
  • Moving Object in ScrollViewer
  • How do I specify custom wording in a will_paginate view helper?
  • Using extern @class in order to add a category?
  • Replace and retrieve placeholder value
  • ConfigurationBuilder not working in azure function
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • Translating C# to PowerShell in InterIMAP
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • How can I run DataNucleus Bytecode Enhancer from SBT?
  • Setting the run time properties on SpringApplicationBuilder()
  • Jquery Knockout: ko.computed() vs classic function?
  • aapt.exe'' finished with non-zero exit value 1
  • URLConnection doesn't work since API 10 and higher?
  • Memory error in python- how to use more memory
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • Differences in dis-assembled C code of GCC and Borland?
  • Tamper-proof configuration files in .NET?
  • Code in Job's Script Block after Start-Process Does not Execute
  • How to define and use opencv mat of user type
  • debug library loaded with ctypes using gdb
  • jQuery .attr() and value
  • Algorithm for a smudge tool?
  • Azure Cloud Service Web Role web pages do not load
  • Running a C# exe file
  • Apache 2.4 - remove | delete | uninstall
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Benchmarking RAM performance - UWP and C#
  • Checking variable from a different class in C#
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?