Skip to content

Commit e87ac18

Browse files
committed
expand lua stack first
1 parent 1da8a6b commit e87ac18

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Diff for: lualib-src/lua-sharedata.c

+1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ pconv(lua_State *L) {
376376
static void
377377
convert_stringmap(struct context *ctx, struct table *tbl) {
378378
lua_State *L = ctx->L;
379+
lua_checkstack(L, ctx->string_index + LUA_MINSTACK);
379380
lua_settop(L, ctx->string_index + 1);
380381
lua_pushvalue(L, 1);
381382
struct state * s = lua_newuserdata(L, sizeof(*s));

Diff for: service-src/service_snlua.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
struct snlua {
1313
lua_State * L;
1414
struct skynet_context * ctx;
15+
FILE *f;
1516
};
1617

1718
// LUA_CACHELIB may defined in patched lua for shared proto
@@ -143,17 +144,35 @@ snlua_init(struct snlua *l, struct skynet_context *ctx, const char * args) {
143144
return 0;
144145
}
145146

147+
static void *
148+
lalloc(void *ud, void *ptr, size_t osize, size_t nsize) {
149+
struct snlua * l = ud;
150+
if (l->f) {
151+
fprintf(l->f, "%p %d %d\n", ptr, (int)osize, (int)nsize);
152+
}
153+
if (nsize == 0) {
154+
skynet_free(ptr);
155+
return NULL;
156+
} else {
157+
return skynet_realloc(ptr, nsize);
158+
}
159+
}
160+
146161
struct snlua *
147162
snlua_create(void) {
148163
struct snlua * l = skynet_malloc(sizeof(*l));
149164
memset(l,0,sizeof(*l));
150-
l->L = lua_newstate(skynet_lalloc, NULL);
165+
char tmp[L_tmpnam];
166+
l->f = fopen(tmpnam(tmp),"wb");
167+
// printf("%s\n", tmp);
168+
l->L = lua_newstate(lalloc, l);
151169
return l;
152170
}
153171

154172
void
155173
snlua_release(struct snlua *l) {
156174
lua_close(l->L);
175+
fclose(l->f);
157176
skynet_free(l);
158177
}
159178

Diff for: skynet-src/malloc_hook.c

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ skynet_strdup(const char *str) {
218218

219219
void *
220220
skynet_lalloc(void *ud, void *ptr, size_t osize, size_t nsize) {
221+
printf("%p osize = %d nsize = %d\n", ptr, (int)osize, (int)nsize);
221222
if (nsize == 0) {
222223
skynet_free(ptr);
223224
return NULL;

0 commit comments

Comments
 (0)