Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#490 closed bug (fixed)

gettimeofday segfaults when called from a shared library

Reported by: simontaylor1@… Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version:
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Trying to track down firefox starting issues brought me to this. I'll attach a simple test app after opening the bug.

If a shared library function calls gettimeofday (in sys/time.h, function in libroot I think), and an application which links to the library calls the library function, a segfault occurs. The same app works fine under R5. Interestingly, the call actually returns the correct value before the segfault happens (in the test app the value is displayed before the crash).

I thought this may be an issue with shared libraries calling functions in other shared libraries but setting up a test app where main() calls a function in lib1, which calls a function in lib2 to get a value to return, worked correctly. It also doesn't apply to all libroot functions, calling snooze from the shared lib also works fine.

I suspect it's the runtime loader that doesn't correctly initialise something when dynamically linking a shared library to another shared library. Then again, it might just be something perculiar about the gettimeofday function.

Attachments (1)

LoaderBug.zip (17.4 KB ) - added by simontaylor1@… 18 years ago.
Simple test case to demonstrate the bug

Download all attachments as: .zip

Change History (6)

comment:1 by simontaylor1@…, 18 years ago

blocked: 428

by simontaylor1@…, 18 years ago

Attachment: LoaderBug.zip added

Simple test case to demonstrate the bug

comment:2 by axeld, 18 years ago

Status: newassigned

comment:3 by axeld, 18 years ago

Status: assignedclosed

comment:4 by axeld, 18 years ago

Resolution: fixed

comment:5 by axeld, 18 years ago

This was a binary compatibility bug: struct timeval was larger on Haiku than it was on BeOS, and thus could overwrite the stack. The library thing was just coincidence. Fixed in hrev17142.

Note: See TracTickets for help on using tickets.