lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


BUG Report:
luabind 0.8 release
lua 5.1.4
VC2008sp1

VC report:
  ntdll.dll!7c92120e()

  ntdll.dll!7c98c201()
  ntdll.dll!7c98c63e()
  ntdll.dll!7c9803b0()
  ntdll.dll!7c980484()
  kernel32.dll!7c85f8d7()
> msvcr90d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x100ac868)  line 2103 C++
  msvcr90d.dll!_free_dbg_nolock(void * pUserData=0x100ac868, int nBlockUse=1)  line 1317 + 0x9 byte C++
  msvcr90d.dll!_free_dbg(void * pUserData=0x100ac868, int nBlockUse=1)  line 1258 + 0xd byte C++
  msvcr90d.dll!free(void * pUserData=0x100ac868)  line 49 + 0xb byte C++
  luai.exe!l_alloc(void * ud=0x00000000, void * ptr=0x100ac868, unsigned int osize=32, unsigned int nsize=0)  line 631 + 0xc byte C++
  luai.exe!luaM_realloc_(lua_State * L=0x00295da8, void * block=0x100ac868, unsigned int osize=32, unsigned int nsize=0)  line 79 + 0x1d byte C++
  luai.exe!luaH_free(lua_State * L=0x00295da8, Table * t=0x002bc800)  line 376 + 0x2d byte C++
  luai.exe!freeobj(lua_State * L=0x00295da8, GCObject * o=0x002bc800)  line 383 + 0xd byte C++
  luai.exe!sweeplist(lua_State * L=0x00295da8, GCObject * * p=0x002bc618, unsigned int count=37)  line 424 + 0xd byte C++
  luai.exe!singlestep(lua_State * L=0x00295da8)  line 583 + 0x12 byte C++
  luai.exe!luaC_fullgc(lua_State * L=0x00295da8)  line 656 + 0x9 byte C++
  luai.exe!lua_gc(lua_State * L=0x00295da8, int what=2, int data=""  line 914 + 0x9 byte C++
  luai.exe!docall(lua_State * L=0x00295da8, int narg=0, int clear=0)  line 116 + 0x13 byte C++
  luai.exe!dotty(lua_State * L=0x00295da8)  line 246 + 0x13 byte C++
  luai.exe!pmain(lua_State * L=0x00295da8)  line 411 + 0x9 byte C++
  luai.exe!luaD_precall(lua_State * L=0x00295da8, lua_TValue * func=0x00292a60, int nresults=0)  line 319 + 0x16 byte C++
  luai.exe!luaD_call(lua_State * L=0x00295da8, lua_TValue * func=0x00292a60, int nResults=0)  line 376 + 0x11 byte C++
  luai.exe!f_Ccall(lua_State * L=0x00295da8, void * ud=0x00ddff28)  line 846 + 0x15 byte C++
  luai.exe!luaD_rawrunprotected(lua_State * L=0x00295da8, void (lua_State *, void *)* f=0x00405220, void * ud=0x00ddff28)  line 118 + 0xd byte C++
  luai.exe!luaD_pcall(lua_State * L=0x00295da8, void (lua_State *, void *)* func=0x00405220, void * u=0x00ddff28, int old_top=16, int ef=0)  line 463 + 0x11 byte C++
  luai.exe!lua_cpcall(lua_State * L=0x00295da8, int (lua_State *)* func=0x00401220, void * ud=0x00ddff54)  line 856 + 0x21 byte C++
  luai.exe!main(int argc=4, char * * argv=0x00295d20)  line 437 + 0x12 byte C++
  luai.exe!__tmainCRTStartup()  line 586 + 0x19 byte C
  luai.exe!mainCRTStartup()  line 403 C
  kernel32.dll!7c817067()

lua part:
require'asio'

t=a.timer()
local n=1
collectgarbage('stop')
local f;f=function(t,e)
local t={'hi~'}-- this line make VC report heap crash
if e=='timeout' then

t:start(f,1000)

n=n+1

print'hi~'

if n>3 then t:cancel() end

else

print(t,e)

end
end
t:start(f,1000)
a.ios_run();

--------------------------------------------------------------------
I think maybe it's gc bug.

On Sun, Jan 4, 2009 at 19:57, Daniel Wallin <daniel@boostpro.com> wrote:
I'm happy to announce the release of luabind 0.8. Most of the
changes since the last release have happened under the hood,
but a number of new features has been added as well.

As usual, source packages available for download at:

 http://sourceforge.net/project/showfiles.php?group_id=77060

Bug reports and questions should go to the mailing list:

 https://lists.sourceforge.net/lists/listinfo/luabind-user

User visible changes since 0.7.1
--------------------------------

 * Added ability to explicity specify the signature of the
  exported function. This additionally means that it's now
  possible to export function objects.

 * Added ability to register translation of custom exception
  classes.

 * Added customization point to allow native conversion of
  user defined types.

 * Added support for exporting the # operator.

 * Expanded the API wrapper interface with more functions and
  a light weight alternative to `object': `argument'.

 * Properties now goes through the same function dispatch
  code as all other functions, and now properly handles
  exceptions.

Breaking changes
----------------

 * Dropped support for old compilers. Anything that doesn't
  handle partial specialization won't work anymore. This
  means no more VC6.5 and VC7.0.

 * `super()' was deprecated in favor of directly calling the
  base class `__init()' function. The deprecation error can
  be turned off by calling `luabind::disable_super_deprecation()'
  before `super()' is used.

 * The user defined converter mechanism was removed in favor
  of the new customization point.

 * Format of error messages was changed.

Changes since 0.7.1:
--------------------

Daniel Wallin (74):
 Refactored temporary holder construction in converters.
 Added new exception_handler code.
 Removed duplicated exception handlers.
 Added test for user defined exception handlers.
 Handle `luabind:error` specially.
 Changed expected error messages from exceptions.
 Documented exception handler mechanism.
 Updated .gitignore with build directories.
 Add support for exporting the # operator.
 Add getmetatable() and setmetatable() functions.
 Add more API wrappers to object.hpp.
 Add missing includes.
 Remove stale object_init code.
 Add "argument" API wrapper class.
 Make all object-like types bool-convertible.
 Rewrite copy_policy in terms of value_converter.
 Test copy_policy with T const*.
 Add signature deduction function template.
 Reimplement "call" template.
 Add missing includes.
 Convert "class" and "property" to new call code.
 Add compute_score() and compute_arity() helpers.
 Use compute_score() instead of match().
 Use compute_score() and invoke() in function.hpp.
 Add constructor<>::signature MPL sequence.
 Use compute_score() when invoking constructors.
 Add missing include and namespace alias.
 Don't try to link to versioned .so.
 Reimplement the function registration code.
 Use new function dispatch code for member functions.
 Fix calling virtual functions without override.
 Remove old function dispatch code completely.
 Add missing include.
 Reimplement constructor code.
 Change constructor signature to include self argument.
 Change super() to always just call the __init() function.
 Change derived class name-shadowing rules.
 Fix destruction of derived Lua classes.
 Rewrite construction code to always just call __init().
 Unify construction of Lua and C++ classes.
 Deprecate "super()".
 Added `property_tag()`.
 Call "get" and "set" property functions.
 Changed use of std::string to lua_pushfstring().
 Added "property()" Lua function.
 Add interface to explicitly specify signatures.
 Add test that demonstrates adopt() bug.
 Test that properties can be added to Lua instances.
 Removed worthless gettable/settable metamethods.
 Add "property()" API wrapper.
 Turn "is_primitive" into a proper metafunction.
 Use the new property system in class_.
 Make using dependency() on non class return types a nop.
 Add function name to signature string.
 Add signature type name for object and argument.
 Get rid of unused global variable warning.
 Fix expected error messages in tests.
 Remove commented out "functor" converter.
 Simplify converters and add customization point.
 Remove old user-defined converters.
 Document the new converter customization point.
 Change private destructor test to use factory function.
 Remove obsolete typedef from converters.
 Fix GCC 'suggest parentheses' warning.
 Add '__len' to list of overloadable operators.
 Document 'tag_function'.
 Really get rid of unused global warning.
 Add test that demonstrates adopt() bug.
 Use correct index in inject_backref().
 Fix adopt() bug when used with wrapper class.
 Change test to use polymorphic type derived from wrap_base.
 Always use __declspec(dllimport/dllexport) on Windows.
 Move LUABIND_BUILDING define from Jamroot to source files.
 docs: Add note about LUABIND_DYNAMIC_LINK.

Nikolas Bowe (1):
 Fix adopt bug when used with derived Lua classes.

Rodolfo Lima (1):
 Synchronize the declaration of class_base::init with its definition.

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com




--
Regards,
Linker Lin
linker.m.lin@gmail.com
#pragma once











#include "luaasio.hpp"
#include "luahelper.hpp"
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/asio.hpp>
#include <string>

using namespace luabind;
using namespace boost;

void helper_functor(object o,object o1,object o2,object o3)
{
	o(o1,o2,o3);
}

luabind::object string_to_obj(luabind::object interpreterobj, std::string const& str)
{
	return luabind::object(interpreterobj.interpreter(),str);
}


inline boost::asio::io_service& gio()
{
	static boost::asio::io_service sio;
	return sio;
}

std::size_t poll()
{
	return gio().poll();
}

std::size_t run()
{
	return gio().run();
}

void post(object o,object o1,object o2,object o3)
{
	if (o.is_valid())
	{
		gio().post( boost::bind(&helper_functor,o,o1,o2,o3 ) );
	}
}


class luatimer : public noncopyable
{
public:
	luatimer()
		: timer_( gio() )
	{
		id_=(boost::uint32_t)this;

	}

	~luatimer()
	{
		cancel();
	}

	void start( luabind::object on_timeout, boost::uint32_t timout_milliseconds )
	{
		on_timeout_ = on_timeout ;
		timer_.expires_from_now( boost::posix_time::milliseconds( timout_milliseconds ) );
		timer_.async_wait( boost::bind( &luatimer::handle_timeout, this, _1 ) );
	}

	void cancel()
	{
		try{
			timer_.cancel();
		}catch(...){}
	}

	boost::uint32_t id() const
	{
		return id_;
	}

	void self(luabind::object selfobj)
	{
		self_=selfobj;
	}

	luabind::object self()const
	{
		return self_;
	}

protected:

	void handle_timeout( const boost::system::error_code& err )
	{
		if ( err == boost::asio::error::operation_aborted )
		{
			on_timeout_( this, "aborted" );
		}
		else
		{  
			on_timeout_( this, "timeout" );
		}
	}


	boost::asio::deadline_timer	timer_;
	luabind::object					on_timeout_;
	boost::uint32_t					id_;
	luabind::object					self_;

};

inline std::ostream& operator<<(std::ostream& os, const luatimer& o)
{
	os<<"timer "<<o.id()<<std::endl;
	return os;
}

class luaconnection:public noncopyable
{
public:
	luaconnection()
	{
		id_=(boost::uint32_t)this;
	}
	virtual ~luaconnection()
	{

	}
	boost::uint32_t id() const
	{
		return id_;
	}

	boost::uint32_t					id_;
};

inline std::ostream& operator<<(std::ostream& os, const luaconnection& o)
{
	os<<"connection "<<o.id()<<std::endl;
	return os;
}


inline void register_luaasio(lua_State* L)
{
	using namespace luabind;
	module( L, "asio" )
		[
			def( "string_to_obj",&string_to_obj),
			def( "ios_poll", &poll ),
			def( "ios_run", &run ),
			def( "ios_post", &post )
		];
	module( L, "asio" )
		[
			class_<luatimer>("timer")
			.def( constructor<>() )
			.def( "start", &luatimer::start )
			.def( "cancel", &luatimer::cancel )
			.def( tostring( self ) )
			.property( "id", &luatimer::id )
			.property( "self", ( luabind::object ( luatimer::* )( void ) const )&luatimer::self, ( void ( luatimer::* )( luabind::object ) )&luatimer::self )
		];
	module( L, "asio" )
		[
			class_<luaconnection>("connection")
			.def( constructor<>() )
			.def( "start", &luatimer::start )
			.def( "cancel", &luatimer::cancel )
			.def( tostring( self ) )
			.property( "id", &luatimer::id )
			.property( "self", ( luabind::object ( luatimer::* )( void ) const )&luatimer::self, ( void ( luatimer::* )( luabind::object ) )&luatimer::self )
		];


}


__declspec(dllexport) int luaopen_luaasio( lua_State *L )
{

	if (luabind::detail::class_registry::get_registry(L) == 0)
	{
		luabind::open(L);
	}

	register_luaasio(L);

	linker::lua::log(linker::lua::dostring( L, "dofile('serialize.lua');" ));


	return 1;
}
#pragma comment(linker,"/EXPORT:luaopen_luaasio=?luaopen_luaasio@@YAHPAUlua_State@@@Z")





Attachment: testasio.lua
Description: Binary data