Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
How can a non-recursive function appear twice in a stack trace?

I have a function check that is roughly like this:

void check() {
    // ...
    
    // Make some execute-only memory readable for subsequent inspection
    // using the mprotect system call
    mprotect(addr, length, PROT_READ | PROT_EXEC); // #1
    
    // Read the memory and do some integrity checks ...
    if (addr[42] == 13) { // #2
        // ...
    }
}

My program sometimes crashes with a segmentation fault in the line marked with #2, where the memory is read.

When I look at the stack trace, there are two(!) entries of my function check:

  1. Function check, line #2 (where the memory is read)
  2. Function check, line #1 (the mprotect system call)

So according to the stack trace, my function is somehow called from within itself, and that call happens in line #1 where I do the mprotect system call.

How is this possible?

EDIT: As requested, here's the original stack trace:

Crashed: Thread :  SIGSEGV  0x000000752eaba9a8
#00 pc 0xddc08 libnative-49.so (isAnyFunctionBeingHooked(_JNIEnv*, unsigned char const**, unsigned long) [NativeLib.cpp:185])
#01 pc 0xddc00 libnative-49.so (isAnyFunctionBeingHooked(_JNIEnv*, unsigned char const**, unsigned long) [NativeLib.cpp:164])
#02 pc 0xd7b54 libnative-49.so (dFAH(_JNIEnv*) [NativeLib.cpp:267])
// Following entries are outside of my code ...

Line 164 is the call to mprotect. Line 185 is reading the memory previously made readable by mprotect.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!