Opened 13 years ago

Closed 13 years ago

Last modified 13 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:
Has a Patch: no 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@… 13 years ago.
Simple test case to demonstrate the bug

Download all attachments as: .zip

Change History (6)

comment:1 Changed 13 years ago by simontaylor1@…

blocked: 428

Changed 13 years ago by simontaylor1@…

Attachment: LoaderBug.zip added

Simple test case to demonstrate the bug

comment:2 Changed 13 years ago by axeld

Status: newassigned

comment:3 Changed 13 years ago by axeld

Status: assignedclosed

comment:4 Changed 13 years ago by axeld

Resolution: fixed

comment:5 Changed 13 years ago by axeld

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.