Closed akhikolla closed 3 years ago
hi can you please clarify what you want? I don't see the problem. Aren't there two error messages in that log, and you are getting two rows?
On Mon, Aug 24, 2020 at 4:24 PM Akhila Chowdary Kolla < notifications@github.com> wrote:
Hello @tdhock https://github.com/tdhock,
I am trying to extract the error message from the log along with the line where the error occurred.
The code I wrote doesn't read all the error messages it reads the first error message only although I specified to read all the error messages. Can you please help me find where I am going wrong? I tried debugging the code but couldn't figure out where the mistake is.
display.dt <- nc::capture_all_str( logfile, inputs="(?:[a-zA-Z ]+values:(?:.\n)?)inputends\n+", errortrace="(?:.\n)?", "==[0-9]+== HEAP SUMMARY:", "\n", heapsum="(?:.\n)?", "==[0-9]+== LEAK SUMMARY:", "\n", leaksum="(?:.\n)?", "==[0-9]+== ERROR SUMMARY:")
files.list<-nc::capture_all_str(logfile,"Command: ./", file.name=".*", "_DeepState_TestHarness") Testharness <- paste0("DeepState_Test_",basename(dirname(logfile)), "_deepstate_test_",files.list$file.name,"_test")
trace <- gsub("==[0-9]+== Warning:.*?\n","",display.dt$errortrace)
for(trace.i in seq_along(trace)){ file.line.dt <- nc::capture_all_str( trace[[trace.i]], "==[0-9]+==", val="(?:(?!at|by).)\n", "==[0-9]+== ","\s", data=".\n", ".", Testharness) }
For log data below, I get the following output
file.line.dt val 1: Invalid read of size 8\n 2: Invalid read of size 8\n data 1: at 0x42BD5A: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22)\n 2: at 0x42BD92: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22)\n
Required output:
file.line.dt val 1: Invalid read of size 8\nAddress 0xb8d7ce8 is 0 bytes after a block of size 184 alloc'd\n 2: Invalid read of size 8\nAddress 0xb989cd8 is 0 bytes after a block of size 648 alloc'd\n data 1: at 0x42BD5A: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22)\n by 0x42BC7E: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:18) 2: at 0x42BD92: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22)\n by 0x42BCC7: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:19)
Log data
==10915== Invalid read of size 8 ==10915== at 0x42BD5A: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22) ==10915== by 0x40A690: DeepState_Test_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:28) ==10915== by 0x40A348: DeepState_Run_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:7) ==10915== by 0x406CD3: DeepState_RunTest.isra.6 (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4153EA: DeepState_FuzzOneTestCase (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4154FF: DeepState_Fuzz (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x40781D: main (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== Address 0xb8d7ce8 is 0 bytes after a block of size 184 alloc'd ==10915== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10915== by 0x4FB8633: Rf_allocVector3 (memory.c:2766) ==10915== by 0x42C17A: void Rcpp::Vector<14, Rcpp::PreserveStorage>::import_sugar_expression<true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> >(Rcpp::VectorBase<14, true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> > const&, Rcpp::traits::integral_constant<bool, false>) (Vector.h:1070) ==10915== by 0x42C021: Rcpp::Vector<14, Rcpp::PreserveStorage>::Vector<true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> >(Rcpp::VectorBase<14, true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> > const&) (Vector.h:165) ==10915== by 0x42BC7E: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:18) ==10915== by 0x40A690: DeepState_Test_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:28) ==10915== by 0x40A348: DeepState_Run_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:7) ==10915== by 0x406CD3: DeepState_RunTest.isra.6 (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4153EA: DeepState_FuzzOneTestCase (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4154FF: DeepState_Fuzz (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x40781D: main (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== ==10915== Invalid read of size 8 ==10915== at 0x42BD92: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:22) ==10915== by 0x40A690: DeepState_Test_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:28) ==10915== by 0x40A348: DeepState_Run_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:7) ==10915== by 0x406CD3: DeepState_RunTest.isra.6 (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4153EA: DeepState_FuzzOneTestCase (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4154FF: DeepState_Fuzz (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x40781D: main (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== Address 0xb989cd8 is 0 bytes after a block of size 648 alloc'd ==10915== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==10915== by 0x4FB8633: Rf_allocVector3 (memory.c:2766) ==10915== by 0x42C17A: void Rcpp::Vector<14, Rcpp::PreserveStorage>::import_sugar_expression<true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> >(Rcpp::VectorBase<14, true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> > const&, Rcpp::traits::integral_constant<bool, false>) (Vector.h:1070) ==10915== by 0x42C021: Rcpp::Vector<14, Rcpp::PreserveStorage>::Vector<true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> >(Rcpp::VectorBase<14, true, Rcpp::sugar::Pow<14, true, Rcpp::Vector<14, Rcpp::PreserveStorage>, int> > const&) (Vector.h:165) ==10915== by 0x42BCC7: get_VM_C(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>) (get_VM_C.cpp:19) ==10915== by 0x40A690: DeepState_Test_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:28) ==10915== by 0x40A348: DeepState_Run_AGread_deepstate_test_get_VM_C_test() (get_VM_C_DeepState_TestHarness.cpp:7) ==10915== by 0x406CD3: DeepState_RunTest.isra.6 (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4153EA: DeepState_FuzzOneTestCase (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x4154FF: DeepState_Fuzz (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915== by 0x40781D: main (in /home/akhila/Documents/compileAttributescheck/AGread/inst/testfiles/get_VM_C/get_VM_C_DeepState_TestHarness) ==10915==
Thanks
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/akhikolla/RcppDeepState/issues/35, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHDX4XUL2CKTBXESIAVBDDSCLZDJANCNFSM4QKARX2Q .
Hello @tdhock ,
We have two error messages in the log but I am able to extract only one error message i.e (Invalid read of size 4 and its error line) I got something like Invalid read of size 8\n and its corresponding error line I am not getting the Address 0xb8d7ce8 is 0 bytes after a block of size 184 alloc'd\n and its corresponding error line(which is also a part of the error message) for the log:
I wrote the code to read the lines that don't start with at|by (that is the error message-Invalid read of size 8\n, Address 0xb8d7ce8 is 0 bytes after a block of size 184 alloc'd\n) and for that I am trying to get the corresponding line where the error occurred.
file.line.dt <- nc::capture_all_str(
trace[[trace.i]],
"==[0-9]+==",
val="(?:(?!at|by).)*\n",
"==[0-9]+== ","\\s*",
data=".*\n",
".*",
Testharness)
Please find the attached log error.log.txt
Hi I think it would be easier if you add "input starts" as in the modified log file 2020-08-25.log I'm using this R code:
## add \n\ninput starts?
messages.raw <- nc::capture_all_str(
"2020-08-25.log",
"input starts\n",
inputs="(?:.*\n)+?",
"input ends\n",
rest="(?:.+\n)+")
str(messages.raw)
messages.raw[, message.i := 1:.N]
## using tibble for the compact print method.
tibble::tibble(messages.raw)
prefix <- function(after){
list("==[0-9]+==", after)
}
trace.pattern <- nc::quantifier(
prefix(" "),
"(?:at|by).*\n",
"+")
tibble::tibble(nc::capture_all_str(
messages.raw[2, rest],
prefix(" "),
problem="[^ \n].*",
"\n",
problem.trace=trace.pattern,
prefix(" "),
address=".*",
"\n",
address.trace=trace.pattern))
values.dt <- nc::capture_all_str(
messages.raw[2, inputs],
variable=".*?",
" ",
nc::field("values", ": ", ".*"))
tibble::tibble(values.dt)
scan(text=values.dt[1, values], quiet=TRUE)
arg.list <- list()
for(arg.i in 1:nrow(values.dt)){
arg.row <- values.dt[arg.i]
v <- arg.row[["variable"]]
## Q: how are you going to read values (line of code below) for
## types other than NumericVector?
arg.list[[v]] <- scan(
text=arg.row[["values"]], quiet=TRUE)
}
messages.parsed <- messages.raw[, {
values.dt <- nc::capture_all_str(
inputs,
variable=".*?",
" ",
nc::field("values", ": ", ".*"))
arg.list <- list()
for(arg.i in 1:nrow(values.dt)){
arg.row <- values.dt[arg.i]
v <- arg.row[["variable"]]
## Q: how are you going to read values (line of code below) for
## types other than NumericVector?
arg.list[[v]] <- scan(
text=arg.row[["values"]], quiet=TRUE)
}
problems.dt <- nc::capture_all_str(
rest,
prefix(" "),
problem="[^ \n].*",
"\n",
problem.trace=trace.pattern,
prefix(" "),
address=".*",
"\n",
address.trace=trace.pattern)
data.table::data.table(
arguments=list(arg.list),
problems=list(problems.dt))
}, by=.(message.i)]
str(messages.parsed)
for(message.i in 1:nrow(messages.parsed)){
cat(sprintf("\nmessage=%d\n", message.i))
str(messages.parsed[["arguments"]][[message.i]])
print(tibble::tibble(messages.parsed[["problems"]][[message.i]]))
}
The output I get from the last block is:
> for(message.i in 1:nrow(messages.parsed)){
+ cat(sprintf("\nmessage=%d\n", message.i))
+ str(messages.parsed[["arguments"]][[message.i]])
+ print(tibble::tibble(messages.parsed[["problems"]][[message.i]]))
+ }
message=1
List of 3
$ x: num [1:80] -Inf -4.30e-277 NaN -Inf 3.92e-233 ...
$ y: num [1:89] -Inf NaN NaN -Inf NaN ...
$ z: num [1:72] NaN -Inf -Inf NaN NaN ...
# A tibble: 1 x 4
problem problem.trace address address.trace
<chr> <chr> <chr> <chr>
1 Invalid r… "==10904== at 0x42BD9… Address 0xba097… "==10904== at 0x4C2F…
message=2
List of 3
$ x: num [1:89] -Inf NaN -Inf -7.22e-197 -1.86e+218 ...
$ y: num [1:17] NaN NaN -Inf NaN NaN ...
$ z: num [1:75] NaN -Inf Inf -4.59e+197 Inf ...
# A tibble: 2 x 4
problem problem.trace address address.trace
<chr> <chr> <chr> <chr>
1 Invalid r… "==10915== at 0x42BD5… Address 0xb8d7c… "==10915== at 0x4C2F…
2 Invalid r… "==10915== at 0x42BD9… Address 0xb989c… "==10915== at 0x4C2F…
>
Does that help? Also note in my code I use scan to turn the values from a character string into a numeric vector... these are numeric vectors right? See also #38
again it would be more useful for the user if you could further parse the *.trace columns so that it is immediately obvious what line of user code the problem/address happens on. TODO create new columns problem.file.line, address.file.line or similar.
Using the problem.trace and address.trace column to store the problem file line, address file line
code.line <- function(pattern){
file.line.dt <- nc::capture_all_str(
pattern,
"==[0-9]+==","\\s*",
trace=".*\n",
".*",
Testharness)
return(file.line.dt$trace)
}
rest <- gsub("==[0-9]+== Warning:.*?\\n","",messages.raw$rest)
messages.parsed <- messages.raw[, {
problems.dt <- nc::capture_all_str(
rest,
prefix(" "),
problem="[^ \n].*",
"\n",
problem.trace=trace.pattern,
prefix(" "),
address=".*",
"\n",
address.trace=trace.pattern)
problems.dt$problem.trace = code.line(problems.dt$problem.trace)
problems.dt$address.trace = code.line(problems.dt$address.trace)
data.table::data.table(
problems=list(problems.dt))
}, by=.(message.i)]
src file function and line number:
> problems.dt$problem.trace = code.line(problems.dt$problem.trace)
> problems.dt$problem.trace
[1] "at 0x41FE2F: rcpp_use_after_free(int) (use_after_free.cpp:7)\n"
> problems.dt$address.trace = code.line(problems.dt$address.trace)
> problems.dt$address.trace
[1] "by 0x41FE2A: rcpp_use_after_free(int) (use_after_free.cpp:6)\n"
Output:
message=1
inputs=alloc_size values: 1358703801
# A tibble: 1 x 4
problem problem.trace address address.trace
<chr> <chr> <chr> <chr>
1 Invalid rea… "at 0x41FE2F: rcpp_use_aft… Address 0x59e43068 is 40… "by 0x41FE2A: rcpp_use_aft…
hi is this issue fixed?
It keeps throwing this error when I run the deepstate_display() function. I think the quantifier is unable to pick the lines from the log. I don't exactly understand what does this error mean ? can you please explain?
Error in set(x, j = name, value = value) :
RHS of assignment to existing column 'problem.trace' is zero length but not NULL. If you intend to delete the column use NULL. Otherwise, the RHS must have length > 0; e.g., NA_integer_. If you are trying to change the column type to be an empty list column then, as with all column type changes, provide a full length RHS vector such as vector('list',nrow(DT)); i.e., 'plonk' in the new column.
6.
set(x, j = name, value = value)
5.
`$<-.data.table`(`*tmp*`, problem.trace, value = character(0))
4.
`$<-`(`*tmp*`, problem.trace, value = character(0))
3.
`[.data.table`(messages.raw, , {
problems.dt <- nc::capture_all_str(rest, prefix(" "), problem = "[^ \n].*",
"\n", problem.trace = trace.pattern, prefix(" "), address = ".*",
"\n", address.trace = trace.pattern) ...
2.
messages.raw[, {
problems.dt <- nc::capture_all_str(rest, prefix(" "), problem = "[^ \n].*",
"\n", problem.trace = trace.pattern, prefix(" "), address = ".*",
"\n", address.trace = trace.pattern) ...
1.
deepstate_displays("/home/akhila/Pictures/inst/testfiles/rcpp_use_after_free/rcpp_use_after_free_output/log_be80e0f43b5dbf4378a994a2024865c134114068/valgrind_log")
But when I run the individual dataframe generation code it works fine. It gives the output as expected.
deepstate_displays <- function(logfile){
messages.raw <- nc::capture_all_str(
logfile,
"input starts\n",
inputs="(?:.*\n)+?",
"input ends\n",
rest="(?:.+\n)+")
messages.raw[, message.i := 1:.N]
files.list<-nc::capture_all_str(logfile,"Command: ./",
file.name=".*",
"_DeepState_TestHarness")
Testharness <- paste0("DeepState_Test_",basename(gsub("/inst/testfiles/.*","",logfile)),
"_deepstate_test_",files.list$file.name,"_test")
prefix <- function(after){
list("==[0-9]+==", after)
}
trace.pattern <- nc::quantifier(
prefix(" "),
"(?:at|by).*\n",
"+")
code.line <- function(pattern){
file.line.dt <- nc::capture_all_str(
pattern,
"==[0-9]+==","\\s*",
trace=".*\n",
".*",
Testharness)
return(file.line.dt$trace)
}
rest <- gsub("==[0-9]+== Warning:.*?\\n","",messages.raw$rest)
if( length(rest) >= 1){
messages.parsed <- messages.raw[, {
problems.dt <- nc::capture_all_str(
rest,
prefix(" "),
problem="[^ \n].*",
"\n",
problem.trace=trace.pattern,
prefix(" "),
address=".*",
"\n",
address.trace=trace.pattern)
problems.dt$problem.trace = code.line(problems.dt$problem.trace)
problems.dt$address.trace = code.line(problems.dt$address.trace)
data.table::data.table(
problems=list(problems.dt))
}, by=.(message.i)]
str(messages.parsed)
for(message.i in 1:nrow(messages.parsed)){
print(tibble::tibble(messages.parsed[["problems"]][[message.i]]))
}
}
sorry I don't understand. if you want me to help can you please clarify with a Minimal Reproducible Example?
Resolved the issue and able to generate the log accordingly.
ok to close this then?
Issue Resolved
Hello @tdhock,
I am trying to extract the error message from the log along with the line where the error occurred.
The code I wrote doesn't read all the error messages it reads the first error message only although I specified to read all the error messages. Can you please help me find where I am going wrong? I tried debugging the code but couldn't figure out where the mistake is.
For log data below, I get the following output
Required output:
Log data
Thanks