Page 1 of 1

love.math.random() causes a crash while profiling

Posted: Fri Jan 09, 2015 7:10 pm
by clofresh
Running this code:

Code: Select all

local Profiler = require('profiler')

function love.load()
    Profiler.start('profile.txt')
    love.math.random()
    Profiler.stop()
end

function love.update(dt)
    print('here')
end
Causes love to crash silently without ever printing "here".

Contents of profile.txt:

Code: Select all

stack_level     file_defined    function_name   line_defined    current_line    local_time      total_time
8       (string)        gsub    -1      1410    0.000035        0.000035
I compiled profiler from this code: https://github.com/luaforge/luaprofiler

With a small patch to get it to compile:

Code: Select all

diff --git a/config.linux b/config.linux
index 5dd041d..4dbbb46 100755
--- a/config.linux
+++ b/config.linux
@@ -1,5 +1,5 @@
 
-LUA_INCLUDE= /usr/local/include/lua51
+LUA_INCLUDE= /usr/include/lua5.1
 
 PROFILER_OUTPUT= bin/profiler.so
 
@@ -7,4 +7,4 @@ INCS= -I$(LUA_INCLUDE)
 CC= gcc
 WARN= -ansi -W -Wall
 EXTRA_LIBS=
-CFLAGS= -O2 -DTESTS $(WARN) $(INCS) -I./src
+CFLAGS= -O2 -DTESTS $(WARN) $(INCS) -I./src -fPIC
Versions of stuff:

Code: Select all

$ uname -a
Linux carlo-arch 3.17.6-1-ARCH #1 SMP PREEMPT Sun Dec 7 23:43:32 UTC 2014 x86_64 GNU/Linux
$ pacman -Q love lua51
love 0.9.1-1
lua51 5.1.5-4
Anyone know why? I need to track down a perf bug in my game but the profiler is causing it to crash before getting any meaningful data.


Edit: Also tried with LUA_INCLUDE= /usr/include/luajit-2.0 (luajit 2.0.3-3) with the same results.

Edit 2: Oops, I'm an idiot, ignore me. I forgot that I fixed this bug in a fork of luaprofiler: https://github.com/clofresh/luaprofiler ... 39e14268f2

Re: love.math.random() causes a crash while profiling

Posted: Fri Jan 09, 2015 7:28 pm
by lelSkrub
try just using math.random(max value)
Edit: Just read your edit xD